release.yml

 1name: Release
 2
 3on:
 4  push:
 5    branches:
 6      - main
 7
 8permissions:
 9  contents: write
10
11jobs:
12  goreleaser:
13    runs-on: ubuntu-latest
14    steps:
15      - name: Checkout
16        uses: actions/checkout@v4
17        with:
18          fetch-depth: 0
19
20      - name: Generate version tag
21        id: version
22        run: |
23          # Get commit count as version number
24          COUNT=$(git rev-list --count HEAD)
25          SHORT_SHA=$(git rev-parse --short=6 HEAD)
26          # Convert 6-char hex SHA to octal, prefixed with 9 to ensure valid semver
27          SHA_OCTAL=$(printf '%o' "0x${SHORT_SHA}")
28          VERSION="0.${COUNT}.9${SHA_OCTAL}"
29          TAG="v${VERSION}"
30
31          echo "version=${VERSION}" >> $GITHUB_OUTPUT
32          echo "tag=${TAG}" >> $GITHUB_OUTPUT
33          echo "sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
34
35          # Create and push tag
36          git config user.name "github-actions[bot]"
37          git config user.email "github-actions[bot]@users.noreply.github.com"
38          git tag -a "${TAG}" -m "Release ${TAG} (${SHORT_SHA})"
39          git push origin "${TAG}"
40
41      - name: Set up Go
42        uses: actions/setup-go@v5
43        with:
44          go-version: '1.24'
45          cache: true
46
47      - name: Set up pnpm
48        uses: pnpm/action-setup@v4
49        with:
50          version: 9
51
52      - name: Set up Node.js
53        uses: actions/setup-node@v4
54        with:
55          node-version: '24'
56          cache: 'pnpm'
57          cache-dependency-path: ui/pnpm-lock.yaml
58
59      - name: Build UI
60        run: |
61          cd ui
62          pnpm install --frozen-lockfile
63          pnpm run build
64
65      - name: Build templates
66        run: |
67          for dir in templates/*/; do
68            name=$(basename "$dir")
69            echo "Creating $name.tar.gz..."
70            tar -czf "templates/$name.tar.gz" -C "templates/$name" --exclude='.DS_Store' .
71          done
72
73      - name: Run GoReleaser
74        uses: goreleaser/goreleaser-action@v6
75        with:
76          distribution: goreleaser
77          version: "~> v2"
78          args: release --clean
79        env:
80          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81          HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}