mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
feat: Add ability to specify release name
Signed-off-by: Matt Stratton <matt.stratton@gmail.com>
This commit is contained in:
parent
f8ced34079
commit
f823cf2865
@ -116,9 +116,10 @@ type Archive struct {
|
||||
|
||||
// Release config used for the GitHub release
|
||||
type Release struct {
|
||||
GitHub Repo `yaml:",omitempty"`
|
||||
Draft bool `yaml:",omitempty"`
|
||||
Prerelease bool `yaml:",omitempty"`
|
||||
GitHub Repo `yaml:",omitempty"`
|
||||
Draft bool `yaml:",omitempty"`
|
||||
Prerelease bool `yaml:",omitempty"`
|
||||
NameTemplate string `yaml:",omitempty`
|
||||
|
||||
// Capture all undefined fields and should be empty after loading
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
@ -67,6 +67,18 @@ func ForChecksums(ctx *context.Context) (string, error) {
|
||||
)
|
||||
}
|
||||
|
||||
// ForTitle returns the release title based upon its template
|
||||
func ForTitle(ctx *context.Context) (string, error) {
|
||||
return apply{
|
||||
nameData{
|
||||
ProjectName: ctx.Config.ProjectName,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
Version: ctx.Version,
|
||||
}
|
||||
ctx.Config.Release.NameTemplate,
|
||||
}
|
||||
}
|
||||
|
||||
func apply(data nameData, templateStr string) (string, error) {
|
||||
var out bytes.Buffer
|
||||
t, err := template.New(data.ProjectName).Parse(templateStr)
|
||||
|
@ -14,6 +14,9 @@ import (
|
||||
// NameTemplate default name_template for the archive.
|
||||
const NameTemplate = "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
||||
|
||||
// ReleaseNameTemplate is the default name for the release.
|
||||
const ReleaseNameTemplate = "{{ .Version }}"
|
||||
|
||||
// SnapshotNameTemplate represents the default format for snapshot release names.
|
||||
const SnapshotNameTemplate = "SNAPSHOT-{{ .Commit }}"
|
||||
|
||||
@ -31,6 +34,9 @@ func (Pipe) Description() string {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
ctx.Config.Dist = "dist"
|
||||
if ctx.Config.Release.NameTemplate == "" {
|
||||
ctx.Config.Release.NameTemplate = ReleaseNameTemplate
|
||||
}
|
||||
if ctx.Config.Snapshot.NameTemplate == "" {
|
||||
ctx.Config.Snapshot.NameTemplate = SnapshotNameTemplate
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user