-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (69 loc) · 2.38 KB
/
release.yml
File metadata and controls
78 lines (69 loc) · 2.38 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump level"
required: false
default: "patch"
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT }}
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Bump version
id: version
run: |
BUMP="${{ inputs.bump || 'patch' }}"
OLD=$(node -p 'require("./package.json").version')
IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD"
case "$BUMP" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW="${MAJOR}.${MINOR}.${PATCH}"
npm version "$NEW" --no-git-tag-version
echo "version=$NEW" >> "$GITHUB_OUTPUT"
echo "old=$OLD" >> "$GITHUB_OUTPUT"
echo "Bumped $OLD → $NEW ($BUMP)"
- run: npm ci
- run: npm run typecheck
- run: npm test
- run: npm run build
# Clear the token placeholder so npm falls through to OIDC auth.
- name: Publish to npm
run: |
npm config delete //registry.npmjs.org/:_authToken || true
npm publish --access public
# PAT checkout token bypasses branch protection (owner is repo admin).
- name: Commit version bump, tag, and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
git commit -m "release: v${{ steps.version.outputs.version }}"
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
git push origin HEAD:main
git push origin "v${{ steps.version.outputs.version }}"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.version.outputs.version }}" \
--title "v${{ steps.version.outputs.version }}" \
--generate-notes