From 8031cb2498dd88d14f3e29c722767c8196ca889d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20K=C3=A4stner?= Date: Mon, 28 Mar 2022 19:00:51 +0200 Subject: [PATCH] add GoReleaser --- .github/workflows/main.yml | 51 ++++++++++++++++++++++++++++++++------ .goreleaser.yaml | 11 ++++++++ 2 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4755768..ae0fb6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,16 @@ name: Go on: push: - branches: [ main ] + tags: + - v* + branches: + - main pull_request: - branches: [ main ] + branches: + - main + +permissions: + contents: write jobs: @@ -13,14 +20,14 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: go-version: ^1.18 - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: Build run: go build -v . @@ -29,14 +36,14 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: go-version: ^1.18 - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: Test run: go test -v ./... @@ -49,3 +56,31 @@ jobs: # uses: codecov/codecov-action@v2 # with: # token: ${{ secrets.CODECOV_TOKEN }} + + release: + name: Release + needs: [build, test] + runs-on: ubuntu-latest + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch all tags + run: git fetch --force --tags + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.18 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..7cb2755 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,11 @@ +before: + hooks: + - go mod tidy +builds: + - skip: true +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:'