Skip to content

Commit e4d80ca

Browse files
authored
Prepare 0.2.4 with a validated release archive (#6)
* chore: prepare validated 0.2.4 release artifacts * ci: keep archive dry run on the publishing runtime * docs: shorten adoption and release guidance
1 parent 65d4abd commit e4d80ca

14 files changed

Lines changed: 339 additions & 35 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,39 @@ jobs:
193193
if: github.event_name == 'pull_request'
194194
steps:
195195
- name: Checkout
196-
uses: actions/checkout@v4
196+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
197197

198198
- name: Setup pnpm
199-
uses: pnpm/action-setup@v4
199+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
200200

201201
- name: Setup Node.js
202-
uses: actions/setup-node@v4
202+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
203203
with:
204204
node-version: 22
205205
cache: pnpm
206206
registry-url: "https://registry.npmjs.org"
207207

208208
- name: Install dependencies
209-
run: pnpm install
209+
run: pnpm install --frozen-lockfile
210210

211-
- name: Build
212-
run: pnpm run build
211+
- name: Validate exact package archive
212+
run: pnpm run release:pack
213+
214+
- name: Setup minimum consumer Node
215+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
216+
with:
217+
node-version: 20.0.0
218+
219+
- name: Verify installed archive on the minimum consumer runtime
220+
run: node .release/consumer/check.mjs
213221

214-
- name: Publish dry run
215-
run: pnpm publish --dry-run --no-git-checks
222+
- name: Restore publishing Node
223+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
224+
with:
225+
node-version: 22
226+
registry-url: "https://registry.npmjs.org"
227+
228+
- name: Publish dry run of the validated archive
229+
run: |
230+
sha256sum --check .release/package.sha256
231+
pnpm publish .release/package.tgz --dry-run --ignore-scripts --no-git-checks

‎.github/workflows/release.yml‎

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,77 @@ on:
66
- "v*"
77

88
permissions:
9-
contents: write # Need write access to create releases
10-
id-token: write
9+
contents: read
1110

1211
jobs:
1312
publish:
1413
name: Publish to NPM
1514
runs-on: ubuntu-latest
15+
timeout-minutes: 20
16+
permissions:
17+
contents: read
18+
id-token: write
1619
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
20+
- name: Checkout tagged candidate
21+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
22+
with:
23+
ref: ${{ github.sha }}
1924

2025
- name: Setup pnpm
21-
uses: pnpm/action-setup@v4
26+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2227

2328
- name: Setup Node.js
24-
uses: actions/setup-node@v4
29+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
2530
with:
2631
node-version: 22
2732
cache: pnpm
2833
registry-url: "https://registry.npmjs.org"
2934

3035
- name: Install dependencies
31-
run: pnpm install
36+
run: pnpm install --frozen-lockfile
3237

33-
- name: Run checks
34-
run: |
35-
pnpm run check
36-
pnpm run type-check
38+
- name: Validate tag, checks and exact package archive
39+
run: pnpm run release:prepare
40+
env:
41+
RELEASE_TAG: ${{ github.ref_name }}
3742

38-
- name: Build
39-
run: pnpm run build
43+
- name: Setup minimum consumer Node
44+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
45+
with:
46+
node-version: 20.0.0
47+
48+
- name: Verify installed archive on the minimum consumer runtime
49+
run: node .release/consumer/check.mjs
4050

41-
- name: Publish
42-
run: pnpm publish --no-git-checks
51+
- name: Restore publishing Node
52+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
53+
with:
54+
node-version: 22
55+
registry-url: "https://registry.npmjs.org"
56+
57+
# release:prepare already ran tests/build and validated this archive.
58+
# Suppress lifecycle rebuilds so publication uses the same bytes.
59+
- name: Publish validated archive
60+
run: |
61+
sha256sum --check .release/package.sha256
62+
pnpm publish .release/package.tgz --ignore-scripts --no-git-checks
4363
env:
4464
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4565

4666
create-release:
4767
name: Create GitHub Release
4868
runs-on: ubuntu-latest
49-
needs: publish # Wait for npm publish to succeed
69+
needs: publish
70+
permissions:
71+
contents: write
5072
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v4
73+
- name: Checkout tagged candidate
74+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
75+
with:
76+
ref: ${{ github.sha }}
5377

5478
- name: Create Release
55-
uses: softprops/action-gh-release@v2
79+
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
5680
with:
5781
tag_name: ${{ github.ref_name }}
5882
name: Release ${{ github.ref_name }}

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ coverage/
4444

4545
# TypeScript cache
4646
*.tsbuildinfo
47+
48+
# Locally prepared release archive and isolated consumer
49+
.release/

‎AGENTS.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# github-typescript-utils
2+
3+
ESM utilities for GitHub Actions, supporting Node >=20. Development uses current
4+
Node 22 from `.nvmrc` and pnpm 10.13.1 from `packageManager`. Preserve helper
5+
signatures, marker matching, branch behavior and peer compatibility.
6+
7+
## Checks
8+
9+
- `pnpm install --frozen-lockfile`
10+
- `pnpm run check` and `pnpm run type-check`
11+
- `pnpm run test:run`
12+
- `pnpm run clean && pnpm run build`
13+
- `RELEASE_TAG=v0.2.4 pnpm run release:prepare` validates without publishing.
14+
Use `pnpm run release:pack` for archive checks without a tag.
15+
16+
Never hand-edit `dist/` or `.release/`. Preserve the existing package payload.
17+
Follow the [README release procedure](README.md#release-preparation); publish the
18+
validated tarball without rebuilding. Release helpers require current Node 22;
19+
only the consumer smoke runs on Node 20. Tags, publication and credential changes
20+
need explicit approval. Verify registry access before tagging; retain `NPM_TOKEN`
21+
until a replacement is verified.

‎README.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,34 @@ export default async function run({ core, github, context }) {
670670
5. Test your changes
671671
6. Submit a pull request
672672

673+
## Release preparation
674+
675+
Use current Node 22 from `.nvmrc` and pnpm 10.13.1. Consumers support Node >=20;
676+
release helpers require current Node 22.
677+
678+
```bash
679+
pnpm install --frozen-lockfile
680+
RELEASE_TAG=v0.2.4 pnpm run release:prepare
681+
```
682+
683+
This validates the version, runs checks/tests and validates the built archive's
684+
installed imports and declarations. It does not publish. Use
685+
`pnpm run release:pack` for archive checks without a tag.
686+
687+
Before a separately approved release:
688+
689+
1. Verify registry access for `NPM_TOKEN` and workflow permissions. Do not tag
690+
until access is confirmed. `id-token: write` alone does not configure npm trust.
691+
2. Push an exact stable `vX.Y.Z` tag at the approved merged `main` commit,
692+
matching `package.json`. Partial and prerelease tags are rejected.
693+
3. Check the release job. It validates the candidate and Node 20 consumer, verifies
694+
the archive checksum, then publishes that exact tarball without rebuilding.
695+
GitHub release creation follows successful npm publication.
696+
697+
Use the release job's archive checksum when verifying publication; local and
698+
hosted archives can differ. Preparation and merging do not authorize publication,
699+
tag changes or credential changes. Keep `NPM_TOKEN` until a replacement is verified.
700+
673701
## License
674702

675703
MIT - see [LICENSE](LICENSE) file for details.

‎biome.json‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@
1515
"selector": {
1616
"kind": "objectLiteralProperty"
1717
},
18-
"formats": ["camelCase", "snake_case", "CONSTANT_CASE"]
18+
"formats": [
19+
"camelCase",
20+
"snake_case",
21+
"CONSTANT_CASE"
22+
]
1923
},
2024
{
2125
"selector": {
2226
"kind": "typeProperty"
2327
},
24-
"formats": ["camelCase", "snake_case", "CONSTANT_CASE"]
28+
"formats": [
29+
"camelCase",
30+
"snake_case",
31+
"CONSTANT_CASE"
32+
]
2533
}
2634
]
2735
}
@@ -56,7 +64,15 @@
5664
},
5765
"files": {
5866
"ignoreUnknown": false,
59-
"includes": ["src/**/*.ts", "src/**/*.js", "*.json", "*.md"]
67+
"includes": [
68+
"src/**/*.ts",
69+
"src/**/*.js",
70+
"*.json",
71+
"*.md",
72+
"scripts/**/*.ts",
73+
"scripts/**/*.mjs",
74+
"scripts/**/*.json"
75+
]
6076
},
6177
"assist": {
6278
"actions": {

‎package.json‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-typescript-utils",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "TypeScript utilities for GitHub Actions workflows - REST API, Octokit, context helpers, and common workflow functions",
55
"type": "module",
66
"main": "./dist/index.js",
@@ -52,10 +52,13 @@
5252
"lint:fix": "biome lint --write src/",
5353
"format": "biome format src/",
5454
"format:fix": "biome format --write src/",
55-
"check": "biome check src/",
56-
"check:fix": "biome check --write src/",
57-
"type-check": "tsc --noEmit",
58-
"prepublishOnly": "pnpm run clean && pnpm run test:run && pnpm run build"
55+
"check": "biome check src/ scripts/",
56+
"check:fix": "biome check --write src/ scripts/",
57+
"type-check": "tsc --noEmit && tsc -p scripts/tsconfig.json",
58+
"prepublishOnly": "pnpm run clean && pnpm run test:run && pnpm run build",
59+
"release:check": "node scripts/release/validate-tag.ts",
60+
"release:pack": "pnpm run clean && pnpm run build && node scripts/release/verify-package.ts",
61+
"release:prepare": "pnpm run release:check && pnpm run check && pnpm run type-check && pnpm run test:run && pnpm run release:pack"
5962
},
6063
"peerDependencies": {
6164
"@actions/core": "^1.10.0",

‎scripts/release/consumer/check.mjs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import assert from 'node:assert/strict';
2+
import { findCommentByIdentifier, sanitizeInput } from 'github-typescript-utils';
3+
4+
assert.equal(sanitizeInput('"release"'), 'release');
5+
const pages = [];
6+
const firstPage = Array.from({ length: 100 }, (_, index) => ({
7+
id: index + 1,
8+
body: 'Ordinary comment',
9+
}));
10+
const ctx = {
11+
github: {
12+
rest: {
13+
issues: {
14+
async listComments({ page, per_page }) {
15+
assert.equal(per_page, 100);
16+
pages.push(page);
17+
return {
18+
data:
19+
page === 1 ? firstPage : [{ id: 501, body: '<!-- sticky-comment-id: release -->' }],
20+
};
21+
},
22+
},
23+
},
24+
},
25+
};
26+
assert.deepEqual(
27+
await findCommentByIdentifier({
28+
ctx,
29+
repo: { owner: 'owner', repo: 'repo' },
30+
issueNumber: 7,
31+
identifier: 'release',
32+
}),
33+
{ id: 501, body: '<!-- sticky-comment-id: release -->' }
34+
);
35+
assert.deepEqual(pages, [1, 2]);
36+
console.log(`Packed public-root import and behavior passed on ${process.version}`);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
findCommentByIdentifier,
3+
type GitHubContext,
4+
type IssueComment,
5+
sanitizeInput,
6+
} from 'github-typescript-utils';
7+
8+
const normalized: string = sanitizeInput('"release"');
9+
const lookup: (args: {
10+
ctx: GitHubContext;
11+
repo: { owner: string; repo: string };
12+
issueNumber: number;
13+
identifier: string;
14+
}) => Promise<IssueComment | null> = findCommentByIdentifier;
15+
void normalized;
16+
void lookup;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"strict": true,
7+
"noEmit": true
8+
},
9+
"include": ["consumer.ts"]
10+
}

0 commit comments

Comments
 (0)