2.2.41 #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Release Binaries | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to release (e.g., v2.0.0)" | |
| required: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| goreleaser: | |
| name: Build Cross-Platform Binaries | |
| if: startsWith(github.event.release.tag_name, '3.') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Determine tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT | |
| elif [ -n "${{ inputs.tag }}" ]; then | |
| echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check if binaries already exist | |
| id: check_assets | |
| run: | | |
| ASSET_COUNT=$(gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| /repos/${{ github.repository }}/releases/tags/${{ steps.tag.outputs.tag }} \ | |
| --jq '.assets | length' 2>/dev/null || echo "0") | |
| echo "asset_count=$ASSET_COUNT" >> $GITHUB_OUTPUT | |
| if [ "$ASSET_COUNT" -gt 0 ]; then | |
| echo "::notice::Release already has $ASSET_COUNT asset(s). Skipping build." | |
| echo "skip_build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "::notice::No assets found. Proceeding with build." | |
| echo "skip_build=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Checkout | |
| if: steps.check_assets.outputs.skip_build == 'false' | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ steps.tag.outputs.tag }} | |
| - name: Set up Go | |
| if: steps.check_assets.outputs.skip_build == 'false' | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| - name: Run GoReleaser | |
| if: steps.check_assets.outputs.skip_build == 'false' | |
| uses: goreleaser/goreleaser-action@v7 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean --skip=validate | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GORELEASER_CURRENT_TAG: ${{ steps.tag.outputs.tag }} | |
| - name: Upload release artifacts | |
| if: steps.check_assets.outputs.skip_build == 'false' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-artifacts | |
| path: dist/* | |
| retention-days: 7 |