add automated release workflow

This commit is contained in:
bkellam 2025-12-18 14:32:21 -05:00
parent 9402f7e550
commit 00eb3e0199

86
.github/workflows/release-sourcebot.yml vendored Normal file
View file

@ -0,0 +1,86 @@
name: Release Sourcebot
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g., 4.10.5)"
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Validate version format
run: |
VERSION="${{ inputs.version }}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?(\+[a-zA-Z0-9._-]+)?$ ]]; then
echo "Error: Version must follow semantic versioning format (X.Y.Z)"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Check if version already exists
run: |
VERSION="${{ inputs.version }}"
if grep -q "## \[$VERSION\]" CHANGELOG.md; then
echo "Error: Version $VERSION already exists in CHANGELOG.md"
exit 1
fi
if git tag | grep -q "^v$VERSION$"; then
echo "Error: Tag v$VERSION already exists"
exit 1
fi
- name: Update CHANGELOG.md
run: |
VERSION="${{ inputs.version }}"
DATE=$(date +%Y-%m-%d)
# Insert the new version header after the [Unreleased] line
sed -i "/## \[Unreleased\]/a\\
\\
## [$VERSION] - $DATE" CHANGELOG.md
echo "Updated CHANGELOG.md with version $VERSION"
cat CHANGELOG.md | head -n 15
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit CHANGELOG
run: |
VERSION="${{ inputs.version }}"
git add CHANGELOG.md
git commit -m "Release v$VERSION"
- name: Create annotated tag
run: |
VERSION="${{ inputs.version }}"
git tag -a "v$VERSION" -m "sourcebot v$VERSION"
- name: Push changes
run: |
git push origin main
git push origin --tags
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ inputs.version }}"
gh release create "v$VERSION" \
--verify-tag \
--generate-notes \
--latest