Skip to content

Commit 4914fca

Browse files
committed
chore: add .nvmrc and auto-tag workflow on PR merge
- .nvmrc pins Node 20.12.0 for consistent contributor environment - release.yml: when a PR merges to main, auto-create v{version} tag which triggers the existing publish.yml → npm publish pipeline
1 parent 6a21e43 commit 4914fca

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Auto Tag on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
tag:
10+
if: github.event.pull_request.merged == true
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: 🛎️ Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: 📋 Read version from package.json
22+
id: version
23+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
24+
25+
- name: 🔍 Check if tag already exists
26+
id: tag_check
27+
run: |
28+
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
29+
echo "exists=true" >> $GITHUB_OUTPUT
30+
else
31+
echo "exists=false" >> $GITHUB_OUTPUT
32+
fi
33+
34+
- name: 🏷️ Create and push tag
35+
if: steps.tag_check.outputs.exists == 'false'
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "github-actions[bot]@users.noreply.github.com"
39+
git tag "v${{ steps.version.outputs.version }}"
40+
git push origin "v${{ steps.version.outputs.version }}"

0 commit comments

Comments
 (0)