-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.72 KB
/
publish-npm.yml
File metadata and controls
59 lines (50 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Publish to npm
on:
push:
tags:
- "v*"
permissions:
contents: read
id-token: write
jobs:
publish:
name: Build and publish WASM package
runs-on: ubuntu-latest
environment: Publishing
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Build WASM package
run: wasm-pack build crates/usfm3-wasm --target web
- name: Set package name and version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
cp crates/usfm3-wasm/node.js crates/usfm3-wasm/pkg/node.js
cd crates/usfm3-wasm/pkg
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.name = 'usfm3';
pkg.version = '${TAG_VERSION}';
pkg.files = ['usfm3_wasm_bg.wasm', 'usfm3_wasm.js', 'usfm3_wasm.d.ts', 'node.js'];
pkg.keywords = ['usfm', 'usj', 'usx', 'vref', 'parser', 'bible', 'scripture'];
pkg.exports = {
'.': {
node: { import: './node.js' },
default: './usfm3_wasm.js'
}
};
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Publish to npm
run: npm publish --access public
working-directory: crates/usfm3-wasm/pkg