Skip to content

Commit 876cf67

Browse files
committed
ci: add npm publishing workflow
1 parent 653815f commit 876cf67

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish npm
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
id-token: write
12+
13+
jobs:
14+
publish-npm:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Deno
21+
uses: denoland/setup-deno@v2
22+
with:
23+
deno-version: v2.x
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
registry-url: https://registry.npmjs.org
30+
31+
- name: Verify tag matches deno.json version
32+
if: github.event_name == 'push'
33+
shell: bash
34+
run: |
35+
set -euo pipefail
36+
tag="${GITHUB_REF_NAME}"
37+
version="${tag#v}"
38+
deno_version="$(node -p "require('./deno.json').version")"
39+
if [[ "${deno_version}" != "${version}" ]]; then
40+
echo "Tag '${tag}' does not match deno.json version '${deno_version}'."
41+
exit 1
42+
fi
43+
44+
- name: Validate package
45+
run: deno task check
46+
47+
- name: Build npm package
48+
run: deno task build:npm
49+
50+
- name: Publish to npm
51+
run: npm publish ./npm --access public --provenance
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)