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