From df59d0eb04b129fcd599956f0c63b3803aad9033 Mon Sep 17 00:00:00 2001 From: b4b4r07 Date: Tue, 11 Feb 2020 00:49:12 +0900 Subject: [PATCH] Use github actions to release workflow --- .github/workflows/release.yml | 24 +++++++++++++++++ .goreleaser.yml | 50 +++++++++++++++++------------------ main.go | 7 ++--- 3 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6de855c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +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: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index ef50a9a..eca6dbd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,28 +1,28 @@ -# This is an example goreleaser.yaml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com +project_name: stein +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy builds: - - binary: stein - goos: - - darwin - - linux - goarch: - - amd64 + - main: . + binary: stein ldflags: - - -X main.Version={{.Version}} -archive: - format: zip - name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" - files: - - README.md - - CHANGELOG.md - - docs/**/*.md + - -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: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip release: - github: - owner: b4b4r07 - name: stein -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' + prerelease: auto diff --git a/main.go b/main.go index 8af56be..31bba79 100644 --- a/main.go +++ b/main.go @@ -14,8 +14,9 @@ import ( const ( // AppName is the application name AppName = "stein" - // Version is the application version - Version = "0.3.0" + + Version = "unset" + Revision = "unset" envEnvPrefix = "STEIN_" ) @@ -33,7 +34,7 @@ func main() { } log.SetOutput(logWriter) - log.Printf("[INFO] Stein version: %s", Version) + log.Printf("[INFO] Stein version: %s (%s)", Version, Revision) log.Printf("[INFO] Go runtime version: %s", runtime.Version()) log.Printf("[INFO] CLI args: %#v", os.Args)