| 1 | name: Release |
| 2 | |
| 3 | # Tag scheme: <app>/vX.Y.Z (e.g. sipp/v0.1.0) |
| 4 | # The app dir must contain its own .goreleaser.yml. |
| 5 | on: |
| 6 | push: |
| 7 | tags: |
| 8 | - "*/v*" |
| 9 | |
| 10 | permissions: |
| 11 | contents: write |
| 12 | |
| 13 | jobs: |
| 14 | goreleaser: |
| 15 | name: Release ${{ github.ref_name }} |
| 16 | runs-on: ubuntu-latest |
| 17 | steps: |
| 18 | - name: Parse app name from tag |
| 19 | id: parse |
| 20 | run: | |
| 21 | tag="${GITHUB_REF_NAME}" |
| 22 | app="${tag%%/*}" |
| 23 | version="${tag#*/}" |
| 24 | echo "app=$app" >> "$GITHUB_OUTPUT" |
| 25 | echo "version=$version" >> "$GITHUB_OUTPUT" |
| 26 | echo "Releasing $app $version" |
| 27 | |
| 28 | - uses: actions/checkout@v6 |
| 29 | with: |
| 30 | fetch-depth: 0 |
| 31 | |
| 32 | - name: Find previous tag for this app |
| 33 | id: prev |
| 34 | run: | |
| 35 | app="${{ steps.parse.outputs.app }}" |
| 36 | current="${GITHUB_REF_NAME}" |
| 37 | prev=$(git tag --list "${app}/v*" --sort=-v:refname | grep -v "^${current}$" | head -n1 || true) |
| 38 | if [ -n "$prev" ]; then |
| 39 | prev_ver="${prev#*/}" |
| 40 | echo "tag=$prev_ver" >> "$GITHUB_OUTPUT" |
| 41 | echo "Previous release: $prev_ver" |
| 42 | else |
| 43 | echo "tag=" >> "$GITHUB_OUTPUT" |
| 44 | echo "No previous release for $app" |
| 45 | fi |
| 46 | |
| 47 | - name: Verify app has goreleaser config |
| 48 | run: | |
| 49 | cfg="apps/${{ steps.parse.outputs.app }}/.goreleaser.yml" |
| 50 | if [ ! -f "$cfg" ]; then |
| 51 | echo "::error::No $cfg — app not configured for releases." |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | - uses: actions/setup-go@v6 |
| 56 | with: |
| 57 | go-version: '1.25.x' |
| 58 | cache-dependency-path: | |
| 59 | apps/*/go.sum |
| 60 | pkg/*/go.sum |
| 61 | |
| 62 | - name: Resolve replace directives |
| 63 | # GoReleaser archives need self-contained sources; replace dirs |
| 64 | # are fine for `go build` but tags must point at real versions |
| 65 | # or we keep local replaces working by running in-tree (which we do). |
| 66 | working-directory: apps/${{ steps.parse.outputs.app }} |
| 67 | run: go mod tidy |
| 68 | |
| 69 | - uses: goreleaser/goreleaser-action@v6 |
| 70 | with: |
| 71 | distribution: goreleaser |
| 72 | version: "~> v2" |
| 73 | # Builds binaries + archives + pushes brew formula. GH release |
| 74 | # itself is disabled via `release.disable` in app config; we |
| 75 | # create it below so it lands on the real prefixed tag. |
| 76 | args: release --clean --skip=announce,validate |
| 77 | workdir: apps/${{ steps.parse.outputs.app }} |
| 78 | env: |
| 79 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 81 | # Strip "app/" prefix so goreleaser parses as semver. |
| 82 | GORELEASER_CURRENT_TAG: ${{ steps.parse.outputs.version }} |
| 83 | GORELEASER_PREVIOUS_TAG: ${{ steps.prev.outputs.tag }} |
| 84 | |
| 85 | - name: Create GitHub release and upload artifacts |
| 86 | working-directory: apps/${{ steps.parse.outputs.app }} |
| 87 | env: |
| 88 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | run: | |
| 90 | app="${{ steps.parse.outputs.app }}" |
| 91 | version="${{ steps.parse.outputs.version }}" |
| 92 | tag="${GITHUB_REF_NAME}" |
| 93 | assets=$(find dist -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name 'checksums.txt' \)) |
| 94 | gh release create "$tag" \ |
| 95 | --title "$app $version" \ |
| 96 | --generate-notes \ |
| 97 | $assets |