Skip to content

Commit b7437a2

Browse files
author
A.P.A. Slaa
committed
fix: workflow
1 parent f6e4e17 commit b7437a2

2 files changed

Lines changed: 23 additions & 72 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
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
@@ -42,10 +44,8 @@ jobs:
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

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@
7171
"main"
7272
],
7373
"plugins": [
74-
"@semantic-release/commit-analyzer",
75-
"@semantic-release/release-notes-generator",
76-
"@semantic-release/changelog",
7774
[
78-
"@semantic-release/npm",
79-
{
80-
"npmPublish": false
81-
}
75+
"@semantic-release/commit-analyzer"
76+
],
77+
[
78+
"@semantic-release/release-notes-generator"
79+
],
80+
[
81+
"@semantic-release/changelog"
82+
],
83+
[
84+
"@semantic-release/npm"
8285
],
8386
[
8487
"@sourceregistry/semantic-release-jsr"

0 commit comments

Comments
 (0)