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: macos-latest
14    steps:
15      - name: Checkout
16        uses: actions/checkout@v6
17        with:
18          fetch-depth: 0
19
20      - name: Set up Go
21        uses: actions/setup-go@v6
22        with:
23          go-version: "1.26.1"
24
25      - name: Set up Zig
26        uses: goto-bus-stop/setup-zig@v2
27
28      - name: Bump version and push tag
29        id: tag_version
30        uses: mathieudutour/github-tag-action@v6.2
31        with:
32          github_token: ${{ secrets.GITHUB_TOKEN }}
33
34      - name: Fetch the new tag
35        run: git fetch --tags
36        env:
37          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
39      - name: Get macOS SDK path
40        id: macos_sdk
41        run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT
42
43      - name: Run GoReleaser
44        if: steps.tag_version.outputs.new_tag
45        uses: goreleaser/goreleaser-action@v7
46        with:
47          version: latest
48          args: release --clean
49        env:
50          SDK_PATH: ${{ steps.macos_sdk.outputs.path }}
51          GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
52          HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
53
54  snapcraft:
55    runs-on: ubuntu-latest
56    needs: goreleaser
57    steps:
58      - name: Checkout
59        uses: actions/checkout@v6
60        with:
61          fetch-depth: 0
62
63      - name: Set up Go
64        uses: actions/setup-go@v6
65        with:
66          go-version: "1.26.1"
67
68      - name: Install Snapcraft and LXD
69        run: |
70          sudo snap install snapcraft --classic
71          sudo snap install lxd
72          sudo lxd init --auto
73          sudo iptables -P FORWARD ACCEPT
74          sudo usermod -aG lxd $USER
75
76      - name: Build and publish snap
77        env:
78          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
79        run: |
80          sg lxd -c 'snapcraft pack'
81          snapcraft upload --release=stable *.snap