Skip to content

Commit 3169148

Browse files
committed
ci: publish pre-releases to npm under the next dist-tag
Run the npm publish + smoke-test jobs on prereleased events too, but tag pre-releases as `next` instead of `latest`. `npm i @zerops/zcli` keeps installing the latest stable; pre-releases are reachable via `@zerops/zcli@next` for testing without affecting existing users.
1 parent 46d3eac commit 3169148

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ jobs:
3737

3838
publish-npm:
3939
needs: goreleaser
40-
if: github.event.action == 'released'
40+
if: github.event.action == 'released' || github.event.action == 'prereleased'
4141
runs-on: ubuntu-latest
4242
timeout-minutes: 10
4343
permissions:
4444
contents: read
4545
env:
4646
VERSION: ${{ github.event.release.tag_name }}
47+
# Full releases go to the default `latest` tag; pre-releases go to `next` so
48+
# `npm i @zerops/zcli` is unaffected and they install via `@zerops/zcli@next`.
49+
NPM_TAG: ${{ github.event.action == 'prereleased' && 'next' || 'latest' }}
4750
steps:
4851
- uses: actions/checkout@v6
4952
- uses: actions/setup-node@v6
@@ -84,7 +87,7 @@ jobs:
8487
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8588
run: |
8689
for dir in "$GITHUB_WORKSPACE"/dist-npm/*/; do
87-
npm publish "$dir" --access=public
90+
npm publish "$dir" --access=public --tag "$NPM_TAG"
8891
done
8992
9093
- name: Publish main package
@@ -94,14 +97,14 @@ jobs:
9497
cd tools/npm
9598
npm i -g replace-in-files-cli@2.2.0
9699
replace-in-files --string='v0.0.0-zerops' --replacement="$NPM_VERSION" package.json
97-
npm publish --access=public --ignore-scripts
100+
npm publish --access=public --ignore-scripts --tag "$NPM_TAG"
98101
99102
# Install the just-published package across OS/arch + package managers and run the
100103
# binary, so a broken release (missing platform package, os/cpu mismatch, Bun
101104
# incompatibility, exec-bit loss) surfaces immediately instead of in user reports.
102105
smoke-test:
103106
needs: publish-npm
104-
if: github.event.action == 'released'
107+
if: github.event.action == 'released' || github.event.action == 'prereleased'
105108
runs-on: ${{ matrix.os }}
106109
timeout-minutes: 10
107110
strategy:

0 commit comments

Comments
 (0)