1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00

project name, templates, readme, etc

This commit is contained in:
Carlos Alexandro Becker 2017-07-01 22:42:10 -03:00
parent a3c1e2b789
commit 6158285994
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
11 changed files with 48 additions and 37 deletions

View File

@ -75,7 +75,7 @@ PS: Invalid GOOS/GOARCH combinations will automatically be skipped.
This configuration specifies the build operating systems to Windows, Linux and MacOS using 64bit architecture, the name of the binaries is `drum-roll`. This configuration specifies the build operating systems to Windows, Linux and MacOS using 64bit architecture, the name of the binaries is `drum-roll`.
GoReleaser will then archive the result binaries of each Os/Arch into a separate file. The default format is `{{.Binary}}_{{.Os}}_{{.Arch}}`. GoReleaser will then archive the result binaries of each Os/Arch into a separate file. The default format is `{{.ProjectName}}_{{.Os}}_{{.Arch}}`.
You can change the archives name and format. You can also replace the OS and the Architecture with your own. You can change the archives name and format. You can also replace the OS and the Architecture with your own.
Another useful feature is to add files to archives, this is very useful for integrating assets like resource files. Another useful feature is to add files to archives, this is very useful for integrating assets like resource files.
@ -172,6 +172,15 @@ defaults are sensible and fit for most projects.
We'll cover all customizations available bellow: We'll cover all customizations available bellow:
### Project name
```yml
# goreleaser.yml
# The name of the project. It is used in the name of the brew formula, archives,
# etc. Defaults to the name of the git project.
project_name: myproject
```
### Build customization ### Build customization
```yml ```yml
@ -254,14 +263,14 @@ archive:
# You can change the name of the archive. # You can change the name of the archive.
# This is parsed with Golang template engine and the following variables # This is parsed with Golang template engine and the following variables
# are available: # are available:
# - Binary # - ProjectName
# - Tag # - Tag
# - Version (Tag with the `v` prefix stripped) # - Version (Tag with the `v` prefix stripped)
# - Os # - Os
# - Arch # - Arch
# - Arm (ARM version) # - Arm (ARM version)
# The default is `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}` # The default is `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
name_template: "{{.Binary}}_{{.Version}}_{{.Os}}_{{.Arch}}" name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
# Archive format. Valid options are `tar.gz` and `zip`. # Archive format. Valid options are `tar.gz` and `zip`.
# Default is `tar.gz` # Default is `tar.gz`

View File

@ -100,7 +100,7 @@ type Snapshot struct {
// Project includes all project configuration // Project includes all project configuration
type Project struct { type Project struct {
Name string `yaml:",omitempty"` ProjectName string `yaml:"project_name,omitempty"`
Release Release `yaml:",omitempty"` Release Release `yaml:",omitempty"`
Brew Homebrew `yaml:",omitempty"` Brew Homebrew `yaml:",omitempty"`
Builds []Build `yaml:",omitempty"` Builds []Build `yaml:",omitempty"`

View File

@ -36,7 +36,7 @@ func (c *githubClient) CreateFile(
}, },
Content: content.Bytes(), Content: content.Bytes(),
Message: github.String( Message: github.String(
ctx.Config.Name + " version " + ctx.Git.CurrentTag, ctx.Config.ProjectName + " version " + ctx.Git.CurrentTag,
), ),
} }

View File

@ -15,7 +15,8 @@ type nameData struct {
Arm string Arm string
Version string Version string
Tag string Tag string
Binary string Binary string // deprecated
ProjectName string
} }
// For returns the name for the given context, goos, goarch and goarm. // For returns the name for the given context, goos, goarch and goarm.
@ -26,7 +27,8 @@ func For(ctx *context.Context, goos, goarch, goarm string) (string, error) {
Arm: replace(ctx.Config.Archive.Replacements, goarm), Arm: replace(ctx.Config.Archive.Replacements, goarm),
Version: ctx.Version, Version: ctx.Version,
Tag: ctx.Git.CurrentTag, Tag: ctx.Git.CurrentTag,
Binary: ctx.Config.Name, Binary: ctx.Config.ProjectName,
ProjectName: ctx.Config.ProjectName,
} }
var out bytes.Buffer var out bytes.Buffer

View File

