release.yml

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