From 1a2f44f5a86813e03688d84a88b3b5e9b0c9475c Mon Sep 17 00:00:00 2001 From: b4b4r07 Date: Tue, 25 Feb 2020 12:27:44 +0900 Subject: [PATCH] Add new release flow with goreleaser --- .github/workflows/release.yml | 27 +++++++++++++++++++++++++++ .goreleaser.yml | 28 ++++++++++++++++++++++++++++ main.go | 4 +++- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3c79ac5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: release +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: 1.13 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: release --rm-dist + env: + # To upload homebrew formula to other repos, + # need to set the dedicated token having enough permissions + # https://github.com/goreleaser/goreleaser/issues/982 + GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..7dab406 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,28 @@ +project_name: tfnotify +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy +builds: + - main: . + binary: tfnotify + ldflags: + - -s -w + - -X main.version={{.Version}} + - -X main.revision={{.ShortCommit}} + env: + - CGO_ENABLED=0 +archives: + - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + darwin: 'darwin' + linux: 'linux' + windows: 'windows' + 386: '386' + amd64: 'amd64' + format_overrides: + - goos: 'windows' + format: 'zip' +release: + prerelease: auto diff --git a/main.go b/main.go index 46448c3..f0d0b2d 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,9 @@ import ( const ( name = "tfnotify" description = "Notify the execution result of terraform command" - version = "0.5.0" + + version = "unset" + revision = "unset" ) type tfnotify struct {