1515 test :
1616 name : Test and build
1717 runs-on : ubuntu-latest
18+ env :
19+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} //it's generated automatically
1820 steps :
1921 - name : Checkout repository
2022 uses : actions/checkout@v4
@@ -23,17 +25,17 @@ jobs:
2325 - name : Setup Node.js
2426 uses : actions/setup-node@v4
2527 with :
26- node-version : 24
28+ node-version : 22
2729 registry-url : " https://registry.npmjs.org/"
2830 - name : Install dependencies
29- run : npm install
31+ run : npm ci
3032 - name : Run tests
3133 run : npm test
3234 - name : Build the package
3335 run : npm run build
3436
35- create- release :
36- name : Create Release
37+ release :
38+ name : Release
3739 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
3840 needs :
3941 - test
4244 contents : write
4345 id-token : write
4446 env :
45- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46- outputs :
47- release_created : ${{ steps.release_tag.outputs.release_created }}
48- release_tag : ${{ steps.release_tag.outputs.release_tag }}
47+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} //it's generated automatically
48+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
4949 steps :
5050 - name : Checkout repository
5151 uses : actions/checkout@v4
@@ -54,69 +54,18 @@ jobs:
5454 - name : Setup Node.js
5555 uses : actions/setup-node@v4
5656 with :
57- node-version : 24
57+ node-version : 22
5858 registry-url : " https://registry.npmjs.org/"
5959 - name : Install dependencies
6060 run : npm ci
61- - name : Restore lockfile
62- run : git restore package-lock.json
63- - name : Create release metadata
61+ - name : Run semantic-release
6462 run : npx semantic-release
65- - name : Fetch latest main and tags
66- run : git fetch --force origin main --tags
67- - name : Detect release tag on main HEAD
68- id : release_tag
69- shell : pwsh
70- run : |
71- git checkout origin/main
72- $tag = git tag --points-at HEAD | Where-Object { $_ -match '^v\d+\.\d+\.\d+$' } | Select-Object -First 1
73- if ($null -eq $tag -or [string]::IsNullOrWhiteSpace($tag)) {
74- "release_created=false" >> $env:GITHUB_OUTPUT
75- "release_tag=" >> $env:GITHUB_OUTPUT
76- exit 0
77- }
78- "release_created=true" >> $env:GITHUB_OUTPUT
79- "release_tag=$tag" >> $env:GITHUB_OUTPUT
80-
81- publish-npm :
82- name : Publish NPM
83- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
84- needs :
85- - create-release
86- runs-on : ubuntu-latest
87- permissions :
88- contents : read
89- steps :
90- - name : Checkout repository
91- if : needs.create-release.outputs.release_created == 'true'
92- uses : actions/checkout@v4
93- with :
94- ref : ${{ needs.create-release.outputs.release_tag }}
95- fetch-depth : 0
96- - name : Setup Node.js
97- if : needs.create-release.outputs.release_created == 'true'
98- uses : actions/setup-node@v4
99- with :
100- node-version : 24
101- registry-url : " https://registry.npmjs.org/"
102- - name : Install dependencies
103- if : needs.create-release.outputs.release_created == 'true'
104- run : npm install
105- - name : Build the package
106- if : needs.create-release.outputs.release_created == 'true'
107- run : npm run build
108- - name : Publish to npm
109- if : needs.create-release.outputs.release_created == 'true'
110- env :
111- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
112- run : npm publish --access public
11363
11464 deploy-docs :
11565 name : Deploy Docs
11666 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
11767 needs :
118- - create-release
119- - publish-npm
68+ - release
12069 runs-on : ubuntu-latest
12170 permissions :
12271 contents : read
@@ -126,15 +75,14 @@ jobs:
12675 - name : Checkout repository
12776 uses : actions/checkout@v4
12877 with :
129- ref : ${{ needs.create-release.outputs.release_created == 'true' && needs.create-release.outputs.release_tag || 'main' }}
13078 fetch-depth : 0
13179 - name : Setup Node.js
13280 uses : actions/setup-node@v4
13381 with :
134- node-version : 24
82+ node-version : 22
13583 cache : npm
13684 - name : Install dependencies
137- run : npm install
85+ run : npm ci
13886 - name : Build documentation
13987 run : npm run docs:build
14088 - name : Setup Pages
0 commit comments