Support branches
This commit is contained in:
parent
a3e29cee46
commit
14b428aed4
10
main.go
10
main.go
@ -82,6 +82,11 @@ func main() {
|
|||||||
Usage: "repository name",
|
Usage: "repository name",
|
||||||
EnvVar: "DRONE_REPO_NAME",
|
EnvVar: "DRONE_REPO_NAME",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "repo.branch",
|
||||||
|
Usage: "repository branch",
|
||||||
|
EnvVar: "DRONE_REPO_BRANCH",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "build.event",
|
Name: "build.event",
|
||||||
Value: "push",
|
Value: "push",
|
||||||
@ -112,8 +117,9 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Owner: c.String("repo.owner"),
|
Owner: c.String("repo.owner"),
|
||||||
Name: c.String("repo.name"),
|
Name: c.String("repo.name"),
|
||||||
|
Branch: c.String("repo.branch"),
|
||||||
},
|
},
|
||||||
Build: Build{
|
Build: Build{
|
||||||
Event: c.String("build.event"),
|
Event: c.String("build.event"),
|
||||||
|
16
plugin.go
16
plugin.go
@ -15,8 +15,9 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
Repo struct {
|
Repo struct {
|
||||||
Owner string
|
Owner string
|
||||||
Name string
|
Name string
|
||||||
|
Branch string
|
||||||
}
|
}
|
||||||
|
|
||||||
Build struct {
|
Build struct {
|
||||||
@ -53,10 +54,6 @@ func (p Plugin) Exec() error {
|
|||||||
files []string
|
files []string
|
||||||
)
|
)
|
||||||
|
|
||||||
if p.Build.Event != "tag" {
|
|
||||||
return fmt.Errorf("The Gitea Release plugin is only available for tags")
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Config.APIKey == "" {
|
if p.Config.APIKey == "" {
|
||||||
return fmt.Errorf("You must provide an API key")
|
return fmt.Errorf("You must provide an API key")
|
||||||
}
|
}
|
||||||
@ -124,11 +121,16 @@ func (p Plugin) Exec() error {
|
|||||||
client.SetHTTPClient(insecureClient)
|
client.SetHTTPClient(insecureClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tag := p.Repo.Branch
|
||||||
|
if p.Build.Event == "tag" {
|
||||||
|
tag = strings.TrimPrefix(p.Commit.Ref, "refs/tags/")
|
||||||
|
}
|
||||||
|
|
||||||
rc := releaseClient{
|
rc := releaseClient{
|
||||||
Client: client,
|
Client: client,
|
||||||
Owner: p.Repo.Owner,
|
Owner: p.Repo.Owner,
|
||||||
Repo: p.Repo.Name,
|
Repo: p.Repo.Name,
|
||||||
Tag: strings.TrimPrefix(p.Commit.Ref, "refs/tags/"),
|
Tag: tag,
|
||||||
Draft: p.Config.Draft,
|
Draft: p.Config.Draft,
|
||||||
Prerelease: p.Config.PreRelease,
|
Prerelease: p.Config.PreRelease,
|
||||||
FileExists: p.Config.FileExists,
|
FileExists: p.Config.FileExists,
|
||||||
|
Loading…
Reference in New Issue
Block a user