diff --git a/.travis.yml b/.travis.yml index 0eea02f..b30c22f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,6 @@ addons: script: - make ci + +notifications: + email: false diff --git a/Gopkg.lock b/Gopkg.lock index 5df6d01..ec92ca4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,21 +1,33 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. +[[projects]] + branch = "master" + name = "github.com/apex/log" + packages = ["."] + revision = "0296d6eb16bb28f8a0c55668affcf4876dc269be" + [[projects]] name = "github.com/goreleaser/goreleaser" packages = ["config","context","pipeline/defaults"] - revision = "fbcae4b5bec60816e6ed23b22cabd5a12c507d62" - version = "v0.20.3" + revision = "658d46397f6f6913d767987ab21c2de4d8ed9681" + version = "v0.28.5" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" [[projects]] - branch = "v1" - name = "gopkg.in/yaml.v1" + branch = "v2" + name = "gopkg.in/yaml.v2" packages = ["."] - revision = "9f9df34309c04878acc86042b16630b0f696e1de" + revision = "25c4ec802a7d637f88d584ab26798e94ad14c13b" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b8819a7af455559909afdf1c8ef2ea0b9e06416dedbcc9acd15b46f96ed6cd32" + inputs-digest = "163f1c73e044d96155004b33881f1e1c4c4b80eab60b168e228f7e483ce15319" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index c6defc6..9425a54 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,56 +1,22 @@ -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" +# Gopkg.toml example # -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. # -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] # -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" # -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" -[[dependencies]] - branch = "master" - name = "github.com/goreleaser/goreleaser" diff --git a/goreleaser.yml b/goreleaser.yml index 8e1da18..45d7738 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -1,5 +1,3 @@ -homepage: &homepage https://github.com/goreleaser/godownloader -description: &description Download Go binaries as fast and easily as possible build: goos: - linux @@ -25,13 +23,13 @@ brew: owner: godownloader name: homebrew-tap folder: Formula - homepage: *homepage - description: *description + homepage: https://github.com/goreleaser/godownloader + description: Download Go binaries as fast and easily as possible dependencies: - git fpm: - homepage: *homepage - description: *description + homepage: https://github.com/goreleaser/godownloader + description: Download Go binaries as fast and easily as possible maintainer: Nick Galbreath vendor: GoDownloader formats: diff --git a/main.go b/main.go index d55d341..be6cfb4 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "errors" "flag" "fmt" "log" @@ -11,6 +12,7 @@ import ( "text/template" "github.com/goreleaser/goreleaser/config" + "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/pipeline/defaults" ) @@ -65,11 +67,28 @@ func makeName(target string) (string, error) { return out.String(), err } +func loadURLs(path string) (*config.Project, error) { + for _, file := range []string{"goreleaser.yml", ".goreleaser.yml"} { + var url = fmt.Sprintf("%s/%s", path, file) + log.Printf("Reading %s", url) + project, err := loadURL(url) + if err == nil { + return project, err + } + } + return nil, fmt.Errorf("goreleaser.yml file not found") +} + +var errNotFound = errors.New("404: not found") + func loadURL(file string) (*config.Project, error) { resp, err := http.Get(file) if err != nil { return nil, err } + if resp.StatusCode == 404 { + return nil, errNotFound + } p, err := config.LoadReader(resp.Body) // to make errcheck happy @@ -91,13 +110,11 @@ func Load(repo string, file string) (project *config.Project, err error) { return nil, fmt.Errorf("Need a repo or file") } if file == "" { - file = "https://raw.githubusercontent.com/" + repo + "/master/goreleaser.yml" - } - - log.Printf("Reading %s", file) - if strings.HasPrefix(file, "http") { - project, err = loadURL(file) + project, err = loadURLs( + fmt.Sprintf("https://raw.githubusercontent.com/%s/master", repo), + ) } else { + log.Printf("Reading %s", file) project, err = loadFile(file) } if err != nil { @@ -113,17 +130,21 @@ func Load(repo string, file string) (project *config.Project, err error) { project.Release.GitHub.Name = path.Base(repo) } - // set default archive format - if project.Archive.Format == "" { - project.Archive.Format = "tar.gz" - } + var ctx = context.New(*project) + err = defaults.Pipe{}.Run(ctx) + project = &ctx.Config // set default binary name - if project.Build.Binary == "" { - project.Build.Binary = path.Base(repo) + if len(project.Builds) == 0 { + project.Builds = []config.Build{ + {Binary: path.Base(repo)}, + } + } + if project.Builds[0].Binary == "" { + project.Builds[0].Binary = path.Base(repo) } - return project, nil + return project, err } func main() { diff --git a/samples/godownloader-goreleaser.sh b/samples/godownloader-goreleaser.sh index 5e01704..897f2a8 100755 --- a/samples/godownloader-goreleaser.sh +++ b/samples/godownloader-goreleaser.sh @@ -69,6 +69,9 @@ is_supported_platform() { windows/amd64) found=0 ;; windows/arm64) found=0 ;; + linux/armv6) found=0 ;; + darwin/armv6) found=0 ;; + windows/armv6) found=0 ;; esac return $found } diff --git a/samples/godownloader-hugo.sh b/samples/godownloader-hugo.sh index 4e8f084..2c4bbe6 100755 --- a/samples/godownloader-hugo.sh +++ b/samples/godownloader-hugo.sh @@ -6,12 +6,12 @@ set -e usage() { this=$1 cat < samples/godownloader-hugo.sh +./godownloader -repo gohugoio/hugo > samples/godownloader-hugo.sh ./godownloader -repo goreleaser/goreleaser > samples/godownloader-goreleaser.sh ./godownloader -repo client9/misspell > samples/godownloader-misspell.sh ./godownloader -source equinoxio -repo tdewolff/minify > samples/godownloader-minify.sh diff --git a/shell_equinoxio.go b/shell_equinoxio.go index e36074e..cd6c425 100644 --- a/shell_equinoxio.go +++ b/shell_equinoxio.go @@ -16,9 +16,10 @@ func processEquinoxio(repo string) (string, error) { project := config.Project{} project.Release.GitHub.Owner = path.Dir(repo) project.Release.GitHub.Name = path.Base(repo) - project.Build.Binary = path.Base(repo) + project.Builds = []config.Build{ + {Binary: path.Base(repo)}, + } project.Archive.Format = "tgz" - return makeShell(shellEquinoxio, &project) } @@ -78,7 +79,7 @@ execute() { echo "$PREFIX: installed ${BINDIR}/${BINARY}" }` + shellfn + `OWNER={{ .Release.GitHub.Owner }} REPO={{ .Release.GitHub.Name }} -BINARY={{ .Build.Binary }} +BINARY={{ (index .Builds 0).Binary }} FORMAT={{ .Archive.Format }} BINDIR=${BINDIR:-./bin} CHANNEL=stable diff --git a/shell_godownloader.go b/shell_godownloader.go index 42eaae9..d070e94 100644 --- a/shell_godownloader.go +++ b/shell_godownloader.go @@ -78,19 +78,20 @@ is_supported_platform() { platform=$1 found=1 case "$platform" in - {{- range $goos := $.Build.Goos }}{{ range $goarch := $.Build.Goarch }} + {{- range $goos := (index $.Builds 0).Goos }}{{ range $goarch := (index $.Builds 0).Goarch }} {{ if not (eq $goarch "arm") }} {{ $goos }}/{{ $goarch }}) found=0 ;;{{ end }} {{- end }}{{ end }} - {{- if $.Build.Goarm }} - {{- range $goos := $.Build.Goos }}{{ range $goarch := $.Build.Goarch }}{{ range $goarm := $.Build.Goarm }} -{{- if eq $goarch "arm" }} {{ $goos }}/armv{{ $goarm }}) found=0 ;; -{{ end }} + {{- if (index $.Builds 0).Goarm }} + {{- range $goos := (index $.Builds 0).Goos }}{{ range $goarch := (index $.Builds 0).Goarch }}{{ range $goarm := (index $.Builds 0).Goarm }} +{{- if eq $goarch "arm" }} + {{ $goos }}/armv{{ $goarm }}) found=0 ;; +{{- end }} {{- end }}{{ end }}{{ end }} {{- end }} esac - {{- if $.Build.Ignore }} - case "$platform" in - {{- range $ignore := $.Build.Ignore }} + {{- if (index $.Builds 0).Ignore }} + case "$platform" in + {{- range $ignore := (index $.Builds 0).Ignore }} {{ $ignore.Goos }}/{{ $ignore.Goarch }}{{ if $ignore.Goarm }}v{{ $ignore.Goarm }}{{ end }}) found=1 ;;{{ end }} esac {{- end }} @@ -149,7 +150,7 @@ adjust_arch() { ` + shellfn + ` OWNER={{ $.Release.GitHub.Owner }} REPO={{ $.Release.GitHub.Name }} -BINARY={{ .Build.Binary }} +BINARY={{ (index .Builds 0).Binary }} FORMAT={{ .Archive.Format }} OS=$(uname_os) ARCH=$(uname_arch) diff --git a/shell_raw.go b/shell_raw.go index 3a30b1e..15ff444 100644 --- a/shell_raw.go +++ b/shell_raw.go @@ -29,9 +29,10 @@ func processRaw(repo string, exe string, nametpl string) (string, error) { project := config.Project{} project.Release.GitHub.Owner = path.Dir(repo) project.Release.GitHub.Name = path.Base(repo) - project.Build.Binary = exe + project.Builds = []config.Build{ + {Binary: exe}, + } project.Archive.NameTemplate = name - return makeShell(shellRaw, &project) } @@ -102,7 +103,7 @@ execute() { ` + shellfn + ` OWNER={{ .Release.GitHub.Owner }} REPO={{ .Release.GitHub.Name }} -BINARY={{ .Build.Binary }} +BINARY={{ (index .Builds 0).Binary }} BINDIR=${BINDIR:-./bin} PREFIX="$OWNER/$REPO" OS=$(uname_os)