@ -20,7 +20,7 @@ func TestNameFor(t *testing.T) {
"amd64": "x86_64", "amd64": "x86_64",
}, },
}, },
Name: "test", ProjectName: "test",
} }
var ctx = &context.Context{ var ctx = &context.Context{
Config: config, Config: config,
@ -42,7 +42,7 @@ func TestInvalidNameTemplate(t *testing.T) {
Archive: config.Archive{ Archive: config.Archive{
NameTemplate: "{{.Binary}_{{.Os}}_{{.Arch}}_{{.Version}}", NameTemplate: "{{.Binary}_{{.Os}}_{{.Arch}}_{{.Version}}",
}, },
Name: "test", ProjectName: "test",
}, },
Git: context.GitInfo{ Git: context.GitInfo{
CurrentTag: "v1.2.3", CurrentTag: "v1.2.3",
@ -60,7 +60,7 @@ func TestNameDefaltTemplate(t *testing.T) {
Archive: config.Archive{ Archive: config.Archive{
NameTemplate: defaults.NameTemplate, NameTemplate: defaults.NameTemplate,
}, },
Name: "test", ProjectName: "test",
}, },
Version: "1.2.3", Version: "1.2.3",
} }

View File

@ -107,7 +107,7 @@ func doRun(ctx *context.Context, client client.Client) error {
log.Warn("skipped because release is marked as draft") log.Warn("skipped because release is marked as draft")
return nil return nil
} }
var path = filepath.Join(ctx.Config.Brew.Folder, ctx.Config.Name+".rb") var path = filepath.Join(ctx.Config.Brew.Folder, ctx.Config.ProjectName+".rb")
log.WithField("formula", path). log.WithField("formula", path).
WithField("repo", ctx.Config.Brew.GitHub.String()). WithField("repo", ctx.Config.Brew.GitHub.String()).
Info("pushing") Info("pushing")
@ -147,7 +147,7 @@ func dataFor(ctx *context.Context, client client.Client) (result templateData, e
return return
} }
return templateData{ return templateData{
Name: formulaNameFor(ctx.Config.Name), Name: formulaNameFor(ctx.Config.ProjectName),
Desc: ctx.Config.Brew.Description, Desc: ctx.Config.Brew.Description,
Homepage: ctx.Config.Brew.Homepage, Homepage: ctx.Config.Brew.Homepage,
Repo: ctx.Config.Release.GitHub, Repo: ctx.Config.Release.GitHub,

View File

@ -26,7 +26,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
file, err := os.OpenFile( file, err := os.OpenFile(
filepath.Join( filepath.Join(
ctx.Config.Dist, ctx.Config.Dist,
fmt.Sprintf("%v_checksums.txt", ctx.Config.Name), fmt.Sprintf("%v_checksums.txt", ctx.Config.ProjectName),
), ),
os.O_APPEND|os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.O_APPEND|os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
0644, 0644,

View File

@ -25,7 +25,7 @@ func TestPipe(t *testing.T) {
var ctx = &context.Context{ var ctx = &context.Context{
Config: config.Project{ Config: config.Project{
Dist: folder, Dist: folder,
Name: binary, ProjectName: binary,
}, },
} }
ctx.AddArtifact(file) ctx.AddArtifact(file)

View File

@ -34,8 +34,8 @@ func (Pipe) Run(ctx *context.Context) error {
if err := setReleaseDefaults(ctx); err != nil { if err := setReleaseDefaults(ctx); err != nil {
return err return err
} }
if ctx.Config.Name == "" { if ctx.Config.ProjectName == "" {
ctx.Config.Name = ctx.Config.Release.GitHub.Name ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
} }
setBuildDefaults(ctx) setBuildDefaults(ctx)
if ctx.Config.Brew.Install == "" { if ctx.Config.Brew.Install == "" {

View File

@ -69,7 +69,7 @@ func create(ctx *context.Context, format, folder, arch string) error {
var options = []string{ var options = []string{
"--input-type", "dir", "--input-type", "dir",
"--output-type", format, "--output-type", format,
"--name", ctx.Config.Name, "--name", ctx.Config.ProjectName,
"--version", ctx.Version, "--version", ctx.Version,
"--architecture", arch, "--architecture", arch,
"--chdir", path, "--chdir", path,

View File

@ -39,7 +39,7 @@ func TestRunPipe(t *testing.T) {
"darwinamd64": "anotherbin", "darwinamd64": "anotherbin",
}, },
Config: config.Project{ Config: config.Project{
Name: "mybin", ProjectName: "mybin",
Dist: dist, Dist: dist,
FPM: config.FPM{ FPM: config.FPM{
Formats: []string{"deb"}, Formats: []string{"deb"},