name: release # After CI succeeds on main, create at most one tag for the unreleased # conventional commits. The tag is then built by the shared GoReleaser # workflow at its exact commit. on: workflow_run: workflows: [ci] types: [completed] branches: [main] permissions: contents: write concurrency: group: release cancel-in-progress: false jobs: tag: if: >- github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' && !contains(github.event.workflow_run.head_commit.message, '[release=skip]') runs-on: ubuntu-latest outputs: tag: ${{ steps.version.outputs.tag }} steps: - name: Check out the verified commit uses: actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true ref: ${{ github.event.workflow_run.head_sha }} - name: Compute the next release tag id: version shell: bash run: | set -euo pipefail tag=$(bash .github/scripts/next-release-tag.sh) if [ -z "$tag" ]; then echo "No releasable conventional commits for this run." exit 0 fi echo "Releasing $tag from $(git rev-parse --short HEAD)" echo "tag=$tag" >> "$GITHUB_OUTPUT" - name: Create and push the tag if: steps.version.outputs.tag != '' env: TAG: ${{ steps.version.outputs.tag }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git tag -a "$TAG" -m "release $TAG" git push origin "$TAG" release: needs: tag if: needs.tag.outputs.tag != '' permissions: contents: write uses: bnema/gh-actions/.github/workflows/go-release.yml@main with: go-version: "1.26" # The reusable workflow fetches tags before this command, ensuring # GoReleaser produces artifacts and notes for the newly created tag. pre-command: git checkout --detach "${{ needs.tag.outputs.tag }}"