Skip to content

Commit 8c93ded

Browse files
authored
feat: adopt trusted publishers (#378)
adopt https://docs.npmjs.com/trusted-publishers to publish releases using Github Actions / OIDC auth.
1 parent 2524aa0 commit 8c93ded

File tree

16 files changed

+1456
-2520
lines changed

16 files changed

+1456
-2520
lines changed

.github/workflows/publish-docs.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ permissions:
99
jobs:
1010
publish_docs:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
node-version: [24.x]
1512

1613
steps:
1714
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -21,12 +18,10 @@ jobs:
2118
- name: Install pnpm
2219
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
2320

24-
- name: Use Node.js ${{ matrix.node-version }}
21+
- name: Use Node.js
2522
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
2623
with:
27-
registry-url: "https://registry.npmjs.org"
28-
node-version: ${{ matrix.node-version }}
29-
cache: 'pnpm'
24+
node-version-file: '.nvmrc'
3025

3126
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
3227
id: nextjs-cache
@@ -37,7 +32,9 @@ jobs:
3732
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
3833
3934
- run: pnpm install --frozen-lockfile
35+
4036
- run: pnpm ci-build
37+
4138
- name: Publish documentation
4239
run: |
4340
git config user.name "github-actions[bot]"

.github/workflows/publish-npm.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish NPM
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish_npm:
13+
runs-on: ubuntu-latest
14+
environment: prod
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
22+
23+
- name: Use Node.js
24+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
25+
with:
26+
node-version-file: '.nvmrc'
27+
28+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
29+
id: nextjs-cache
30+
with:
31+
path: packages/documentation/.next/cache
32+
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
33+
restore-keys: |
34+
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
35+
36+
- name: Validate tag matches package.json versions
37+
run: |
38+
TAG_VERSION="${{ github.ref_name }}"
39+
40+
node scripts/validate-package-version.mjs "${TAG_VERSION}"
41+
42+
- run: pnpm install --frozen-lockfile
43+
44+
- run: pnpm ci-build
45+
46+
- name: Publish packages
47+
run: |
48+
TAG_VERSION="${{ github.ref_name }}"
49+
50+
if [[ $TAG_VERSION == *"alpha"* ]]; then
51+
NPM_DIST_TAG=alpha
52+
else
53+
NPM_DIST_TAG=latest
54+
fi
55+
56+
pnpm publish -r --dry-run --tag $NPM_DIST_TAG

CONTRIBUTING.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ workplace's Github organisation.
118118

119119
## Publishing
120120

121-
For now, publishing the package is a manual process. There are two scripts to
122-
assist:
121+
The package is published using Github Actions as a [trusted publisher](https://docs.npmjs.com/trusted-publishers).
123122

124-
```shell
125-
# Publish a pre-release, eg: 0.0.2-alpha.107
126-
pnpm publish:alpha
127-
# Publish a release, eg: 0.0.1
128-
pnpm publish:release
129-
```
123+
The release process is as follows:
130124

131-
These will build and test before asking for publish confirmation.
125+
1. Repository admin runs `pnpm publish:alpha` / `pnpm publish:release` against `main`
126+
* bumps the package versions
127+
* generates changelogs
128+
* commits and tags
129+
2. When happy with the release commit / tags, push to `main`
130+
3. The [publish-npm](./.github/workflows/publish-npm.yml) action will be triggered by the version tag, build and publish the packages to npm.
131+
* A repository admin will need to manually approve the workflow run.
132132

133133
After publishing a release, manually create a release in Github.

biome.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",
@@ -13,8 +13,8 @@
1313
}
1414
},
1515
"files": {
16-
"maxSize": 10485760,
1716
// 10MB
17+
"maxSize": 10485760,
1818
"includes": [
1919
"**",
2020
"!**/packages/openapi-code-generator/src/core/schemas/openapi-3.0-specification-validator.js",

e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@nahkies/typescript-koa-runtime": "workspace:*",
2222
"axios": "^1.12.2",
2323
"express": "^5.1.0",
24-
"koa": "^3.0.1",
24+
"koa": "^3.0.3",
2525
"zod": "^3.25.74"
2626
},
2727
"devDependencies": {

integration-tests/typescript-angular/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
},
1313
"private": true,
1414
"dependencies": {
15-
"@angular/animations": "^20.3.4",
16-
"@angular/common": "^20.3.4",
17-
"@angular/compiler": "^20.3.4",
18-
"@angular/core": "^20.3.4",
19-
"@angular/forms": "^20.3.4",
20-
"@angular/platform-browser": "^20.3.4",
21-
"@angular/platform-browser-dynamic": "^20.3.4",
22-
"@angular/router": "^20.3.4",
15+
"@angular/animations": "^20.3.6",
16+
"@angular/common": "^20.3.6",
17+
"@angular/compiler": "^20.3.6",
18+
"@angular/core": "^20.3.6",
19+
"@angular/forms": "^20.3.6",
20+
"@angular/platform-browser": "^20.3.6",
21+
"@angular/platform-browser-dynamic": "^20.3.6",
22+
"@angular/router": "^20.3.6",
2323
"rxjs": "~7.8.2",
2424
"tslib": "^2.8.1",
2525
"zone.js": "~0.15.1"
2626
},
2727
"devDependencies": {
28-
"@angular-devkit/build-angular": "^20.3.5",
29-
"@angular/cli": "^20.3.5",
30-
"@angular/compiler-cli": "^20.3.4",
31-
"@types/jasmine": "~5.1.9",
28+
"@angular-devkit/build-angular": "^20.3.6",
29+
"@angular/cli": "^20.3.6",
30+
"@angular/compiler-cli": "^20.3.6",
31+
"@types/jasmine": "~5.1.12",
3232
"jasmine-core": "~5.12.0",
3333
"karma": "~6.4.4",
3434
"karma-chrome-launcher": "~3.2.0",

integration-tests/typescript-koa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@koa/router": "^14.0.0",
1414
"@nahkies/typescript-koa-runtime": "workspace:*",
1515
"joi": "^18.0.1",
16-
"koa": "^3.0.1",
16+
"koa": "^3.0.3",
1717
"tslib": "^2.8.1",
1818
"zod": "^3.25.74"
1919
},

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"prepare": "husky"
4040
},
4141
"devDependencies": {
42-
"@biomejs/biome": "2.2.5",
42+
"@biomejs/biome": "2.2.6",
4343
"@biomejs/js-api": "3.0.0",
44-
"@biomejs/wasm-nodejs": "2.2.5",
44+
"@biomejs/wasm-nodejs": "2.2.6",
4545
"@commander-js/extra-typings": "^14.0.0",
4646
"@jest/reporters": "^30.2.0",
4747
"@swc/core": "^1.13.5",
@@ -56,7 +56,7 @@
5656
"husky": "^9.1.7",
5757
"jest": "^30.2.0",
5858
"json5": "^2.2.3",
59-
"lerna": "^8.2.3",
59+
"lerna": "^9.0.0",
6060
"lint-staged": "^16.2.4",
6161
"prettier": "^3.6.2",
6262
"remark": "^15.0.1",

packages/documentation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@types/lodash": "^4.17.20",
4747
"@types/node": "22.16.5",
4848
"@types/react": "^19.2.2",
49-
"@types/react-dom": "^19.2.1",
49+
"@types/react-dom": "^19.2.2",
5050
"gh-pages": "^6.3.0",
5151
"null-loader": "^4.0.1",
5252
"tsx": "^4.20.6",

packages/openapi-code-generator/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
"tsx": "^4.20.6"
5757
},
5858
"dependencies": {
59-
"@biomejs/biome": "2.2.5",
59+
"@biomejs/biome": "2.2.6",
6060
"@biomejs/js-api": "3.0.0",
61-
"@biomejs/wasm-nodejs": "2.2.5",
61+
"@biomejs/wasm-nodejs": "2.2.6",
6262
"@commander-js/extra-typings": "^14.0.0",
6363
"ajv": "^8.17.1",
6464
"ajv-draft-04": "^1.0.0",

0 commit comments

Comments
 (0)