You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-17 01:42:37 +02:00
feat: Add prerelease option
Add an config option to `release` section to set a release at not ready for production. Closes #384
This commit is contained in:
@ -116,8 +116,9 @@ type Archive struct {
|
|||||||
|
|
||||||
// Release config used for the GitHub release
|
// Release config used for the GitHub release
|
||||||
type Release struct {
|
type Release struct {
|
||||||
GitHub Repo `yaml:",omitempty"`
|
GitHub Repo `yaml:",omitempty"`
|
||||||
Draft bool `yaml:",omitempty"`
|
Draft bool `yaml:",omitempty"`
|
||||||
|
Prerelease bool `yaml:",omitempty"`
|
||||||
|
|
||||||
// Capture all undefined fields and should be empty after loading
|
// Capture all undefined fields and should be empty after loading
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
|
@ -19,6 +19,10 @@ release:
|
|||||||
# If set to true, will not auto-publish the release.
|
# If set to true, will not auto-publish the release.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
draft: true
|
draft: true
|
||||||
|
|
||||||
|
# If set to true, will mark the release as not ready for production.
|
||||||
|
# Default is false.
|
||||||
|
prerelease: true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Custom release notes
|
## Custom release notes
|
||||||
|
@ -84,10 +84,11 @@ func (c *githubClient) CreateFile(
|
|||||||
func (c *githubClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) {
|
func (c *githubClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) {
|
||||||
var release *github.RepositoryRelease
|
var release *github.RepositoryRelease
|
||||||
var data = &github.RepositoryRelease{
|
var data = &github.RepositoryRelease{
|
||||||
Name: github.String(ctx.Git.CurrentTag),
|
Name: github.String(ctx.Git.CurrentTag),
|
||||||
TagName: github.String(ctx.Git.CurrentTag),
|
TagName: github.String(ctx.Git.CurrentTag),
|
||||||
Body: github.String(body),
|
Body: github.String(body),
|
||||||
Draft: github.Bool(ctx.Config.Release.Draft),
|
Draft: github.Bool(ctx.Config.Release.Draft),
|
||||||
|
Prerelease: github.Bool(ctx.Config.Release.Prerelease),
|
||||||
}
|
}
|
||||||
release, _, err = c.client.Repositories.GetReleaseByTag(
|
release, _, err = c.client.Repositories.GetReleaseByTag(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -23,14 +23,14 @@ func (Pipe) Description() string {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
func (Pipe) Run(ctx *context.Context) error {
|
||||||
client, err := client.NewGitHub(ctx)
|
c, err := client.NewGitHub(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if !ctx.Publish {
|
||||||
return pipeline.Skip("--skip-publish is set")
|
return pipeline.Skip("--skip-publish is set")
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ func doRun(ctx *context.Context, client client.Client) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
releaseID, err := client.CreateRelease(ctx, body.String())
|
releaseID, err := c.CreateRelease(ctx, body.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -54,13 +54,13 @@ func doRun(ctx *context.Context, client client.Client) error {
|
|||||||
defer func() {
|
defer func() {
|
||||||
<-sem
|
<-sem
|
||||||
}()
|
}()
|
||||||
return upload(ctx, client, releaseID, artifact)
|
return upload(ctx, c, releaseID, artifact)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return g.Wait()
|
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)
|
var path = filepath.Join(ctx.Config.Dist, artifact)
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,5 +69,5 @@ func upload(ctx *context.Context, client client.Client, releaseID int, artifact
|
|||||||
defer func() { _ = file.Close() }()
|
defer func() { _ = file.Close() }()
|
||||||
_, name := filepath.Split(path)
|
_, name := filepath.Split(path)
|
||||||
log.WithField("file", file.Name()).WithField("name", name).Info("uploading to release")
|
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)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user