Skip to content

ci: make tag workflow robust for non-release commits #2

ci: make tag workflow robust for non-release commits

ci: make tag workflow robust for non-release commits #2

Workflow file for this run

name: Tag Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create and push tag for release commits
run: |
MESSAGE="${{ github.event.head_commit.message }}"
if [[ "$MESSAGE" != chore\(release\):\ v* ]]; then
echo "Not a release commit; skipping"
exit 0
fi
VERSION="v$(node -p \"require('./package.json').version\")"
if git ls-remote --tags origin | grep -q "refs/tags/${VERSION}$"; then
echo "Tag ${VERSION} already exists; skipping"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${VERSION}" -m "Release ${VERSION}"
git push origin "${VERSION}"