File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ strategy :
13+ matrix :
14+ node-version : [18.x, 20.x, 22.x]
15+ steps :
16+ - uses : actions/checkout@v4
17+ - name : Use Node.js ${{ matrix.node-version }}
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : ${{ matrix.node-version }}
21+ cache : npm
22+ - run : npm ci
23+ - run : npm run build
24+ - run : npm test
Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ jobs :
8+ publish :
9+ runs-on : ubuntu-latest
10+ permissions :
11+ contents : read
12+ id-token : write
13+ steps :
14+ - uses : actions/checkout@v4
15+ - uses : actions/setup-node@v4
16+ with :
17+ node-version : 20.x
18+ registry-url : https://registry.npmjs.org
19+ cache : npm
20+ - run : npm ci
21+ - run : npm run build
22+ - run : npm test
23+ - name : Verify tag matches package.json version
24+ run : |
25+ PKG_VERSION=$(node -p "require('./package.json').version")
26+ TAG_VERSION="${GITHUB_REF_NAME#v}"
27+ if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
28+ echo "Tag $TAG_VERSION does not match package.json version $PKG_VERSION"
29+ exit 1
30+ fi
31+ - run : npm publish --provenance --access public
32+ env :
33+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments