From a1ab8ed51fb63f3fc64a8df54d04dab8b0ac93a1 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 22 Oct 2019 11:17:46 +0800 Subject: [PATCH] update goreleaser and travis --- .goreleaser.yml | 68 ++++++++++++++++++++++++++++++++----------------- .travis.yml | 38 +++++++++++++++++++-------- 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ad470db..a57f6bd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,13 +1,27 @@ +project_name: AriaNg-go + +env: + - GO111MODULE=on + - REPO=github.com/cxjava/AriaNg-go + before: hooks: + - go mod tidy - go generate ./... -project_name: AriaNg-go + builds: -- env: +- id: default + binary: AriaNg-go + env: - CGO_ENABLED=0 ldflags: - "-s -w" - binary: AriaNg-go + - -X "{{.Env.REPO}}/cmd.Version={{.Version}}" + - -X "{{.Env.REPO}}/cmd.Commit={{.FullCommit}}" + - -X "{{.Env.REPO}}/cmd.RepoUrl={{.GitURL}}" + - -X "{{.Env.REPO}}/cmd.BuildDate={{.Date}}" + - -X "{{.Env.REPO}}/cmd.BuiltWithGoVersion={{.Env.GO_VERSION}}" + - -X "{{.Env.REPO}}/cmd.BuiltBy={{.Env.BUILT_BY}}" flags: - -tags=release goos: @@ -21,28 +35,36 @@ builds: goarm: - 6 - 7 + ignore: + - goos: darwin + goarch: 386 + - goos: darwin + goarch: arm hooks: post: ./upx.sh -archive: - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - format: tar.gz - format_overrides: - - goos: windows - format: zip - wrap_in_directory: true - files: - - none* - replacements: - amd64: 64-bit - 386: 32-bit - arm: ARM - arm64: ARM64 - darwin: macOS - linux: Linux - windows: Windows - openbsd: OpenBSD - netbsd: NetBSD - freebsd: FreeBSD +archives: + - id: binary + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + format: tar.gz + format_overrides: + - goos: windows + format: zip + builds: + - default + wrap_in_directory: true + files: + - none* + replacements: + amd64: 64-bit + 386: 32-bit + arm: ARM + arm64: ARM64 + darwin: macOS + linux: Linux + windows: Windows + openbsd: OpenBSD + netbsd: NetBSD + freebsd: FreeBSD release: github: owner: cxjava diff --git a/.travis.yml b/.travis.yml index 5295fc5..4c3e0d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,18 @@ language: go -sudo: true + go: -- 1.12.x +- 1.13.x env: global: - - GORELEASER_VERSION=0.104.3 + - GO111MODULE=on + - GORELEASER_VERSION=0.120.2 - ARIANG_VERSION="1.1.4" - UPXVER="3.94" -before_install: + +install: + - curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b $(go env GOPATH)/bin v${GORELEASER_VERSION} - wget https://github.com/mayswind/AriaNg/releases/download/${ARIANG_VERSION}/AriaNg-${ARIANG_VERSION}.zip && unzip -q AriaNg-${ARIANG_VERSION}.zip -d AriaNg - - wget https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_amd64.deb - - sudo dpkg -i goreleaser_amd64.deb - | if [[ ! -f "./upx" ]] then @@ -27,9 +28,24 @@ before_install: - go get -u -v github.com/UnnoTed/fileb0x - go install github.com/UnnoTed/fileb0x -script: - - goreleaser --skip-validate --skip-sign --debug +deploy: + - provider: script + skip_cleanup: true + script: | + export GO_VERSION="$TRAVIS_GO_VERSION" + export BUILT_BY="$(whoami)@$(hostname)" + export GIT_BRANCH="$TRAVIS_BRANCH" + goreleaser --skip-validate --skip-sign --debug + on: + tags: true -branches: - only: - - master + - provider: script + skip_cleanup: true + script: | + export GO_VERSION="$TRAVIS_GO_VERSION" + export BUILT_BY="$(whoami)@$(hostname)" + export GIT_BRANCH="$TRAVIS_BRANCH" + goreleaser --rm-dist --snapshot --debug + on: + all_branches: true + tags: false \ No newline at end of file