1- name : Test and Release
1+ name : CI — test → gate → release
22
33on :
44 push :
55 branches :
6- - main
7- - " release/**"
8- - " prerelease/**"
6+ - ' **'
7+ tags :
8+ - ' **'
9+ pull_request :
10+ types : [opened, synchronize, reopened, ready_for_review]
911
10- concurrency : ${{ github.workflow }}-${{ github.ref }}
12+ # Ensure only one workflow per ref is active at a time
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.ref }}
15+ cancel-in-progress : true
16+
17+ # Default, least-privilege token permissions; jobs elevate as needed
18+ permissions :
19+ contents : read
1120
1221jobs :
1322 test :
14- name : Test (Node ${{ matrix.node }})
23+ name : Test (Node ${{ matrix.node-version }})
1524 runs-on : ubuntu-latest
1625 strategy :
1726 fail-fast : false
1827 matrix :
19- node : [22.x, 24.x]
28+ node-version : [22.x, 24.x]
2029 steps :
21- - uses : actions/checkout@v4
30+ - name : Checkout Repo
31+ uses : actions/checkout@v4
2232 with :
2333 fetch-depth : 0
24- - uses : actions/setup-node@v4
25- with :
26- node-version : ${{ matrix.node }}
27- cache : pnpm
28- - uses : pnpm/action-setup@v4
34+ # Install pnpm before any pnpm command; mirrors appsyncjs
35+ - name : Install pnpm
36+ uses : pnpm/action-setup@v4
2937 with :
30- # Use the pnpm version pinned in package.json `packageManager` to avoid conflicts
38+ version : latest
3139 run_install : false
32- - run : pnpm install --frozen-lockfile
33- - run : pnpm -w run fmt:check
34- - run : pnpm -w run typecheck:tsgo
40+ - name : Setup Node.js ${{ matrix.node-version }}
41+ uses : actions/setup-node@v4
42+ with :
43+ node-version : ${{ matrix.node-version }}
44+ cache : pnpm
45+ cache-dependency-path : pnpm-lock.yaml
46+ - name : Install dependencies
47+ run : pnpm install --frozen-lockfile
48+ - name : Format check
49+ run : pnpm -w run fmt:check
50+ - name : Typecheck (tsgo)
51+ run : pnpm -w run typecheck:tsgo
3552
3653 determine_release :
54+ name : Determine release
55+ needs : [test]
3756 runs-on : ubuntu-latest
3857 outputs :
3958 is_prerelease : ${{ steps.determine.outputs.is_prerelease }}
4059 is_release : ${{ steps.determine.outputs.is_release }}
4160 steps :
42- - uses : actions/checkout@v4
61+ - name : Checkout Repo
62+ uses : actions/checkout@v4
4363 with :
4464 fetch-depth : 0
45- - uses : actions/setup-node@v4
65+ - name : Install pnpm
66+ uses : pnpm/action-setup@v4
67+ with :
68+ version : latest
69+ run_install : false
70+ - name : Setup Node.js 24
71+ uses : actions/setup-node@v4
4672 with :
4773 node-version : 24.x
4874 cache : pnpm
49- - uses : pnpm/action-setup@v4
50- with :
51- run_install : false
52- - run : pnpm install --frozen-lockfile
53- - id : determine
75+ cache-dependency-path : pnpm-lock.yaml
76+ - name : Install dependencies
77+ run : pnpm install --frozen-lockfile
78+ - name : Compute release flags
79+ id : determine
5480 run : |
5581 pnpm changeset status --output=changeset-status.json
5682 PRE=$(jq -r '.preState.mode // ""' changeset-status.json)
@@ -59,28 +85,43 @@ jobs:
5985 echo "is_release=$([[ $GITHUB_REF_NAME = 'main' ]] && echo true || echo false)" >> $GITHUB_OUTPUT
6086
6187 release :
88+ name : Release
6289 needs : [test, determine_release]
6390 if : needs.determine_release.outputs.is_release == 'true' || needs.determine_release.outputs.is_prerelease == 'true'
6491 permissions :
6592 contents : write
6693 runs-on : ubuntu-latest
6794 steps :
68- - uses : actions/checkout@v4
95+ - name : Checkout Repo
96+ uses : actions/checkout@v4
6997 with :
7098 fetch-depth : 0
71- -
run :
git config user.name "GitHubActions" && git config user.email "[email protected] " 72- - uses : actions/setup-node@v4
99+ - name : Configure Git author (for tag/commit)
100+ run : |
101+ git config user.name "GitHubActions"
102+ git config user.email "[email protected] " 103+ - name : Install pnpm
104+ uses : pnpm/action-setup@v4
105+ with :
106+ version : latest
107+ run_install : false
108+ - name : Setup Node.js 24 (with npm registry)
109+ uses : actions/setup-node@v4
73110 with :
74111 node-version : 24.x
75112 cache : pnpm
113+ cache-dependency-path : pnpm-lock.yaml
76114 registry-url : https://registry.npmjs.org
77- - uses : pnpm/action-setup@v4
78- with :
79- run_install : false
80- - run : pnpm install --frozen-lockfile
81- - run : pnpm build
115+ env :
116+ # Ensure the registry is authenticated for publish
117+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
118+ - name : Install dependencies
119+ run : pnpm install --frozen-lockfile
120+ - name : Build
121+ run : pnpm build
82122 - name : Publish with Changesets
83123 env :
124+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
84125 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
85126 run : |
86127 pnpm changeset status
0 commit comments