From aace3d4813cbbfdaf68883a7b91f5fcc897c03ce Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 29 Jan 2017 21:55:32 -0200 Subject: [PATCH 01/15] added fpm support closes #10 --- config/config.go | 12 +++++ context/context.go | 1 + goreleaser.yml | 10 ++++ main.go | 2 + pipeline/brew/brew.go | 4 +- pipeline/fpm/fpm.go | 100 ++++++++++++++++++++++++++++++++++++ pipeline/git/git.go | 8 ++- pipeline/release/release.go | 12 +++-- 8 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 pipeline/fpm/fpm.go diff --git a/config/config.go b/config/config.go index af5489d41..728613eac 100644 --- a/config/config.go +++ b/config/config.go @@ -43,12 +43,24 @@ type Release struct { Repo string } +// FPMFormat defines a FPM format and how it should be built +type FPMFormat struct { + Name string + Dependencies []string +} + +// FPM config +type FPM struct { + Formats []FPMFormat +} + // Project includes all project configuration type Project struct { Release Release Brew Homebrew Build Build Archive Archive + FPM FPM `yaml:"fpm"` } // Load config file diff --git a/context/context.go b/context/context.go index a474287f1..68ce61571 100644 --- a/context/context.go +++ b/context/context.go @@ -22,6 +22,7 @@ type Context struct { ReleaseRepo Repo BrewRepo Repo Archives map[string]string + Version string } // New context diff --git a/goreleaser.yml b/goreleaser.yml index 2da2612d2..0224ae72c 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -3,3 +3,13 @@ brew: folder: Formula dependencies: - git +fpm: + formats: + - + name: deb + dependencies: + - git + - + name: rpm + dependencies: + - git diff --git a/main.go b/main.go index 7c7888690..ea77d02bc 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/goreleaser/goreleaser/pipeline/build" "github.com/goreleaser/goreleaser/pipeline/defaults" "github.com/goreleaser/goreleaser/pipeline/env" + "github.com/goreleaser/goreleaser/pipeline/fpm" "github.com/goreleaser/goreleaser/pipeline/git" "github.com/goreleaser/goreleaser/pipeline/release" "github.com/goreleaser/goreleaser/pipeline/repos" @@ -33,6 +34,7 @@ var pipes = []pipeline.Pipe{ // real work build.Pipe{}, archive.Pipe{}, + fpm.Pipe{}, release.Pipe{}, brew.Pipe{}, } diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index aa03669a7..2236fe256 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -22,7 +22,7 @@ const formula = `class {{ .Name }} < Formula desc "{{ .Desc }}" homepage "{{ .Homepage }}" url "https://github.com/{{ .Repo }}/releases/download/{{ .Tag }}/{{ .File }}.{{ .Format }}" - version "{{ .Tag }}" + version "{{ .Version }}" sha256 "{{ .SHA256 }}" {{- if .Dependencies }} @@ -50,6 +50,7 @@ type templateData struct { Homepage string Repo string Tag string + Version string BinaryName string Caveats string File string @@ -156,6 +157,7 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData, Homepage: homepage, Repo: ctx.Config.Release.Repo, Tag: ctx.Git.CurrentTag, + Version: ctx.Version, BinaryName: ctx.Config.Build.BinaryName, Caveats: ctx.Config.Brew.Caveats, File: file, diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go new file mode 100644 index 000000000..e355c4a41 --- /dev/null +++ b/pipeline/fpm/fpm.go @@ -0,0 +1,100 @@ +package fpm + +import ( + "bytes" + "errors" + "log" + "os/exec" + "path/filepath" + + "golang.org/x/sync/errgroup" + + "github.com/goreleaser/goreleaser/context" +) + +var linuxArchives = []struct { + Key string + Arch string +}{ + { + Key: "linuxamd64", + Arch: "x86_64", + }, + { + Key: "linux386", + Arch: "i386", + }, +} + +// ErrNoFPM is shown when fpm cannot be found in $PATH +var ErrNoFPM = errors.New("fpm not present in $PATH") + +// Pipe for fpm packaging +type Pipe struct{} + +// Description of the pipe +func (Pipe) Description() string { + return "Creating Linux packages with fpm" +} + +// Run the pipe +func (Pipe) Run(ctx *context.Context) error { + cmd := exec.Command("which", "fpm") + if err := cmd.Run(); err != nil { + return ErrNoFPM + } + if len(ctx.Config.FPM.Formats) == 0 { + log.Println("No output formats configured") + return nil + } + var g errgroup.Group + for _, format := range ctx.Config.FPM.Formats { + for _, archive := range linuxArchives { + if ctx.Archives[archive.Key] == "" { + continue + } + archive := archive + g.Go(func() error { + return create( + ctx, + format.Name, + ctx.Archives[archive.Key], + archive.Arch, + format.Dependencies, + ) + }) + } + } + return g.Wait() +} + +func create(ctx *context.Context, format, archive, arch string, deps []string) error { + var path = filepath.Join("dist", archive) + var file = path + ".deb" + var name = ctx.Config.Build.BinaryName + log.Println("Creating", file) + + var options = []string{ + "-s", "dir", + "-t", format, + "-n", name, + "-v", ctx.Version, + "-a", arch, + "-C", path, + "-p", file, + "--force", + } + for _, dep := range deps { + options = append(options, "-d", dep) + } + options = append(options, name+"="+filepath.Join("/usr/local/bin", name)) + cmd := exec.Command("fpm", options...) + log.Println(cmd) + var stdout bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stdout + if err := cmd.Run(); err != nil { + return errors.New(stdout.String()) + } + return nil +} diff --git a/pipeline/git/git.go b/pipeline/git/git.go index 37b2d735a..5afbae61f 100644 --- a/pipeline/git/git.go +++ b/pipeline/git/git.go @@ -1,6 +1,10 @@ package git -import "github.com/goreleaser/goreleaser/context" +import ( + "strings" + + "github.com/goreleaser/goreleaser/context" +) // Pipe for brew deployment type Pipe struct{} @@ -30,5 +34,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { PreviousTag: previous, Diff: log, } + // removes usual `v` prefix + ctx.Version = strings.TrimPrefix(tag, "v") return } diff --git a/pipeline/release/release.go b/pipeline/release/release.go index 6acea0ce4..24a0c2640 100644 --- a/pipeline/release/release.go +++ b/pipeline/release/release.go @@ -31,9 +31,13 @@ func (Pipe) Run(ctx *context.Context) error { for _, archive := range ctx.Archives { archive := archive g.Go(func() error { - return upload(client, *r.ID, archive, ctx) + return upload(ctx, client, *r.ID, archive, ctx.Config.Archive.Format) }) - + for _, fpm := range ctx.Config.FPM.Formats { + g.Go(func() error { + return upload(ctx, client, *r.ID, archive, fpm.Name) + }) + } } return g.Wait() } @@ -67,8 +71,8 @@ func description(diff string) string { return result + "\nBuilt with " + string(bts) } -func upload(client *github.Client, releaseID int, archive string, ctx *context.Context) error { - archive = archive + "." + ctx.Config.Archive.Format +func upload(ctx *context.Context, client *github.Client, releaseID int, archive, format string) error { + archive = archive + "." + format file, err := os.Open("dist/" + archive) if err != nil { return err From 8b83e59971042f5fa8d7c02faf77637876498687 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 29 Jan 2017 22:01:26 -0200 Subject: [PATCH 02/15] fixed test --- pipeline/brew/brew_test.go | 3 ++- pipeline/fpm/fpm.go | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index f9dca51f8..e9ada50af 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -25,6 +25,7 @@ var defaultTemplateData = templateData{ Name: "Test", Repo: "caarlos0/test", Tag: "v0.1.3", + Version: "0.1.3", File: "test_Darwin_x86_64", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68", Format: "tar.gz", @@ -36,7 +37,7 @@ func assertDefaultTemplateData(t *testing.T, formulae string) { assert.Contains(formulae, "homepage \"https://google.com\"") assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"") assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"") - assert.Contains(formulae, "version \"v0.1.3\"") + assert.Contains(formulae, "version \"0.1.3\"") assert.Contains(formulae, "bin.install \"test\"") } diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index e355c4a41..53f1639f3 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -7,9 +7,8 @@ import ( "os/exec" "path/filepath" - "golang.org/x/sync/errgroup" - "github.com/goreleaser/goreleaser/context" + "golang.org/x/sync/errgroup" ) var linuxArchives = []struct { @@ -39,14 +38,14 @@ func (Pipe) Description() string { // Run the pipe func (Pipe) Run(ctx *context.Context) error { + if len(ctx.Config.FPM.Formats) == 0 { + log.Println("No output formats configured, skipping") + return nil + } cmd := exec.Command("which", "fpm") if err := cmd.Run(); err != nil { return ErrNoFPM } - if len(ctx.Config.FPM.Formats) == 0 { - log.Println("No output formats configured") - return nil - } var g errgroup.Group for _, format := range ctx.Config.FPM.Formats { for _, archive := range linuxArchives { From 3f2eb7c56b7995a555209234eefd4175e883505f Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 29 Jan 2017 22:33:08 -0200 Subject: [PATCH 03/15] code improvements --- config/config.go | 9 ++------- goreleaser.yml | 11 +++-------- pipeline/fpm/fpm.go | 35 +++++++++++++---------------------- pipeline/release/release.go | 12 +++++++++--- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/config/config.go b/config/config.go index 728613eac..43563482a 100644 --- a/config/config.go +++ b/config/config.go @@ -43,15 +43,10 @@ type Release struct { Repo string } -// FPMFormat defines a FPM format and how it should be built -type FPMFormat struct { - Name string - Dependencies []string -} - // FPM config type FPM struct { - Formats []FPMFormat + Formats []string + Dependencies []string } // Project includes all project configuration diff --git a/goreleaser.yml b/goreleaser.yml index 0224ae72c..1f7d62dae 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -5,11 +5,6 @@ brew: - git fpm: formats: - - - name: deb - dependencies: - - git - - - name: rpm - dependencies: - - git + - deb + dependencies: + - git diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 53f1639f3..13bd8ebfb 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -11,18 +11,9 @@ import ( "golang.org/x/sync/errgroup" ) -var linuxArchives = []struct { - Key string - Arch string -}{ - { - Key: "linuxamd64", - Arch: "x86_64", - }, - { - Key: "linux386", - Arch: "i386", - }, +var goarchToUnix = map[string]string{ + "386": "i386", + "amd64": "x86_64", } // ErrNoFPM is shown when fpm cannot be found in $PATH @@ -46,20 +37,20 @@ func (Pipe) Run(ctx *context.Context) error { if err := cmd.Run(); err != nil { return ErrNoFPM } + var g errgroup.Group for _, format := range ctx.Config.FPM.Formats { - for _, archive := range linuxArchives { - if ctx.Archives[archive.Key] == "" { + for _, goarch := range ctx.Config.Build.Goarch { + if ctx.Archives["linux"+goarch] == "" { continue } - archive := archive + archive := ctx.Archives["linux"+goarch] g.Go(func() error { return create( ctx, - format.Name, - ctx.Archives[archive.Key], - archive.Arch, - format.Dependencies, + format, + archive, + goarchToUnix[goarch], ) }) } @@ -67,7 +58,7 @@ func (Pipe) Run(ctx *context.Context) error { return g.Wait() } -func create(ctx *context.Context, format, archive, arch string, deps []string) error { +func create(ctx *context.Context, format, archive, arch string) error { var path = filepath.Join("dist", archive) var file = path + ".deb" var name = ctx.Config.Build.BinaryName @@ -83,12 +74,12 @@ func create(ctx *context.Context, format, archive, arch string, deps []string) e "-p", file, "--force", } - for _, dep := range deps { + for _, dep := range ctx.Config.FPM.Dependencies { options = append(options, "-d", dep) } options = append(options, name+"="+filepath.Join("/usr/local/bin", name)) cmd := exec.Command("fpm", options...) - log.Println(cmd) + var stdout bytes.Buffer cmd.Stdout = &stdout cmd.Stderr = &stdout diff --git a/pipeline/release/release.go b/pipeline/release/release.go index 24a0c2640..ff7fe87e9 100644 --- a/pipeline/release/release.go +++ b/pipeline/release/release.go @@ -4,6 +4,7 @@ import ( "log" "os" "os/exec" + "path/filepath" "github.com/google/go-github/github" "github.com/goreleaser/goreleaser/clients" @@ -33,9 +34,10 @@ func (Pipe) Run(ctx *context.Context) error { g.Go(func() error { return upload(ctx, client, *r.ID, archive, ctx.Config.Archive.Format) }) - for _, fpm := range ctx.Config.FPM.Formats { + for _, format := range ctx.Config.FPM.Formats { + format := format g.Go(func() error { - return upload(ctx, client, *r.ID, archive, fpm.Name) + return upload(ctx, client, *r.ID, archive, format) }) } } @@ -73,7 +75,11 @@ func description(diff string) string { func upload(ctx *context.Context, client *github.Client, releaseID int, archive, format string) error { archive = archive + "." + format - file, err := os.Open("dist/" + archive) + var path = filepath.Join("dist", archive) + if _, err := os.Stat(path); os.IsNotExist(err) { + return nil + } + file, err := os.Open(path) if err != nil { return err } From dd277451d8d416ad8cf81403a97211ab1f1228dc Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 07:53:05 -0200 Subject: [PATCH 04/15] using lookpath --- pipeline/fpm/fpm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 13bd8ebfb..8641db44a 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -33,8 +33,8 @@ func (Pipe) Run(ctx *context.Context) error { log.Println("No output formats configured, skipping") return nil } - cmd := exec.Command("which", "fpm") - if err := cmd.Run(); err != nil { + _, err := exec.LookPath("fpm") + if err != nil { return ErrNoFPM } From d13da655fd65b4b0073425fd6bf341137ad81e79 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 07:54:40 -0200 Subject: [PATCH 05/15] added comments --- pipeline/fpm/fpm.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 8641db44a..4c591ae71 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -77,6 +77,8 @@ func create(ctx *context.Context, format, archive, arch string) error { for _, dep := range ctx.Config.FPM.Dependencies { options = append(options, "-d", dep) } + // This basically tells fpm to put the binary in the /usr/local/bin + // binary=/usr/local/bin/binary options = append(options, name+"="+filepath.Join("/usr/local/bin", name)) cmd := exec.Command("fpm", options...) From e18d07e7779c14610107306d60e91db004c471dd Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 07:55:20 -0200 Subject: [PATCH 06/15] travis install fpm --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b59a70ef6..6ab716011 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ install: make setup script: - make ci after_success: - - git status - - test -n "$TRAVIS_TAG" && go run main.go + - test -n "$TRAVIS_TAG" && gem install fpm && go run main.go notifications: email: false From edf603604121b5550a60287c7908476d64cbc6b5 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 07:59:49 -0200 Subject: [PATCH 07/15] readme --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index a7dc072f6..ca0d2516c 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,28 @@ class Program < Formula end ``` +### FPM build customization + +GoReleaser can be wired to [fpm]() to generate `.deb`, `.rpm` and other archives. Check it's +[wiki](https://github.com/jordansissel/fpm/wiki) for more info. + +[fpm]: https://github.com/jordansissel/fpm + +```yml +# goreleaser.yml +fpm: + # Formats to generate as output + formats: + - deb + - rpm + + # Dependencies of your package + dependencies: + - git +``` + +Note that GoReleaser will not install `fpm` nor any of it's dependencies for you. + ## Integration with CI You may want to wire this to auto-deploy your new tags on [Travis](https://travis-ci.org), for example: From 289921d278e111b027e7b283fd9075e19bfbcccc Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 08:06:48 -0200 Subject: [PATCH 08/15] using version on build ldflag too --- pipeline/build/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/build/build.go b/pipeline/build/build.go index 2057abbcf..e7c7496cc 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -41,7 +41,7 @@ func (Pipe) Run(ctx *context.Context) error { } func build(name, goos, goarch string, ctx *context.Context) error { - ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Git.CurrentTag + ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Version output := "dist/" + name + "/" + ctx.Config.Build.BinaryName + extFor(goos) log.Println("Building", output) if ctx.Config.Build.Hooks.Pre != "" { From 4ca2bb210140ee5beb5ce82491d39d211ee4ed55 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 08:08:42 -0200 Subject: [PATCH 09/15] erroring if version is invalid --- pipeline/git/git.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pipeline/git/git.go b/pipeline/git/git.go index 5afbae61f..fd04ce8e5 100644 --- a/pipeline/git/git.go +++ b/pipeline/git/git.go @@ -1,11 +1,21 @@ package git import ( + "regexp" "strings" "github.com/goreleaser/goreleaser/context" ) +// ErrInvalidVersionFormat is return when the version isnt in a valid format +type ErrInvalidVersionFormat struct { + version string +} + +func (e ErrInvalidVersionFormat) Error() string { + return e.version + " is not in a valid version format" +} + // Pipe for brew deployment type Pipe struct{} @@ -36,5 +46,8 @@ func (Pipe) Run(ctx *context.Context) (err error) { } // removes usual `v` prefix ctx.Version = strings.TrimPrefix(tag, "v") + if matches, err := regexp.MatchString("[0-9.]+", ctx.Version); !matches || err != nil { + return ErrInvalidVersionFormat{ctx.Version} + } return } From 1c2221b2c5a078232cadbf16e1e6fc3f4f45eed7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 08:17:15 -0200 Subject: [PATCH 10/15] using cmd.CombinedOutput() --- pipeline/build/build.go | 8 ++------ pipeline/fpm/fpm.go | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pipeline/build/build.go b/pipeline/build/build.go index e7c7496cc..9b3f7bd77 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -1,7 +1,6 @@ package build import ( - "bytes" "errors" "log" "os" @@ -67,11 +66,8 @@ func run(goos, goarch string, command []string) error { cmd := exec.Command(command[0], command[1:]...) cmd.Env = append(cmd.Env, os.Environ()...) cmd.Env = append(cmd.Env, "GOOS="+goos, "GOARCH="+goarch) - var stdout bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stdout - if err := cmd.Run(); err != nil { - return errors.New(stdout.String()) + if out, err := cmd.CombinedOutput(); err != nil { + return errors.New(string(out)) } return nil } diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 4c591ae71..e3663d131 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -1,7 +1,6 @@ package fpm import ( - "bytes" "errors" "log" "os/exec" @@ -82,11 +81,8 @@ func create(ctx *context.Context, format, archive, arch string) error { options = append(options, name+"="+filepath.Join("/usr/local/bin", name)) cmd := exec.Command("fpm", options...) - var stdout bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stdout - if err := cmd.Run(); err != nil { - return errors.New(stdout.String()) + if out, err := cmd.CombinedOutput(); err != nil { + return errors.New(string(out)) } return nil } From a444a4ef5360f38373719fe9479ab99fdc19c90b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 10:01:05 -0200 Subject: [PATCH 11/15] improve version regex --- pipeline/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/git/git.go b/pipeline/git/git.go index fd04ce8e5..cdd62e67a 100644 --- a/pipeline/git/git.go +++ b/pipeline/git/git.go @@ -46,7 +46,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { } // removes usual `v` prefix ctx.Version = strings.TrimPrefix(tag, "v") - if matches, err := regexp.MatchString("[0-9.]+", ctx.Version); !matches || err != nil { + if matches, err := regexp.MatchString("^[0-9.]+", ctx.Version); !matches || err != nil { return ErrInvalidVersionFormat{ctx.Version} } return From 954935823df6b2fb449d89acee5356805ed8b33b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 10:01:29 -0200 Subject: [PATCH 12/15] comment IsNotExist on release pipe --- pipeline/release/release.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pipeline/release/release.go b/pipeline/release/release.go index ff7fe87e9..4efc050e9 100644 --- a/pipeline/release/release.go +++ b/pipeline/release/release.go @@ -76,6 +76,13 @@ func description(diff string) string { func upload(ctx *context.Context, client *github.Client, releaseID int, archive, format string) error { archive = archive + "." + format var path = filepath.Join("dist", archive) + // In case the file doesn't exist, we just ignore it. + // We do this because we can get invalid combinations of archive+format here, + // like darwinamd64 + deb or something like that. + // It's assumed that the archive pipe would fail the entire thing in case it fails to + // generate some archive, as well fpm pipe is expected to fail if something wrong happens. + // So, here, we just assume IsNotExist as an expected error. + // TODO: maybe add a list of files to upload in the context so we don't have to do this. if _, err := os.Stat(path); os.IsNotExist(err) { return nil } From 797af410a4eb164b2c645249e91619a980e1f531 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 14:22:39 -0200 Subject: [PATCH 13/15] note about version --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca0d2516c..02431c9cf 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,14 @@ GoReleaser uses the latest [Git tag](https://git-scm.com/book/en/v2/Git-Basics-T Create a tag: ```console -$ git tag -a v0.1 -m "First release" +$ git tag -a v0.1.0 -m "First release" ``` +**Note**: we recommend the use of [semantic versioning](http://semver.org/). We +are not enforcing it though. We do remove the `v` prefix and then enforce +that the next character is a number. So, `v0.1.0` and `0.1.0` are virtually the +same and are both accepted, while `version0.1.0` is not. + Now you can run GoReleaser at the root of your repository: ```console From e1b2d240acc9a559c6cd37b7268e2b8721b79dbd Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 14:44:39 -0200 Subject: [PATCH 14/15] debug --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ab716011..719bef157 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ install: make setup script: - make ci after_success: - - test -n "$TRAVIS_TAG" && gem install fpm && go run main.go + - test -n "$TRAVIS_TAG" && gem install fpm + - git status -sb + - test -n "$TRAVIS_TAG" && go run main.go + - git status -sb notifications: email: false From 0f2f8dd1a1dde711fe114f838c9431b057171a51 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 30 Jan 2017 14:53:21 -0200 Subject: [PATCH 15/15] concurrency fix --- pipeline/fpm/fpm.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index e3663d131..7e2681a65 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -44,13 +44,9 @@ func (Pipe) Run(ctx *context.Context) error { continue } archive := ctx.Archives["linux"+goarch] + arch := goarchToUnix[goarch] g.Go(func() error { - return create( - ctx, - format, - archive, - goarchToUnix[goarch], - ) + return create(ctx, format, archive, arch) }) } }