From 4cd081e31a23b95fbc0736f232cccf7b98b4048d Mon Sep 17 00:00:00 2001 From: Hiroshi Muraoka Date: Wed, 16 Oct 2024 17:50:44 +0900 Subject: [PATCH] Setup goreleaser Signed-off-by: Hiroshi Muraoka --- .github/workflows/release.yml | 39 +++++++++++++++++++++-------------- .goreleaser.yml | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9814b46a..2a88625a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,32 @@ name: Release on: - release: - types: [created] + push: + tags: + - 'v*' jobs: - releases-matrix: - name: Release Go Binary + goreleaser: + name: Release runs-on: ubuntu-latest - strategy: - matrix: - goos: [linux, windows, darwin] - goarch: [amd64] + timeout-minutes: 30 + permissions: + contents: write steps: - name: Checkout - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@v1.38 + uses: actions/checkout@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - goversion: 1.20 - pre_command: export CGO_ENABLED=0 - project_path: "./sql-migrate" + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..f2690369 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +version: 2 + +builds: + - binary: sql-migrate + main: ./sql-migrate/main.go + goos: + - darwin + - linux + goarch: + - '386' + - amd64 + - arm64 + goarm: + - '6' + ignore: + - goos: darwin + goarch: '386' + env: + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - -s -w + +gomod: + proxy: true + +archives: + - name_template: "{{.Binary}}_{{ .Version }}_{{.Os}}_{{.Arch}}" + files: + - README.md + - LICENSE + +release: + draft: false