Skip to content

Commit d18bbc3

Browse files
authored
Set up NPM trusted publishing #389
ref DEV-3099
2 parents 5b43004 + 6c93064 commit d18bbc3

File tree

21 files changed

+2487
-1517
lines changed

21 files changed

+2487
-1517
lines changed

.github/workflows/ci.yaml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,31 @@ on:
1111
branches:
1212
- '*'
1313
- '!gh-pages'
14+
tags:
15+
- '*'
1416
pull_request:
1517
branches:
1618
- '*'
1719
- '!gh-pages'
1820

21+
# https://docs.npmjs.com/trusted-publishers#step-2-configure-your-cicd-workflow
22+
permissions:
23+
id-token: write
24+
contents: read
25+
1926
jobs:
2027
test:
2128
runs-on: macos-15
2229
steps:
2330
- uses: actions/checkout@v4
24-
- uses: actions/setup-node@v4
31+
- uses: actions/setup-node@v6
2532
with:
2633
node-version-file: "./.tool-versions"
2734
- uses: ruby/setup-ruby@v1
2835
with:
2936
bundler-cache: true
37+
- run: node --version
38+
- run: npm --version
3039
- run: make ruby-audit
3140
- run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
3241
- run: npm ci
@@ -49,11 +58,37 @@ jobs:
4958
if: ${{ !cancelled() }}
5059
- run: npm run verify
5160
if: ${{ !cancelled() }}
52-
- run: npm run bundle
61+
- run: npm run build
5362
if: ${{ !cancelled() }}
5463
- run: make docs
5564
if: ${{ !cancelled() }}
5665

66+
publish:
67+
if: ${{ github.ref_type == 'tag' }}
68+
runs-on: macos-15
69+
needs: test
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: actions/setup-node@v6
73+
with:
74+
node-version-file: "./.tool-versions"
75+
- run: node --version
76+
- run: npm --version
77+
- run: npm ci
78+
- run: npm run build
79+
- run: ../../scripts/npm-publish.sh
80+
working-directory: ./packages/authgear-web/
81+
env:
82+
GITHUB_REF_NAME: ${{ github.ref_name }}
83+
- run: ../../scripts/npm-publish.sh
84+
working-directory: ./packages/authgear-react-native/
85+
env:
86+
GITHUB_REF_NAME: ${{ github.ref_name }}
87+
- run: ../../scripts/npm-publish.sh
88+
working-directory: ./packages/authgear-capacitor/
89+
env:
90+
GITHUB_REF_NAME: ${{ github.ref_name }}
91+
5792
webapp-image:
5893
runs-on: ubuntu-24.04
5994
needs: test
@@ -78,7 +113,7 @@ jobs:
78113
runs-on: macos-15
79114
steps:
80115
- uses: actions/checkout@v4
81-
- uses: actions/setup-node@v4
116+
- uses: actions/setup-node@v6
82117
with:
83118
node-version-file: "./.tool-versions"
84119
- run: make sdk-build
@@ -89,7 +124,7 @@ jobs:
89124
runs-on: macos-15
90125
steps:
91126
- uses: actions/checkout@v4
92-
- uses: actions/setup-node@v4
127+
- uses: actions/setup-node@v6
93128
with:
94129
node-version-file: "./.tool-versions"
95130
- uses: ruby/setup-ruby@v1
@@ -105,7 +140,7 @@ jobs:
105140
runs-on: macos-15
106141
steps:
107142
- uses: actions/checkout@v4
108-
- uses: actions/setup-node@v4
143+
- uses: actions/setup-node@v6
109144
with:
110145
node-version-file: "./.tool-versions"
111146
- run: make sdk-build
@@ -122,7 +157,7 @@ jobs:
122157
runs-on: macos-15
123158
steps:
124159
- uses: actions/checkout@v4
125-
- uses: actions/setup-node@v4
160+
- uses: actions/setup-node@v6
126161
with:
127162
node-version-file: "./.tool-versions"
128163
- uses: ruby/setup-ruby@v1
@@ -157,7 +192,7 @@ jobs:
157192
runs-on: macos-15
158193
steps:
159194
- uses: actions/checkout@v4
160-
- uses: actions/setup-node@v4
195+
- uses: actions/setup-node@v6
161196
with:
162197
node-version-file: "./.tool-versions"
163198
- uses: ruby/setup-ruby@v1
@@ -190,7 +225,7 @@ jobs:
190225
runs-on: macos-15
191226
steps:
192227
- uses: actions/checkout@v4
193-
- uses: actions/setup-node@v4
228+
- uses: actions/setup-node@v6
194229
with:
195230
node-version-file: "./.tool-versions"
196231
- uses: ruby/setup-ruby@v1
@@ -223,7 +258,7 @@ jobs:
223258
runs-on: macos-15
224259
steps:
225260
- uses: actions/checkout@v4
226-
- uses: actions/setup-node@v4
261+
- uses: actions/setup-node@v6
227262
with:
228263
node-version-file: "./.tool-versions"
229264
- uses: ruby/setup-ruby@v1

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nodejs 20.19.5
1+
nodejs 24.9.0
22
yarn 1.22.22
33
kubectl 1.21.8
44
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#ruby

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ docs:
2121
--entryPoints packages/authgear-web/index.d.ts \
2222
--out ./temp/docs/web \
2323
--plugin typedoc-plugin-markdown \
24-
--namedAnchors \
25-
--entryDocument index.md
24+
--useHTMLAnchors \
25+
--entryFileName index.md
2626
npx typedoc \
2727
--options typedoc/typedoc.json \
2828
--tsconfig typedoc/tsconfig.react-native.json \
2929
--name @authgear/react-native \
3030
--entryPoints packages/authgear-react-native/index.d.ts \
3131
--out ./temp/docs/react-native \
3232
--plugin typedoc-plugin-markdown \
33-
--namedAnchors \
34-
--entryDocument index.md
33+
--useHTMLAnchors \
34+
--entryFileName index.md
3535
npx typedoc \
3636
--options typedoc/typedoc.json \
3737
--tsconfig typedoc/tsconfig.capacitor.json \
3838
--name @authgear/capacitor \
3939
--entryPoints packages/authgear-capacitor/index.d.ts \
4040
--out ./temp/docs/capacitor \
4141
--plugin typedoc-plugin-markdown \
42-
--namedAnchors \
43-
--entryDocument index.md
42+
--useHTMLAnchors \
43+
--entryFileName index.md
4444
cp ./typedoc/index.md ./temp/docs/index.md
4545
cp ./typedoc/web_index.md ./temp/docs/web/index.md
4646
cp ./typedoc/react_native_index.md ./temp/docs/react-native/index.md

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ $ (cd website && yarn install --frozen-lockfile)
7070

7171
## Releasing
7272

73-
- Ensure you have `node`, `npm`, and `yarn` in your `PATH`.
74-
- Sign in as appropriate user in npm.
75-
76-
```sh
77-
# VERSION should be in format like "0.1.0"
78-
$ GIT_USER=<github-username> GITHUB_TOKEN=<github-token> GIT_BRANCH=master VERSION=<new-version> ./scripts/release.sh
79-
```
73+
1. Ensure you have `node`, `npm`, `yarn`, `sed`, `git` in your `PATH`.
74+
2. Run `npm run set-version VERSION` to set the version. VERSION should be without the `v` at the beginning, for example, `1.0.0`.
75+
3. Commit the change.
76+
4. Create a pull request for this change.
77+
5. Wait for merge.
78+
6. Run `git tag -a vVERSION -m "Release vVERSION" MERGE_COMMIT`. MERGE_COMMIT should be the commit hash of the merge commit.
79+
7. Push the tag to `github.com/authgear/authgear-sdk-js`.
8080

8181
## Known issues
8282

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# We need to use the clang from Xcode.
2727
devShells.default = pkgs.mkShellNoCC {
2828
packages = [
29-
# 20.19.5
30-
pkgs.nodejs_20
29+
# 24.9.0
30+
pkgs.nodejs_24
3131
# 3.3.9
3232
pkgs.ruby_3_3
3333
# 1.22.22

0 commit comments

Comments
 (0)