55# package plus per-platform `optionalDependencies` (fleischwolf-<triple>) via
66# napi-rs and publishes them all.
77#
8- # Trigger: manual only (workflow_dispatch). Pick the release tag to build — the
9- # workflow checks out that tag and publishes the npm version derived from it, so
10- # npm releases stay decoupled from the crates.io release on every master push.
11- # Run it from the Actions tab (or `gh workflow run npm-publish.yml -f tag=v0.7.0`).
8+ # Trigger: manual only (workflow_dispatch). By default it builds the latest
9+ # master (the version in the workspace Cargo.toml); optionally pass a release
10+ # tag to build that instead. Either way the workflow checks out the chosen ref
11+ # and publishes, so npm releases stay decoupled from the crates.io release on
12+ # every master push. Run it from the Actions tab (or
13+ # `gh workflow run npm-publish.yml`, optionally `-f tag=v0.7.0`).
1214#
1315# Requires one repository secret: NPM_TOKEN — an npm automation token with
1416# publish rights to `fleischwolf` and the `fleischwolf-*` platform packages.
1921 workflow_dispatch :
2022 inputs :
2123 tag :
22- description : " Release tag to build and publish (e.g. v0.7.0)."
23- required : true
24+ description : " Release tag to build (e.g. v0.7.0). Blank = latest master."
25+ required : false
26+ default : " "
2427 version :
25- description : " Override the npm version (e.g. 0.7.0). Blank = derive from the tag ."
28+ description : " Override the npm version (e.g. 0.7.0). Blank = tag, or workspace version on master ."
2629 required : false
2730 default : " "
2831
2932concurrency :
30- group : npm-publish-${{ inputs.tag }}
33+ group : npm-publish-${{ inputs.tag || github.ref }}
3134 cancel-in-progress : false
3235
3336defaults :
@@ -48,16 +51,19 @@ jobs:
4851 # ONNX/ort build). Requires the arm64 runner image to be available.
4952 - target : aarch64-unknown-linux-gnu
5053 host : ubuntu-24.04-arm
51- - target : x86_64-apple-darwin
52- host : macos-13
53- - target : aarch64-apple-darwin
54- host : macos-14
54+ # macOS (darwin) prebuilds are omitted: GitHub-hosted macOS runners are
55+ # blocked in this environment, and darwin can't be cross-compiled on
56+ # Linux (needs the Apple SDK). macOS users build from source. To re-add
57+ # when macOS runners are available, add the darwin targets back here AND
58+ # to `napi.triples.additional` in package.json:
59+ # - { target: aarch64-apple-darwin, host: macos-14 }
60+ # - { target: x86_64-apple-darwin, host: macos-14 } # cross via --target
5561 - target : x86_64-pc-windows-msvc
5662 host : windows-latest
5763 steps :
58- - uses : actions/checkout@v4
64+ - uses : actions/checkout@v5
5965 with :
60- ref : ${{ inputs.tag }}
66+ ref : ${{ inputs.tag || github.ref }}
6167
6268 - uses : dtolnay/rust-toolchain@stable
6369 with :
6975 key : ${{ matrix.target }}
7076 workspaces : " ."
7177
72- - uses : actions/setup-node@v4
78+ - uses : actions/setup-node@v5
7379 with :
7480 node-version : 20
7581
8894 run : npx napi build --platform --release --target ${{ matrix.target }} --js native.js --dts native.d.ts
8995
9096 - name : Upload prebuilt binary
91- uses : actions/upload-artifact@v4
97+ uses : actions/upload-artifact@v5
9298 with :
9399 name : bindings-${{ matrix.target }}
94100 path : crates/fleischwolf-node/fleischwolf.*.node
98104 # linux-x64 build) for the publish job to include in the main package.
99105 - name : Upload JS binding
100106 if : matrix.target == 'x86_64-unknown-linux-gnu'
101- uses : actions/upload-artifact@v4
107+ uses : actions/upload-artifact@v5
102108 with :
103109 name : js-binding
104110 path : |
@@ -111,11 +117,11 @@ jobs:
111117 needs : build
112118 runs-on : ubuntu-latest
113119 steps :
114- - uses : actions/checkout@v4
120+ - uses : actions/checkout@v5
115121 with :
116- ref : ${{ inputs.tag }}
122+ ref : ${{ inputs.tag || github.ref }}
117123
118- - uses : actions/setup-node@v4
124+ - uses : actions/setup-node@v5
119125 with :
120126 node-version : 20
121127 registry-url : " https://registry.npmjs.org"
@@ -125,26 +131,33 @@ jobs:
125131
126132 # Prebuilt binaries → artifacts/<name>/fleischwolf.<triple>.node
127133 - name : Download prebuilt binaries
128- uses : actions/download-artifact@v4
134+ uses : actions/download-artifact@v5
129135 with :
130136 pattern : bindings-*
131137 path : crates/fleischwolf-node/artifacts
132138
133139 # The JS loader + types → the package root.
134140 - name : Download JS binding
135- uses : actions/download-artifact@v4
141+ uses : actions/download-artifact@v5
136142 with :
137143 name : js-binding
138144 path : crates/fleischwolf-node
139145
140- # Version = the explicit override, else the selected tag with its leading `v`.
146+ # Version = the explicit override, else the selected tag (sans leading `v`),
147+ # else the workspace version from the root Cargo.toml (latest-master run).
141148 - name : Resolve version
142149 id : ver
143150 run : |
144151 v="${{ inputs.version }}"
145- if [ -z "$v" ]; then v="${{ inputs.tag }}"; v="${v#v}"; fi
152+ if [ -z "$v" ]; then
153+ if [ -n "${{ inputs.tag }}" ]; then
154+ v="${{ inputs.tag }}"; v="${v#v}"
155+ else
156+ v="$(grep -m1 '^version = ' ../../Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')"
157+ fi
158+ fi
146159 echo "version=$v" >> "$GITHUB_OUTPUT"
147- echo "Publishing fleischwolf@$v from tag ${{ inputs.tag }} "
160+ echo "Publishing fleischwolf@$v (ref: ${{ inputs.tag || github.ref }}) "
148161
149162 # Skip cleanly if this version is already on npm (idempotent re-runs).
150163 - name : Check if already published
0 commit comments