Skip to content

Commit 7a85335

Browse files
committed
ci: add auto-tag workflow
1 parent c1a7171 commit 7a85335

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI + Auto Tag
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
ci-and-tag:
9+
name: Test, Build & Tag
10+
runs-on: ubuntu-latest
11+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm install --include=dev
27+
28+
- name: Type check
29+
run: npx tsc --noEmit
30+
31+
- name: Test
32+
run: npm test
33+
34+
- name: Build
35+
run: npm run build
36+
37+
- name: Bump patch version and tag
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
42+
CURRENT=$(node -p "require('./package.json').version")
43+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
44+
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
45+
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]"
55+
git tag "v$NEW_VERSION"
56+
git push origin main --follow-tags

0 commit comments

Comments
 (0)