Skip to content

Commit 84786a1

Browse files
authored
fix(ci): pass --ref tag to publish workflow dispatches (#1124)
## Summary - **release.yml**: Pass `--ref $TAG` to all `gh workflow run` calls so `GITHUB_REF` points to the release tag instead of `refs/heads/main` - **publish-js.yml**: Add resilient dist-tag detection that falls back to checking `package.json` version format when `GITHUB_REF` isn't a tag ## Problem npm `latest` tag has been stuck at 0.1.10 since v0.1.11. All subsequent versions (0.1.11–0.1.14) were published under the `next` dist-tag instead. **Root cause**: `release.yml` dispatches publish workflows via `gh workflow run` without `--ref`. The `release: [published]` event doesn't fire because GitHub prevents recursive workflow triggers from `GITHUB_TOKEN`. Without `--ref`, `GITHUB_REF` defaults to `refs/heads/main`, and `publish-js.yml` classifies that as a pre-release → `--tag next`. ## Test plan - [ ] Verify `release.yml` passes `--ref $TAG` to all three publish workflow dispatches - [ ] Verify `publish-js.yml` determines `latest` tag when `GITHUB_REF` is a version tag - [ ] Verify `publish-js.yml` falls back to `latest` when `package.json` has stable semver - [ ] Ship v0.1.16 release to confirm npm `latest` tag updates correctly
1 parent 972ab2d commit 84786a1

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

.github/workflows/publish-js.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,31 @@ jobs:
395395
run: ls -lh bashkit.*.node bashkit.*.wasm 2>/dev/null || true
396396
working-directory: crates/bashkit-js
397397

398-
- name: Publish
398+
- name: Determine npm dist-tag
399+
id: dist-tag
400+
working-directory: crates/bashkit-js
399401
run: |
402+
PKG_VERSION=$(node -p "require('./package.json').version")
403+
echo "version=$PKG_VERSION"
404+
405+
# Stable if triggered by a release tag, OR if workflow_dispatch
406+
# and the version looks like a stable semver (no pre-release suffix).
400407
if [[ "$GITHUB_REF" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
401-
echo "Publishing stable release"
408+
echo "tag=latest" >> "$GITHUB_OUTPUT"
409+
elif [[ "$PKG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
410+
echo "tag=latest" >> "$GITHUB_OUTPUT"
411+
else
412+
echo "tag=next" >> "$GITHUB_OUTPUT"
413+
fi
414+
415+
- name: Publish
416+
run: |
417+
TAG="${{ steps.dist-tag.outputs.tag }}"
418+
echo "Publishing with dist-tag: $TAG"
419+
if [ "$TAG" = "latest" ]; then
402420
npm publish --provenance --access public
403421
else
404-
echo "Publishing pre-release with 'next' tag"
405-
npm publish --provenance --tag next --access public
422+
npm publish --provenance --tag "$TAG" --access public
406423
fi
407424
working-directory: crates/bashkit-js
408425
env:

.github/workflows/release.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ jobs:
7272
draft: false
7373
prerelease: false
7474

75+
# Note: the `release: [published]` event does NOT trigger other
76+
# workflows when the release is created with GITHUB_TOKEN (GitHub
77+
# prevents recursive workflow triggers). We must dispatch explicitly.
78+
# Use --ref to set GITHUB_REF to the tag so publish-js correctly
79+
# identifies stable releases.
7580
- name: Trigger publish workflows
76-
run: |
77-
gh workflow run publish.yml
78-
gh workflow run publish-python.yml
79-
gh workflow run publish-js.yml
8081
env:
8182
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
TAG="${{ steps.version.outputs.tag }}"
85+
gh workflow run publish.yml --ref "$TAG"
86+
gh workflow run publish-python.yml --ref "$TAG"
87+
gh workflow run publish-js.yml --ref "$TAG"
8288
8389
- name: Trigger CLI binary builds for release tag
8490
env:

0 commit comments

Comments
 (0)