Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #40 from flyinprogrammer/feature/tagtoversion
Browse files Browse the repository at this point in the history
Tag -> Version standarization
  • Loading branch information
caarlos0 authored Feb 18, 2018
2 parents c8c6654 + 77f8204 commit b5a249b
Show file tree
Hide file tree
Showing 12 changed files with 336 additions and 180 deletions.
132 changes: 121 additions & 11 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Your old `.travis.yml` file might have

```yaml
install:
- go get github.com/spf13/hugo
- go get github.com/gohugoio/hugo
```
This can take up to 30 seconds!
Expand All @@ -32,14 +32,14 @@ Hugo doesn't have (yet) a `godownloader.sh` file. So we will make our own:

```
# create a godownloader script
godownloader -repo spf/hugo > ./godownloader-hugo.sh`
godownloader -repo gohugoio/hugo > ./godownloader-hugo.sh
```
and add `godownloader-hugo.sh` to your GitHub repo. Edit your `.travis.yml` as such
```yaml
install:
- ./godownloader-hugo.sh 0.20.6
- ./godownloader-hugo.sh v0.33.1
```

Without a version number, GitHub is queried to get the latest version number. This is subject to the usual [GitHub rate limits](https://developer.github.com/v3/#rate-limiting). If working on a public machine (like travis-ci), be sure to set `GITHUB_TOKEN`.
Expand Down
25 changes: 13 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"errors"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -31,9 +30,9 @@ func makeShell(tplsrc string, cfg *config.Project) (string, error) {
// except for the default goreleaser templates, templates with
// conditionals will return an error
//
// {{ .Binary }} ---> NAME=${BINARY}, etc.
// {{ .Binary }} ---> [prefix]${BINARY}, etc.
//
func makeName(target string) (string, error) {
func makeName(prefix, target string) (string, error) {
// armv6 is the default in the shell script
// so do not need special template condition for ARM
armversion := "{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
Expand All @@ -55,7 +54,7 @@ func makeName(target string) (string, error) {
}

var out bytes.Buffer
out.WriteString("NAME=")
out.WriteString(prefix)
t, err := template.New("name").Parse(target)
if err != nil {
return "", err
Expand All @@ -65,26 +64,28 @@ func makeName(target string) (string, error) {
}

func loadURLs(path string) (*config.Project, error) {
for _, file := range []string{"goreleaser.yml", ".goreleaser.yml"} {
for _, file := range []string{"goreleaser.yml", ".goreleaser.yml", "goreleaser.yaml", ".goreleaser.yaml"} {
var url = fmt.Sprintf("%s/%s", path, file)
log.Printf("Reading %s", url)
project, err := loadURL(url)
if err == nil {
return project, err
if err != nil {
return nil, err
}
if project != nil {
return project, nil
}
}
return nil, fmt.Errorf("goreleaser.yml file not found")
return nil, fmt.Errorf("could not fetch a goreleaser configuration file")
}

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
if resp.StatusCode != 200 {
log.Printf("Issue reading %s returned: %d %s\n", file, resp.StatusCode, http.StatusText(resp.StatusCode))
return nil, nil
}
p, err := config.LoadReader(resp.Body)

Expand Down
Loading

0 comments on commit b5a249b

Please sign in to comment.