chore: release 0.1.5 (#62) #20
This file contains 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: Tag Release | |
on: | |
push: | |
branches: | |
- main # Trigger only when PRs are merged into main | |
permissions: | |
contents: write # ✅ Required to push tags | |
jobs: | |
tag-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # ✅ Fetch all commits and tags | |
token: ${{ secrets.GHA_PAT_TAGS }} | |
- name: Push Tag for Release | |
id: push_tag | |
run: | | |
# Get the latest commit message that matches the pattern "chore: release vX.Y.Z" | |
COMMIT_MSG=$(git log --grep="^chore: release [0-9]\+\.[0-9]\+\.[0-9]\+" -n 1 --format="%s") | |
# Match "chore: release vX.Y.Z" | |
if [[ "$COMMIT_MSG" =~ ^chore:\ release\ ([0-9]+\.[0-9]+\.[0-9]+)(\ \(.+\))?$ ]]; then | |
VERSION="v${BASH_REMATCH[1]}" | |
echo "Found release commit for version $VERSION" | |
TAG_EXISTS=$(git tag -l "${VERSION}") | |
if [ -n "$TAG_EXISTS" ]; then | |
echo "Tag $VERSION already exists. Skipping." | |
exit 0 | |
else | |
echo "Pushing tag $VERSION" | |
# Create and push the tag (auth is already configured) | |
git tag "$VERSION" | |
git push origin "$VERSION" | |
fi | |
else | |
echo "Commit message '$COMMIT_MSG' does not match the pattern 'chore: release vX.Y.Z'. Skipping." | |
fi | |