Release #35
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 override (e.g. v1.2.3). Leave empty to auto-detect via git-cliff." | |
| required: false | |
| default: "" | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Ensure tags are available | |
| run: git fetch --force --tags | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Run tests | |
| run: go test ./... | |
| - name: Determine version via git-cliff | |
| id: cliff | |
| uses: orhun/git-cliff-action@v4 | |
| with: | |
| config: cliff.toml | |
| args: --bumped-version | |
| - name: Resolve release version | |
| id: version | |
| env: | |
| CLIFF_OUTPUT: ${{ steps.cliff.outputs.content }} | |
| INPUT_VERSION: ${{ inputs.version }} | |
| run: | | |
| DETECTED_VERSION="$(echo "$CLIFF_OUTPUT" | tr -d '[:space:]')" | |
| VERSION="$INPUT_VERSION" | |
| if [ -z "$VERSION" ]; then | |
| VERSION="$DETECTED_VERSION" | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: could not determine version. Use the version override input." >&2 | |
| exit 1 | |
| fi | |
| if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: resolved version '$VERSION' is not semver (vX.Y.Z)." >&2 | |
| exit 1 | |
| fi | |
| if git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then | |
| echo "Error: tag '$VERSION' already exists. Set workflow input 'version' to a new value." >&2 | |
| exit 1 | |
| fi | |
| echo "Releasing $VERSION" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Generate changelog | |
| uses: orhun/git-cliff-action@v4 | |
| with: | |
| config: cliff.toml | |
| args: --tag ${{ steps.version.outputs.version }} -o CHANGELOG.md | |
| - name: Re-render integrations with release version | |
| env: | |
| TAPPER_PLUGIN_VERSION: ${{ steps.version.outputs.version }} | |
| run: go run ./cmd/render-integrations | |
| - name: Commit and push release atomically | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| git add CHANGELOG.md integrations/rendered | |
| if git diff --staged --quiet; then | |
| echo "Error: no release artifacts staged. Expected CHANGELOG and rendered integrations to change." >&2 | |
| exit 1 | |
| fi | |
| git commit -m "chore: release $VERSION" | |
| git tag -a "$VERSION" -m "$VERSION" | |
| git push origin main "refs/tags/$VERSION" | |
| - name: Ensure clean tree for goreleaser | |
| run: | | |
| git clean -ffdx | |
| test -z "$(git status --porcelain)" || { git status --porcelain; exit 1; } | |
| - name: Run goreleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| distribution: goreleaser | |
| version: "~> v2" | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} |