1
0
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:
Matt Stratton 2017-10-07 04:31:14 -05:00
parent f8ced34079
commit f823cf2865
No known key found for this signature in database
GPG Key ID: EF2B156510452D81
3 changed files with 22 additions and 3 deletions

View File

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

View File

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

View File

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