Skip to content

Commit cb13ea2

Browse files
committed
Guard prerelease npm publish tag
1 parent eb299bf commit cb13ea2

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
description: Run all checks without publishing to npm.
1111
type: boolean
1212
default: true
13+
npm_tag:
14+
description: npm dist-tag to use when publishing manually.
15+
type: string
16+
default: next
1317

1418
permissions:
1519
contents: read
@@ -63,11 +67,25 @@ jobs:
6367
- name: Smoke test packed package
6468
run: bun run pack:smoke
6569

70+
- name: Resolve npm publish tag
71+
id: publish-tag
72+
run: |
73+
version="$(node -p "require('./package.json').version")"
74+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.npm_tag }}" ]; then
75+
tag="${{ inputs.npm_tag }}"
76+
elif [[ "$version" == *-* ]]; then
77+
tag="next"
78+
else
79+
tag="latest"
80+
fi
81+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
82+
echo "Resolved npm dist-tag '$tag' for version '$version'."
83+
6684
- name: Publish to npm
6785
if: github.event_name == 'release' || inputs.dry_run == false
6886
env:
6987
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70-
run: npm publish --provenance --access public
88+
run: npm publish --provenance --access public --tag "${{ steps.publish-tag.outputs.tag }}"
7189

7290
- name: Skip publish
7391
if: github.event_name == 'workflow_dispatch' && inputs.dry_run

docs/v1-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Exit criteria:
139139

140140
Goal: make npm release boring.
141141

142-
Status: completed for local and workflow dry-run gates. `bun run pack:check` verifies package contents, and `bun run pack:smoke` packs the tarball, installs it into a temp consumer project, checks `--version`, dry-runs a scaffold, and scaffolds a real app without installing generated dependencies. The publish workflow supports GitHub releases and `workflow_dispatch` dry runs. The `Publish` workflow dry run for `a9777406d914a43c89376705f4ffdb5927961fda` passed in GitHub Actions run `25640509300`; `Publish to npm` was skipped and `Skip publish` succeeded.
142+
Status: completed for local and workflow dry-run gates. `bun run pack:check` verifies package contents, and `bun run pack:smoke` packs the tarball, installs it into a temp consumer project, checks `--version`, dry-runs a scaffold, and scaffolds a real app without installing generated dependencies. The publish workflow supports GitHub releases and `workflow_dispatch` dry runs, and resolves prerelease publishes to the `next` npm dist-tag by default. The `Publish` workflow dry run for `a9777406d914a43c89376705f4ffdb5927961fda` passed in GitHub Actions run `25640509300`; `Publish to npm` was skipped and `Skip publish` succeeded.
143143

144144
- Confirm `npm pack --dry-run` includes only intended files.
145145
- Add package smoke tests against the packed tarball:

0 commit comments

Comments
 (0)