66 - main
77 - beta
88 pull_request : {}
9+ workflow_dispatch : {}
910
1011jobs :
1112 test-and-release :
1213 runs-on : ubuntu-latest
13- if : " !contains(github.event.head_commit.message, '[skip ci]')"
14-
15- strategy :
16- matrix :
17- node-version : [18.x, 22.x]
14+ if : ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
1815
1916 concurrency :
20- group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.node-version }}
17+ group : ${{ github.workflow }}-${{ github.ref }}
2118 cancel-in-progress : true
2219
2320 permissions :
@@ -28,45 +25,57 @@ jobs:
2825 # Necessary for npm publish --provenance
2926 # See https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow
3027 id-token : write
28+ packages : write
3129
3230 steps :
33- - name : ⬇️ Checkout repo
34- uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@main
35- - name : ⎔ Setup node ${{ matrix.node-version }}
36- uses : actions/setup-node@26961cf329f22f6837d5f54c3efd76b480300ace # pin@main
31+ - name : 📥 Checkout repository
32+ uses : actions/checkout@8edcb1bdb4e267140fa742c62e395cd74f332709 # main
33+
34+ - name : 🟢 Setup Node.js
35+ uses : actions/setup-node@65beceff8e91358525397bdce9103d999507ab03 # main
3736 with :
38- node-version : ${{ matrix.node-version }}
37+ node-version-file : " .nvmrc "
3938 cache : " npm"
39+
4040 - name : 🗄 Cache node_modules
4141 id : cache-node_modules
42- uses : actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # pin@ main
42+ uses : actions/cache@640a1c2554105b57832a23eea0b4672fc7a790d5 # main
4343 with :
4444 path : " **/node_modules"
45- key : node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
45+ key : node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
46+
4647 - name : 🗄 Cache .eslintcache
47- uses : actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # pin@ main
48+ uses : actions/cache@640a1c2554105b57832a23eea0b4672fc7a790d5 # main
4849 with :
4950 path : .eslintcache
50- key : eslintcache-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
51- - name : 📥 Install dependencies
51+ key : eslintcache-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
52+
53+ - name : 🔍 Install dependencies
5254 if : steps.cache-node_modules.outputs.cache-hit != 'true'
5355 run : |
54- npm ci --ignore-scripts
55- - name : 🧪 Test
56+ npm ci --ignore-scripts --prefer-offline --no-audit
57+
58+ - name : 🧪 Run tests
5659 run : |
5760 npm run prepare:build
5861 npm test
5962 env :
6063 CI : true
64+
6165 - name : ⬆️ Upload coverage report
62- uses : coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # pin@main
63- if : " matrix.node-version == '22.x'"
66+ uses : coverallsapp/github-action@e7f4f977bd3dba07a6fda03be3053f1658992446 # main
6467 with :
6568 github-token : ${{ secrets.GITHUB_TOKEN }}
66- - name : 🚀 Release
67- if : " contains(' refs/heads/main refs/heads/beta ', github.ref) && matrix.node-version == '22.x'"
69+
70+ - name : 🚀 Release preview
71+ if : ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/beta' }}
72+ run : |
73+ npx pkg-pr-new publish
74+
75+ - name : 🚀 Release on npm and jsr
76+ if : ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' }}
6877 env :
69- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7078 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
79+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7180 run : |
7281 npm run release
0 commit comments