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"` }