1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Merge pull request #390 from goreleaser/prerelease

feat: Add prerelease option
This commit is contained in:
jorin 2017-10-05 16:19:34 +02:00 committed by GitHub
commit f8ced34079
4 changed files with 19 additions and 13 deletions

View File

@ -116,8 +116,9 @@ type Archive struct {
// Release config used for the GitHub release
type Release struct {
GitHub Repo `yaml:",omitempty"`
Draft bool `yaml:",omitempty"`
GitHub Repo `yaml:",omitempty"`
Draft bool `yaml:",omitempty"`
Prerelease bool `yaml:",omitempty"`
// Capture all undefined fields and should be empty after loading
XXX map[string]interface{} `yaml:",inline"`

View File

@ -19,6 +19,10 @@ release:
# If set to true, will not auto-publish the release.
# Default is false.
draft: true
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: true
```
## Custom release notes

View File

@ -84,10 +84,11 @@ func (c *githubClient) CreateFile(
func (c *githubClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) {
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),
Name: github.String(ctx.Git.CurrentTag),
TagName: github.String(ctx.Git.CurrentTag),
Body: github.String(body),
Draft: github.Bool(ctx.Config.Release.Draft),
Prerelease: github.Bool(ctx.Config.Release.Prerelease),
}
release, _, err = c.client.Repositories.GetReleaseByTag(
ctx,

View File

@ -23,14 +23,14 @@ func (Pipe) Description() string {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
client, err := client.NewGitHub(ctx)
c, err := client.NewGitHub(ctx)
if err != nil {
return err
}
return doRun(ctx, client)
return doRun(ctx, c)
}
func doRun(ctx *context.Context, client client.Client) error {
func doRun(ctx *context.Context, c client.Client) error {
if !ctx.Publish {
return pipeline.Skip("--skip-publish is set")
}
@ -41,7 +41,7 @@ func doRun(ctx *context.Context, client client.Client) error {
if err != nil {
return err
}
releaseID, err := client.CreateRelease(ctx, body.String())
releaseID, err := c.CreateRelease(ctx, body.String())
if err != nil {
return err
}
@ -54,13 +54,13 @@ func doRun(ctx *context.Context, client client.Client) error {
defer func() {
<-sem
}()
return upload(ctx, client, releaseID, artifact)
return upload(ctx, c, releaseID, artifact)
})
}
return g.Wait()
}
func upload(ctx *context.Context, client client.Client, releaseID int, artifact string) error {
func upload(ctx *context.Context, c client.Client, releaseID int, artifact string) error {
var path = filepath.Join(ctx.Config.Dist, artifact)
file, err := os.Open(path)
if err != nil {
@ -69,5 +69,5 @@ func upload(ctx *context.Context, client client.Client, releaseID int, artifact
defer func() { _ = file.Close() }()
_, name := filepath.Split(path)
log.WithField("file", file.Name()).WithField("name", name).Info("uploading to release")
return client.Upload(ctx, releaseID, name, file)
return c.Upload(ctx, releaseID, name, file)
}