name: Release on: push: tags: - "v*" permissions: contents: read concurrency: group: release-${{ github.ref }} cancel-in-progress: false jobs: test: name: Go checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod cache: true - name: go vet run: go vet ./... - name: go test run: go test -race -count=1 ./... - name: go build run: go build ./... build: name: Build ${{ matrix.artifact }} needs: test runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - artifact: limen-linux-amd64 goos: linux goarch: amd64 - artifact: limen-linux-arm64 goos: linux goarch: arm64 - artifact: limen-macos-amd64 goos: darwin goarch: amd64 - artifact: limen-macos-arm64 goos: darwin goarch: arm64 steps: - uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod cache: true - name: Resolve version id: version run: | VERSION="${GITHUB_REF_NAME#v}" echo "version=${VERSION}" >> "$GITHUB_OUTPUT" - name: Build binary env: CGO_ENABLED: "0" GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} VERSION: ${{ steps.version.outputs.version }} run: | mkdir -p dist go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o "dist/${{ matrix.artifact }}" . - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: dist/${{ matrix.artifact }} release: name: Publish GitHub release needs: build runs-on: ubuntu-latest permissions: contents: write steps: - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Prepare release assets run: | mkdir -p release find artifacts -type f -exec cp {} release/ \; cd release shasum -a 256 ./limen-* > checksums.txt ls -la - name: Create release uses: softprops/action-gh-release@v2 with: files: release/* generate_release_notes: true update-homebrew: name: Update Homebrew tap needs: release runs-on: ubuntu-latest env: HOMEBREW_TAP_TOKEN_SET: ${{ secrets.HOMEBREW_TAP_TOKEN != '' }} steps: - name: Verify Homebrew tap token run: | if [ "${HOMEBREW_TAP_TOKEN_SET}" != "true" ]; then echo "::error::HOMEBREW_TAP_TOKEN repo secret is required to update KofTwentyTwo/homebrew-tap." exit 1 fi - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Checkout Homebrew tap uses: actions/checkout@v4 with: repository: KofTwentyTwo/homebrew-tap token: ${{ secrets.HOMEBREW_TAP_TOKEN }} path: homebrew-tap - name: Update formula env: TAG_NAME: ${{ github.ref_name }} run: | VERSION="${TAG_NAME#v}" SHA_MACOS_ARM64=$(shasum -a 256 artifacts/limen-macos-arm64/limen-macos-arm64 | cut -d' ' -f1) SHA_MACOS_AMD64=$(shasum -a 256 artifacts/limen-macos-amd64/limen-macos-amd64 | cut -d' ' -f1) SHA_LINUX_ARM64=$(shasum -a 256 artifacts/limen-linux-arm64/limen-linux-arm64 | cut -d' ' -f1) SHA_LINUX_AMD64=$(shasum -a 256 artifacts/limen-linux-amd64/limen-linux-amd64 | cut -d' ' -f1) FORMULA="homebrew-tap/Formula/limen.rb" mkdir -p "$(dirname "$FORMULA")" cat > "$FORMULA" < "limen" end test do assert_match version.to_s, shell_output("#{bin}/limen --version") end end RUBY - name: Commit and push run: | cd homebrew-tap git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add Formula/limen.rb if git status -s | grep -q "Formula/limen.rb"; then git commit -m "Update limen to ${GITHUB_REF_NAME}" git push else echo "Formula already current." fi