Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 34 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ on:
push:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to release (e.g. v0.2.0)'
required: true
type: string

permissions:
contents: write

jobs:
tag:
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.tag.outputs.new_tag }}
Expand All @@ -19,37 +26,43 @@ jobs:
with:
fetch-depth: 0

- name: Determine next version
- name: Bump version and push tag
id: tag
run: |
# Get the latest tag, default to v0.0.0 if none exists
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $LATEST_TAG"

# Extract major.minor.patch
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Bump patch version
PATCH=$((PATCH + 1))
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
echo "New tag: $NEW_TAG"
echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT"

- name: Create and push tag
run: |
git tag ${{ steps.tag.outputs.new_tag }}
git push origin ${{ steps.tag.outputs.new_tag }}
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
release_branches: main
tag_prefix: v
# Pre-1.0 policy: breaking changes bump minor instead of major.
# Remove this line once the project reaches v1.0.0 so that `!:` /
# `BREAKING CHANGE:` commits correctly bump major.
custom_release_rules: breaking:minor,feat!:minor,feat:minor,fix:patch

release:
needs: tag
if: needs.tag.outputs.new_tag != ''
if: |
always() && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Resolve release ref
id: ref
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "ref=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "ref=${{ needs.tag.outputs.new_tag }}" >> "$GITHUB_OUTPUT"
fi

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.ref.outputs.ref }}

- name: Verify dispatched tag exists
if: github.event_name == 'workflow_dispatch'
run: git rev-parse "refs/tags/${{ inputs.tag }}"

- name: Set up Go
uses: actions/setup-go@v5
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ go test ./...
- Every feature must ship with tests covering it; no feature lands without test coverage.
- Add or update tests whenever behavior changes, and keep `go test ./...` green.
- Update `README.md` when user-facing behavior or flags change.
- avoid using unnesessary emojis.
- avoid using unnecessary emojis.

## Commit messages

Expand Down
Loading