Release #65
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: Release | |
| on: | |
| # Trigger when tagpr workflow completes successfully | |
| workflow_run: | |
| workflows: | |
| - tagpr | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| # Manual trigger for existing tags or re-runs | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to release (e.g., v1.0.0)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| goreleaser: | |
| runs-on: ubuntu-latest | |
| # Only run if: | |
| # 1. Triggered by successful tagpr workflow run, OR | |
| # 2. Manually dispatched | |
| if: | | |
| (github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push') || | |
| github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| # Fetch complete history and all tags | |
| fetch-depth: 0 | |
| # For workflow_run, checkout the commit that triggered tagpr | |
| ref: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| - name: Get tag name | |
| id: get-tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| # Manual trigger | |
| if [ -n "${{ inputs.tag }}" ]; then | |
| # Use specified tag | |
| TAG="${{ inputs.tag }}" | |
| else | |
| # No tag specified - use the latest tag | |
| TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1) | |
| if [ -z "$TAG" ]; then | |
| echo "Error: No tag specified and no tags found in repository" | |
| exit 1 | |
| fi | |
| echo "No tag specified, using latest tag: $TAG" | |
| fi | |
| else | |
| # Auto trigger from workflow_run | |
| # Find tag pointing to the HEAD commit (the commit that tagpr just tagged) | |
| TAG=$(git tag --points-at HEAD | grep '^v' | sort -V | tail -n1) | |
| if [ -z "$TAG" ]; then | |
| echo "No tag found on commit ${{ github.event.workflow_run.head_sha }}" | |
| echo "Skipping release - tagpr did not create a tag (this was a regular PR merge)" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| echo "Release tag: $TAG" | |
| # Verify tag exists | |
| if ! git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Error: Tag $TAG does not exist" | |
| exit 1 | |
| fi | |
| - name: Checkout tag | |
| if: steps.get-tag.outputs.skip != 'true' | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ steps.get-tag.outputs.tag }} | |
| # Fetch complete history (required for CHANGELOG generation) | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| if: steps.get-tag.outputs.skip != 'true' | |
| uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run GoReleaser | |
| if: steps.get-tag.outputs.skip != 'true' | |
| uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |