Skip to content

Commit f785d22

Browse files
charliecreates[bot]CharlieHelpsmikecbrant
authored
ci(gha): install pnpm before use; align release to appsyncjs (Node 22/24, NPM_TOKEN) (#7)
* ci(gha): install pnpm before use; align release flow to appsyncjs (Node 22/24, registry auth, caching) * ci(gha): use pnpm/action-setup with package_json_file to honor pinned pnpm version * ci(gha): push-only release gating, npm auth hardening, strict tag push; pin pnpm via packageManager and fix Prettier config resolution * ci(gha): make determine_release tolerant of PR merge refs (fallback when changeset status cannot diff from main) * Update .github/workflows/release.yml --------- Co-authored-by: CharlieCreates <198680274+charliecreates[bot]@users.noreply.github.com> Co-authored-by: CharlieHelps <[email protected]> Co-authored-by: Mike Brant <[email protected]>
1 parent ca97714 commit f785d22

File tree

3 files changed

+84
-35
lines changed

3 files changed

+84
-35
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,131 @@
1-
name: Test and Release
1+
name: CI — test → gate → release
22

33
on:
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

1221
jobs:
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+
- name: Install pnpm
35+
uses: pnpm/action-setup@v4
2936
with:
30-
# Use the pnpm version pinned in package.json `packageManager` to avoid conflicts
37+
package_json_file: package.json
3138
run_install: false
32-
- run: pnpm install --frozen-lockfile
33-
- run: pnpm -w run fmt:check
34-
- run: pnpm -w run typecheck:tsgo
39+
- name: Setup Node.js ${{ matrix.node-version }}
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: ${{ matrix.node-version }}
43+
cache: pnpm
44+
cache-dependency-path: pnpm-lock.yaml
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
- name: Format check
48+
run: pnpm -w run fmt:check
49+
- name: Typecheck (tsgo)
50+
run: pnpm -w run typecheck:tsgo
3551

3652
determine_release:
53+
name: Determine release
54+
needs: [test]
3755
runs-on: ubuntu-latest
3856
outputs:
3957
is_prerelease: ${{ steps.determine.outputs.is_prerelease }}
4058
is_release: ${{ steps.determine.outputs.is_release }}
4159
steps:
42-
- uses: actions/checkout@v4
60+
- name: Checkout Repo
61+
uses: actions/checkout@v4
4362
with:
4463
fetch-depth: 0
45-
- uses: actions/setup-node@v4
64+
- name: Install pnpm
65+
uses: pnpm/action-setup@v4
66+
with:
67+
package_json_file: package.json
68+
run_install: false
69+
- name: Setup Node.js 24
70+
uses: actions/setup-node@v4
4671
with:
4772
node-version: 24.x
4873
cache: pnpm
49-
- uses: pnpm/action-setup@v4
50-
with:
51-
run_install: false
52-
- run: pnpm install --frozen-lockfile
53-
- id: determine
74+
cache-dependency-path: pnpm-lock.yaml
75+
- name: Install dependencies
76+
run: pnpm install --frozen-lockfile
77+
- name: Compute release flags
78+
id: determine
5479
run: |
55-
pnpm changeset status --output=changeset-status.json
80+
# Changesets can error on PR merge refs; tolerate and default to no pre mode
81+
pnpm changeset status --output=changeset-status.json || echo '{}' > changeset-status.json
5682
PRE=$(jq -r '.preState.mode // ""' changeset-status.json)
5783
rm -f changeset-status.json
5884
echo "is_prerelease=$([[ $PRE = 'pre' ]] && echo true || echo false)" >> $GITHUB_OUTPUT
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]
63-
if: needs.determine_release.outputs.is_release == 'true' || needs.determine_release.outputs.is_prerelease == 'true'
90+
if: ${{ github.event_name == 'push' && (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+
package_json_file: package.json
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+
always-auth: true
116+
env:
117+
# Ensure the registry is authenticated for publish
118+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
119+
- name: Install dependencies
120+
run: pnpm install --frozen-lockfile
121+
- name: Build
122+
run: pnpm build
82123
- name: Publish with Changesets
83124
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84126
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
85127
run: |
86128
pnpm changeset status
87129
pnpm changeset version
88130
pnpm changeset publish
89-
git push --follow-tags --no-verify || true
131+
git push --follow-tags --no-verify

packages/eslint-config/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"eslint-plugin-sonarjs": "^3.0.2",
2020
"eslint-plugin-unused-imports": "^4.0.0"
2121
},
22+
"devDependencies": {
23+
"@mikecbrant/prettier-config": "workspace:*"
24+
},
2225
"publishConfig": {
2326
"access": "public"
2427
},

pnpm-lock.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)