Support branches
This commit is contained in:
parent
54b8bc5018
commit
ac29e29e79
6
main.go
6
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",
|
||||||
@ -114,6 +119,7 @@ func run(c *cli.Context) error {
|
|||||||
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"),
|
||||||
|
12
plugin.go
12
plugin.go
@ -17,6 +17,7 @@ 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