Skip to content

Commit dd6b21d

Browse files
qdotclaude
andcommitted
feat(wasm): add publish safeguards and CI release workflow
- blob's prepublishOnly now runs wasm-pack before vite build, ensuring manual npm publish always gets a fresh Rust build - New publish-wasm.yml workflow triggers on wasm-v* tags: builds from scratch and publishes both packages with npm provenance Requires NPM_TOKEN secret in the repo for CI publishing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e391623 commit dd6b21d

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

.github/workflows/publish-wasm.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish WASM Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- 'wasm-v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Fix ~/.cargo directory permissions
17+
run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
18+
- name: Install required packages
19+
run: sudo apt-get -y update && sudo apt-get -y install libudev-dev libusb-1.0-0-dev libdbus-1-dev
20+
- name: Cache cargo registry
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.cargo/registry
24+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
25+
- name: Cache cargo build
26+
uses: actions/cache@v4
27+
with:
28+
path: target
29+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
30+
- name: Rust toolchain fetch
31+
uses: actions-rs/toolchain@v1
32+
with:
33+
profile: minimal
34+
toolchain: nightly
35+
override: true
36+
- name: WASM Toolchain fetch
37+
uses: jetli/wasm-pack-action@v0.4.0
38+
with:
39+
version: 'latest'
40+
- name: Set up Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '22'
44+
registry-url: 'https://registry.npmjs.org'
45+
- name: Build WASM crate
46+
run: wasm-pack build crates/buttplug_wasm --target web
47+
- name: Install workspace dependencies
48+
run: cd wasm && npm install
49+
- name: Build blob package
50+
run: cd wasm && npm run build:blob
51+
- name: Build connector package
52+
run: cd wasm && npm run build:connector
53+
- name: Publish buttplug-wasm-blob
54+
run: cd wasm/packages/blob && npm publish --provenance --access public
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
- name: Publish buttplug-wasm
58+
run: cd wasm/packages/connector && npm publish --provenance --access public
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

wasm/packages/blob/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
"node": ">=18"
3737
},
3838
"scripts": {
39-
"build": "vite build",
39+
"build:wasm": "cd ../../../crates/buttplug_wasm && wasm-pack build --target web",
40+
"build:js": "vite build",
41+
"build": "npm run build:wasm && npm run build:js",
4042
"prepublishOnly": "npm run build"
4143
},
4244
"devDependencies": {

0 commit comments

Comments
 (0)