Skip to content

Commit 1219d1f

Browse files
committed
ci: tag HEAD directly instead of committing back to main
1 parent 19f085a commit 1219d1f

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,20 @@ jobs:
3434
- name: Build
3535
run: npm run build
3636

37-
- name: Bump patch version and tag
37+
- name: Tag HEAD with next patch version
3838
run: |
3939
git config user.name "github-actions[bot]"
4040
git config user.email "github-actions[bot]@users.noreply.github.com"
4141
42-
CURRENT=$(node -p "require('./package.json').version")
42+
# Determine next version from latest git tag (fallback to package.json)
43+
LATEST=$(git tag -l 'v*' --sort=-version:refname | head -1)
44+
if [ -z "$LATEST" ]; then
45+
LATEST="v$(node -p "require('./package.json').version")"
46+
fi
47+
CURRENT="${LATEST#v}"
4348
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
4449
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
4550
46-
node -e "
47-
const fs = require('fs');
48-
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
49-
pkg.version = '$NEW_VERSION';
50-
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
51-
"
52-
53-
git add package.json
54-
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
5551
git tag "v$NEW_VERSION"
56-
git push origin main
5752
git push origin "v$NEW_VERSION"
53+
echo "Tagged HEAD as v$NEW_VERSION"

0 commit comments

Comments
 (0)