From cc6a93ab03374c0a96e791a6afa494accd484892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Fr=C3=B6ssman?= Date: Thu, 11 Feb 2016 14:23:52 +0100 Subject: [PATCH] Add setting to create draft releases Closes #10 --- DOCS.md | 1 + main.go | 7 ++++++- types.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DOCS.md b/DOCS.md index c39d797..a934242 100644 --- a/DOCS.md +++ b/DOCS.md @@ -4,6 +4,7 @@ can override the default configuration with the following parameters: * `api_key` - GitHub oauth token with public_repo or repo permission * `files` - Files to upload to GitHub Release, globs are allowed * `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 * `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 13854f2..00bd080 100644 --- a/main.go +++ b/main.go @@ -103,6 +103,7 @@ func main() { Owner: repo.Owner, Repo: repo.Name, Tag: filepath.Base(build.Ref), + Draft: vargs.Draft, } release, err := rc.buildRelease() @@ -123,6 +124,7 @@ type releaseClient struct { Owner string Repo string Tag string + Draft bool } func (rc *releaseClient) buildRelease() (*github.RepositoryRelease, error) { @@ -155,7 +157,10 @@ func (rc *releaseClient) getRelease() (*github.RepositoryRelease, error) { } func (rc *releaseClient) newRelease() (*github.RepositoryRelease, error) { - rr := &github.RepositoryRelease{TagName: github.String(rc.Tag)} + rr := &github.RepositoryRelease{ + TagName: github.String(rc.Tag), + Draft: &rc.Draft, + } release, _, err := rc.Client.Repositories.CreateRelease(rc.Owner, rc.Repo, rr) if err != nil { return nil, fmt.Errorf("Failed to create release: %s", err) diff --git a/types.go b/types.go index 295d5f7..c77e566 100644 --- a/types.go +++ b/types.go @@ -9,4 +9,5 @@ type Params struct { APIKey string `json:"api_key"` Files drone.StringSlice `json:"files"` Checksum drone.StringSlice `json:"checksum"` + Draft bool `json:"draft"` }