Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Auto Tag Release

on:
push:
branches:
- main
paths:
- 'package.json'
workflow_dispatch:

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT

- name: Check if tag already exists
id: tag_check
run: |
TAG="v${{ steps.version.outputs.VERSION }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists"
echo "EXISTS=true" >> $GITHUB_OUTPUT
else
echo "Tag $TAG does not exist"
echo "EXISTS=false" >> $GITHUB_OUTPUT
fi

- name: Create and push tag
if: steps.tag_check.outputs.EXISTS == 'false'
run: |
TAG="${{ steps.version.outputs.TAG }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
echo "✓ Created and pushed tag: $TAG"

- name: Tag already exists, skipping
if: steps.tag_check.outputs.EXISTS == 'true'
run: |
echo "Tag v${{ steps.version.outputs.VERSION }} already exists. Skipping tag creation."