Release #6
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to release, e.g.: v0.1.0" | |
| required: true | |
| type: string | |
| concurrency: | |
| group: release-${{ github.event.inputs.version }} | |
| cancel-in-progress: false | |
| jobs: | |
| validate-version: | |
| name: Validate semantic version | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| sparse-checkout: .github/actions/validate-semver | |
| - name: Validate semantic version | |
| uses: ./.github/actions/validate-semver | |
| with: | |
| version: ${{ github.event.inputs.version }} | |
| tests: | |
| uses: ./.github/workflows/tests.yml | |
| release: | |
| name: Release | |
| needs: [validate-version, tests] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | |
| with: | |
| go-version-file: ./go.mod | |
| - name: Set git identity | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Create local tag | |
| run: | | |
| V="${{ github.event.inputs.version }}" | |
| # Re-tag if already exists locally (idempotent CI reruns). | |
| if git rev-parse -q --verify "refs/tags/$V" >/dev/null; then | |
| git tag -d "$V" | |
| fi | |
| git tag -a "$V" -m "$V" | |
| - name: Build artifacts only | |
| uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | |
| with: | |
| version: "~> v2" | |
| args: release --skip=publish --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push tag | |
| run: | | |
| V="${{ github.event.inputs.version }}" | |
| # If the remote already has it (rare), fail early to avoid double-publish. | |
| if git ls-remote --tags origin | grep -qx ".*refs/tags/$V"; then | |
| echo "Tag $V already exists on origin. Aborting." >&2 | |
| exit 1 | |
| fi | |
| git push origin "$V" | |
| - name: Publish release | |
| uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | |
| with: | |
| version: "~> v2" | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |