Skip to content

Commit 1849e1b

Browse files
committed
Publish to npm
1 parent 2041827 commit 1849e1b

File tree

5 files changed

+111
-4
lines changed

5 files changed

+111
-4
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- main
66

77
jobs:
8-
publish:
8+
jsr:
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: read
@@ -18,3 +18,26 @@ jobs:
1818
deno-version: vx.x.x
1919
- name: Publish package
2020
run: deno publish
21+
npm:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
id-token: write
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup Deno
29+
uses: denoland/setup-deno@v2
30+
with:
31+
deno-version: vx.x.x
32+
- name: setup Node
33+
uses: actions/setup-node@v4
34+
with:
35+
registry-url: "https://registry.npmjs.org"
36+
- name: Build npm package
37+
run: deno run -A scripts/build_npm.ts
38+
39+
- name: Publish package
40+
run: npm publish --provenance --access public
41+
working-directory: ./npm
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm/

deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rotu/structview",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"license": "MIT",
55
"tasks": {
66
"dev": "deno test --watch"
@@ -9,6 +9,7 @@
99
"semiColons": false
1010
},
1111
"imports": {
12+
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
1213
"@std/assert": "jsr:@std/assert@1"
1314
},
1415
"exports": {

deno.lock

Lines changed: 55 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build_npm.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { build, emptyDir } from "@deno/dnt"
2+
3+
import denojson from "../deno.json" with { type: "json" }
4+
5+
await emptyDir("./npm")
6+
7+
await build({
8+
typeCheck: false,
9+
scriptModule: false,
10+
entryPoints: ["./mod.ts"],
11+
outDir: "./npm",
12+
shims: {
13+
deno: "dev",
14+
},
15+
package: {
16+
name: "@rotu/structview",
17+
version: `${denojson.version}+dnt`,
18+
repository: {
19+
type: "git",
20+
url: "https://github.com/rotu/structview",
21+
},
22+
description: "Read and write structured binary data with typesafe views",
23+
license: "MIT",
24+
},
25+
postBuild() {
26+
// steps to run after building and before running the tests
27+
Deno.copyFileSync("README.md", "npm/README.md")
28+
},
29+
})

0 commit comments

Comments
 (0)