Add release workflow

Add a workflow_dispatch workflow that bumps the version (patch/minor/major),
creates a GitHub release with auto-generated notes, and updates the major
version tag.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Devraj Mehta
2026-03-10 21:45:33 -04:00
parent 14747e0edd
commit d278e42d43

72
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: Version bump type
required: true
default: patch
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest-slim
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine new version
id: version
run: |
# Get the latest semver tag
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1)
if [ -z "$LATEST_TAG" ]; then
echo "No existing version tag found"
exit 1
fi
# Strip leading 'v' and split into components
VERSION="${LATEST_TAG#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
case "${{ inputs.bump }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
echo "previous=$LATEST_TAG" >> "$GITHUB_OUTPUT"
echo "new=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "major=v${MAJOR}" >> "$GITHUB_OUTPUT"
echo "Bumping $LATEST_TAG -> $NEW_VERSION"
- name: Create GitHub release
run: |
gh release create "${{ steps.version.outputs.new }}" \
--generate-notes \
--notes-start-tag "${{ steps.version.outputs.previous }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update major version tag
run: |
git tag -f "${{ steps.version.outputs.major }}" "${{ steps.version.outputs.new }}"
git push -f origin "${{ steps.version.outputs.major }}"