mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
commit
3aebff9d86
@ -262,6 +262,10 @@ release:
|
||||
github:
|
||||
owner: user
|
||||
name: repo
|
||||
|
||||
# If set to true, will not auto-publish the release.
|
||||
# Default is false
|
||||
draft: true
|
||||
```
|
||||
|
||||
You can also specify a release notes file in markdown format using the
|
||||
|
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
@ -68,34 +69,37 @@ func (c *githubClient) CreateFile(
|
||||
}
|
||||
|
||||
func (c *githubClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) {
|
||||
data := &github.RepositoryRelease{
|
||||
var release *github.RepositoryRelease
|
||||
var data = &github.RepositoryRelease{
|
||||
Name: github.String(ctx.Git.CurrentTag),
|
||||
TagName: github.String(ctx.Git.CurrentTag),
|
||||
Body: github.String(body),
|
||||
Draft: github.Bool(ctx.Config.Release.Draft),
|
||||
}
|
||||
r, _, err := c.client.Repositories.GetReleaseByTag(
|
||||
release, _, err = c.client.Repositories.GetReleaseByTag(
|
||||
ctx,
|
||||
ctx.Config.Release.GitHub.Owner,
|
||||
ctx.Config.Release.GitHub.Name,
|
||||
ctx.Git.CurrentTag,
|
||||
)
|
||||
if err != nil {
|
||||
r, _, err = c.client.Repositories.CreateRelease(
|
||||
release, _, err = c.client.Repositories.CreateRelease(
|
||||
ctx,
|
||||
ctx.Config.Release.GitHub.Owner,
|
||||
ctx.Config.Release.GitHub.Name,
|
||||
data,
|
||||
)
|
||||
return r.GetID(), err
|
||||
} else {
|
||||
release, _, err = c.client.Repositories.EditRelease(
|
||||
ctx,
|
||||
ctx.Config.Release.GitHub.Owner,
|
||||
ctx.Config.Release.GitHub.Name,
|
||||
release.GetID(),
|
||||
data,
|
||||
)
|
||||
}
|
||||
r, _, err = c.client.Repositories.EditRelease(
|
||||
ctx,
|
||||
ctx.Config.Release.GitHub.Owner,
|
||||
ctx.Config.Release.GitHub.Name,
|
||||
r.GetID(),
|
||||
data,
|
||||
)
|
||||
return r.GetID(), err
|
||||
log.Printf("Release updated: %v\n", release.GetHTMLURL())
|
||||
return release.GetID(), err
|
||||
}
|
||||
|
||||
func (c *githubClient) Upload(
|
||||
|
@ -67,6 +67,7 @@ type Archive struct {
|
||||
// Release config used for the GitHub release
|
||||
type Release struct {
|
||||
GitHub Repo
|
||||
Draft bool
|
||||
}
|
||||
|
||||
// FPM config
|
||||
|
@ -102,6 +102,10 @@ func doRun(ctx *context.Context, client client.Client) error {
|
||||
log.Println("Skipped because brew section is not configured")
|
||||
return nil
|
||||
}
|
||||
if ctx.Config.Release.Draft {
|
||||
log.Println("Skipped because release is marked as draft")
|
||||
return nil
|
||||
}
|
||||
path := filepath.Join(ctx.Config.Brew.Folder, ctx.Config.Build.Binary+".rb")
|
||||
log.Println("Pushing", path, "to", ctx.Config.Brew.GitHub.String())
|
||||
content, err := buildFormula(ctx, client)
|
||||
|
@ -165,6 +165,27 @@ func TestRunPipeNoPublish(t *testing.T) {
|
||||
assert.False(client.CreatedFile)
|
||||
}
|
||||
|
||||
func TestRunPipeDraftRelease(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
var ctx = &context.Context{
|
||||
Publish: true,
|
||||
Config: config.Project{
|
||||
Release: config.Release{
|
||||
Draft: true,
|
||||
},
|
||||
Brew: config.Homebrew{
|
||||
GitHub: config.Repo{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
client := &DummyClient{}
|
||||
assert.NoError(doRun(ctx, client))
|
||||
assert.False(client.CreatedFile)
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user