From 6505d772c88efa1c51fefbf5ff9984aa128fe894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20Darcel?= Date: Mon, 13 Mar 2017 17:07:52 -0600 Subject: [PATCH] Implement prerelease option --- DOCS.md | 1 + main.go | 6 ++++++ plugin.go | 2 ++ release.go | 6 ++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DOCS.md b/DOCS.md index 07d11ce..d26ef62 100644 --- a/DOCS.md +++ b/DOCS.md @@ -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 diff --git a/main.go b/main.go index 4eb3a4d..ea0509b 100644 --- a/main.go +++ b/main.go @@ -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"), }, diff --git a/plugin.go b/plugin.go index c3282f4..615f1cb 100644 --- a/plugin.go +++ b/plugin.go @@ -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, } diff --git a/release.go b/release.go index cd8c833..1e0326d 100644 --- a/release.go +++ b/release.go @@ -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)