0
0
mirror of https://github.com/thegeeklab/wp-gitea-release.git synced 2024-11-21 13:50:40 +00:00

Implement prerelease option

This commit is contained in:
Kévin Darcel 2017-03-13 17:07:52 -06:00
parent 22db67489d
commit 6505d772c8
No known key found for this signature in database
GPG Key ID: F29F49C57EA3F7AD
4 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,7 @@ The following parameters are used to configure the plugin:
* **file_exists** - what to do if an file asset already exists, supported values: **overwrite** (default), **skip** and **fail**
* **checksum** - checksum takes hash methods to include in your GitHub release for the files specified. Supported hash methods include md5, sha1, sha256, sha512, adler32, and crc32.
* **draft** - create a draft release if set to true
* **prerelease** - set the release as prerelease if set to true
* **base_url** - GitHub base URL, only required for GHE
* **upload_url** - GitHub upload URL, only required for GHE

View File

@ -44,6 +44,11 @@ func main() {
Usage: "create a draft release",
EnvVar: "PLUGIN_DRAFT,GITHUB_RELEASE_DRAFT",
},
cli.BoolFlag{
Name: "prerelease",
Usage: "set the release as prerelease",
EnvVar: "PLUGIN_PRERELEASE,GITHUB_RELEASE_PRERELEASE",
},
cli.StringFlag{
Name: "base-url",
Value: "https://api.github.com/",
@ -112,6 +117,7 @@ func run(c *cli.Context) error {
FileExists: c.String("file-exists"),
Checksum: c.StringSlice("checksum"),
Draft: c.Bool("draft"),
Prerelease: c.Bool("prerelease"),
BaseURL: c.String("base-url"),
UploadURL: c.String("upload-url"),
},

View File

@ -30,6 +30,7 @@ type (
FileExists string
Checksum []string
Draft bool
Prerelease bool
BaseURL string
UploadURL string
}
@ -117,6 +118,7 @@ func (p Plugin) Exec() error {
Repo: p.Repo.Name,
Tag: filepath.Base(p.Commit.Ref),
Draft: p.Config.Draft,
Prerelease: p.Config.Prerelease,
FileExists: p.Config.FileExists,
}

View File

@ -15,6 +15,7 @@ type releaseClient struct {
Repo string
Tag string
Draft bool
Prerelease bool
FileExists string
}
@ -51,8 +52,9 @@ func (rc *releaseClient) getRelease() (*github.RepositoryRelease, error) {
func (rc *releaseClient) newRelease() (*github.RepositoryRelease, error) {
rr := &github.RepositoryRelease{
TagName: github.String(rc.Tag),
Draft: &rc.Draft,
TagName: github.String(rc.Tag),
Draft: &rc.Draft,
Prerelease: &rc.Prerelease,
}
release, _, err := rc.Client.Repositories.CreateRelease(rc.Owner, rc.Repo, rr)