-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (43 loc) · 1.39 KB
/
auto-tag.yml
File metadata and controls
53 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI + Auto Tag
on:
push:
branches: [main]
jobs:
ci-and-tag:
name: Test, Build & Tag
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm install --include=dev
- name: Type check
run: npx tsc --noEmit
- name: Test
run: npm test
- name: Build
run: npm run build
- name: Tag HEAD with next patch version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Determine next version from latest git tag (fallback to package.json)
LATEST=$(git tag -l 'v*' --sort=-version:refname | head -1)
if [ -z "$LATEST" ]; then
LATEST="v$(node -p "require('./package.json').version")"
fi
CURRENT="${LATEST#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"
echo "Tagged HEAD as v$NEW_VERSION"