Skip to content

chore: bump version 0.8.1a0 #12

chore: bump version 0.8.1a0

chore: bump version 0.8.1a0 #12

Workflow file for this run

name: Publish Release from Tag and CHANGELOG
on:
push:
tags:
- "v*"
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
- name: Validate CHANGELOG format
run: |
if [[ ! -f "CHANGELOG.md" ]]; then
echo "::error::CHANGELOG.md not found"
exit 1
fi
if ! grep -q "^## \[" CHANGELOG.md && ! grep -q "^## v" CHANGELOG.md; then
echo "::error::CHANGELOG.md does not contain valid version headers"
echo "::error::Expected format: '## [X.Y.Z]' or '## vX.Y.Z'"
exit 1
fi
- name: Extract latest version and notes
id: changelog
run: ./scripts/extract_changelog.sh
- name: Validate semantic version
if: steps.changelog.outputs.is_unreleased != 'true'
run: |
VERSION="${{ steps.changelog.outputs.version }}"
VERSION=${VERSION#v}
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Version '$VERSION' does not follow semantic versioning"
echo "::error::Expected format: MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]"
exit 1
fi
echo "::notice::Version $VERSION is valid semantic version"
- name: Validate tag matches changelog version
if: steps.changelog.outputs.is_unreleased != 'true'
run: |
TAG_NAME="${GITHUB_REF_NAME}"
TAG_VERSION="${TAG_NAME#v}"
CHANGELOG_VERSION="${{ steps.changelog.outputs.version }}"
CHANGELOG_VERSION="${CHANGELOG_VERSION#v}"
if [[ "$TAG_VERSION" != "$CHANGELOG_VERSION" ]]; then
echo "::error::Tag '$TAG_NAME' does not match CHANGELOG version '$CHANGELOG_VERSION'"
echo "::error::Update CHANGELOG.md or push the matching release tag"
exit 1
fi
echo "::notice::Tag '$TAG_NAME' matches CHANGELOG version '$CHANGELOG_VERSION'"
- name: Check for existing release
if: steps.changelog.outputs.is_unreleased != 'true'
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME="${GITHUB_REF_NAME}"
if gh release view "$TAG_NAME" &>/dev/null; then
echo "::notice::Release already exists: $TAG_NAME"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::No existing release found for: $TAG_NAME"
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
if: steps.changelog.outputs.is_unreleased != 'true' && steps.check_release.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.changelog.outputs.notes }}
run: |
TAG_NAME="${GITHUB_REF_NAME}"
VERSION="${TAG_NAME#v}"
NOTES_FILE="$(mktemp)"
printf '%s\n' "$RELEASE_NOTES" > "$NOTES_FILE"
PRERELEASE_FLAG=""
if [[ "$VERSION" == *-* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create "$TAG_NAME" \
--title "Release $TAG_NAME" \
--notes-file "$NOTES_FILE" \
--verify-tag \
$PRERELEASE_FLAG
rm -f "$NOTES_FILE"
- name: Verify Release Created
if: steps.changelog.outputs.is_unreleased != 'true' && steps.check_release.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME="${GITHUB_REF_NAME}"
if gh release view "$TAG_NAME" &>/dev/null; then
RELEASE_URL=$(gh release view "$TAG_NAME" --json url --jq '.url')
echo "::notice::Release successfully created: $RELEASE_URL"
else
echo "::error::Release verification failed for $TAG_NAME"
exit 1
fi
- name: Notify on Failure
if: failure()
run: |
echo "::error::Release workflow failed"
echo "::error::Please check CHANGELOG.md format and workflow logs"