Skip to content

Commit a7fb40d

Browse files
committed
ci(node): make the npm-publish tag optional, default to latest master
The workflow_dispatch `tag` input is now optional: blank builds the latest master (checking out the dispatch ref and deriving the npm version from the workspace Cargo.toml), or pass a tag to build that release instead. An explicit `version` input still overrides either. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L7XwjsWSHWjrh39JxMLuB3
1 parent 174825f commit a7fb40d

2 files changed

Lines changed: 26 additions & 15 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
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.
@@ -19,15 +21,16 @@ on:
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

2932
concurrency:
30-
group: npm-publish-${{ inputs.tag }}
33+
group: npm-publish-${{ inputs.tag || github.ref }}
3134
cancel-in-progress: false
3235

3336
defaults:
@@ -57,7 +60,7 @@ jobs:
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

crates/fleischwolf-node/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Prebuilt platforms: Linux x64 / arm64 (glibc), macOS x64 / arm64, Windows x64.
2323
The right binary is pulled in automatically as a platform-specific
2424
`optionalDependency` (`fleischwolf-<triple>`). Releases are published to npm by
2525
manually running the `npm publish` workflow
26-
(`.github/workflows/npm-publish.yml`) for a chosen release tag — decoupled from
27-
the crates.io release.
26+
(`.github/workflows/npm-publish.yml`) — by default it builds the latest master
27+
(the workspace version); optionally pass a release tag to build that instead.
28+
Decoupled from the crates.io release.
2829

2930
## Build from source
3031

0 commit comments

Comments
 (0)