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

Add setting to create draft releases

Closes #10
This commit is contained in:
Thomas Frössman 2016-02-11 14:23:52 +01:00
parent 53bcc23e1f
commit cc6a93ab03
3 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

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