release.yml

 1name: Release
 2
 3on:
 4  push:
 5    branches:
 6      - master
 7
 8permissions:
 9  contents: write # to create releases, tags and upload assets
10  pull-requests: read # to read pull request titles and labels for changelog
11  id-token: write # to sign the release
12
13jobs:
14  goreleaser:
15    runs-on: ubuntu-latest
16    steps:
17      - name: Checkout
18        uses: actions/checkout@v4
19        with:
20          # This is required to allow GoReleaser to fetch all tags
21          # to determine the next version number.
22          fetch-depth: 0
23
24      - name: Set up Go
25        uses: actions/setup-go@v5
26        with:
27          go-version: "1.24" # Match the Go version in go.mod
28
29      - name: Bump version and push tag
30        id: tag_version
31        uses: mathieudutour/github-tag-action@v6.1
32        with:
33          github_token: ${{ secrets.GITHUB_TOKEN }}
34
35      - name: Fetch the new tag
36        run: git fetch --tags
37        env:
38          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
40      - name: Install Snapcraft
41        run: sudo snap install snapcraft --classic
42
43      - name: Clean Snapcraft cache
44        run: sudo rm -rf /home/runner/.cache/snapcraft
45
46      - name: Run GoReleaser
47        if: steps.tag_version.outputs.new_tag
48        uses: goreleaser/goreleaser-action@v5
49        with:
50          version: latest
51          args: release --clean
52        env:
53          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54          HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
55          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}