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
48 changes: 48 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Auto-tag on version bump

on:
push:
branches: [main]
paths:
- "package.json"

permissions:
contents: write

jobs:
tag:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Check if version changed
id: version
run: |
current=$(python3 -c 'import json;print(json.load(open("package.json"))["version"])')
previous=$(git show HEAD~1:package.json 2>/dev/null | python3 -c 'import json,sys;print(json.load(sys.stdin)["version"])' 2>/dev/null || echo "")

echo "current=$current" >> "$GITHUB_OUTPUT"
echo "previous=$previous" >> "$GITHUB_OUTPUT"

if [ "$current" != "$previous" ] && [ -n "$current" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Create and push tag
if: steps.version.outputs.changed == 'true'
env:
VERSION: ${{ steps.version.outputs.current }}
run: |
tag="v${VERSION}"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "Tag $tag already exists, skipping"
exit 0
fi
git tag "$tag"
git push origin "$tag"
echo "Created and pushed tag $tag"
Loading