From 3cc9a19a1cd38921e58d98f3f1cb8c4666a1bd25 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 29 May 2018 19:40:00 +0200 Subject: [PATCH] Add a release system. (#550) * feat: add release system. * feat: goreleaser. * review: minor changes. --- .gitignore | 2 ++ .goreleaser.yml | 38 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 37 ++++++++++++++++++++++++++++--------- Makefile | 15 +++++++++++++++ cli.go | 10 +++------- 5 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 .goreleaser.yml create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 74d32f0a..7e000deb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ lego.exe lego .lego .idea +dist/ +builds/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..4a68fa94 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,38 @@ +project_name: lego + +builds: + - binary: lego + goos: + - windows + - darwin + - linux + - freebsd + - openbsd + - solaris + goarch: + - amd64 + - 386 + - arm + - arm64 + goarm: + - 7 + + ignore: + - goos: darwin + goarch: 386 + - goos: openbsd + goarch: arm + +archive: + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm + }}v{{ .Arm }}{{ end }}' + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE + - CHANGELOG.md + +release: + disable: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index d7a626e2..9e81312d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,35 @@ language: go + go: -- 1.8.x -- 1.9.x -- tip + - 1.9.x + - 1.x + services: - memcached + env: - MEMCACHED_HOSTS=localhost:11211 -install: -- go get -t ./... -script: -- go vet ./... -- go test -v ./... + before_install: -- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_26c593b079d9_key -iv $encrypted_26c593b079d9_iv -in .gitcookies.enc -out .gitcookies -d || true' + - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_26c593b079d9_key -iv $encrypted_26c593b079d9_iv -in .gitcookies.enc -out .gitcookies -d || true' + +install: + - go get -t ./... + +deploy: + - provider: script + skip_cleanup: true + script: curl -sL https://git.io/goreleaser | bash + on: + tags: true + condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$ + + - provider: releases + api_key: ${GITHUB_TOKEN} + file: dist/lego_* + skip_cleanup: true + overwrite: true + file_glob: true + on: + tags: true + condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e69ae04d --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +.PHONY: all + +default: clean checks test build + +test: clean + go test -v -cover ./... + +clean: + rm -rf dist/ builds/ cover.out + +checks: + go vet ./... + +build: clean + go build diff --git a/cli.go b/cli.go index 3878e095..1fce0c56 100644 --- a/cli.go +++ b/cli.go @@ -7,7 +7,6 @@ import ( "log" "os" "path" - "strings" "text/tabwriter" "github.com/urfave/cli" @@ -25,18 +24,15 @@ func logger() *log.Logger { return Logger } -var gittag string +var ( + version = "dev" +) func main() { app := cli.NewApp() app.Name = "lego" app.Usage = "Let's Encrypt client written in Go" - version := "0.4.1" - if strings.HasPrefix(gittag, "v") { - version = gittag - } - app.Version = version acme.UserAgent = "lego/" + app.Version