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 :
5760 steps :
5861 - uses : actions/checkout@v4
5962 with :
60- ref : ${{ inputs.tag }}
63+ ref : ${{ inputs.tag || github.ref }}
6164
6265 - uses : dtolnay/rust-toolchain@stable
6366 with :
@@ -113,7 +116,7 @@ jobs:
113116 steps :
114117 - uses : actions/checkout@v4
115118 with :
116- ref : ${{ inputs.tag }}
119+ ref : ${{ inputs.tag || github.ref }}
117120
118121 - uses : actions/setup-node@v4
119122 with :
@@ -137,14 +140,21 @@ jobs:
137140 name : js-binding
138141 path : crates/fleischwolf-node
139142
140- # Version = the explicit override, else the selected tag with its leading `v`.
143+ # Version = the explicit override, else the selected tag (sans leading `v`),
144+ # else the workspace version from the root Cargo.toml (latest-master run).
141145 - name : Resolve version
142146 id : ver
143147 run : |
144148 v="${{ inputs.version }}"
145- if [ -z "$v" ]; then v="${{ inputs.tag }}"; v="${v#v}"; fi
149+ if [ -z "$v" ]; then
150+ if [ -n "${{ inputs.tag }}" ]; then
151+ v="${{ inputs.tag }}"; v="${v#v}"
152+ else
153+ v="$(grep -m1 '^version = ' ../../Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')"
154+ fi
155+ fi
146156 echo "version=$v" >> "$GITHUB_OUTPUT"
147- echo "Publishing fleischwolf@$v from tag ${{ inputs.tag }} "
157+ echo "Publishing fleischwolf@$v (ref: ${{ inputs.tag || github.ref }}) "
148158
149159 # Skip cleanly if this version is already on npm (idempotent re-runs).
150160 - name : Check if already published
0 commit comments