Skip to content

Commit 4646fb4

Browse files
author
Lucas McDonald
committed
fix(release): omit --dist-tag when empty so latest isn't moved
Instead of requiring a tag, when dist_tag is empty run lerna publish without --dist-tag. Modern npm won't move the 'latest' tag when publishing a lower version, so 4.x maintenance releases don't hijack latest.
1 parent 8d837b5 commit 4646fb4

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

.github/workflows/prod-release.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ on:
1111
description: '[Optional] Override semantic versioning with explict version (allowed values: "patch", "minor", "major", or explicit version)'
1212
default: ''
1313
dist_tag:
14-
description: 'NPM distribution tag (required; this is a 4.x maintenance line, so do not use "latest")'
15-
required: true
14+
description: 'NPM dist-tag. Leave empty to publish without moving the "latest" tag (use for 4.x maintenance releases).'
15+
required: false
16+
default: ''
1617

1718
env:
1819
NODE_OPTIONS: "--max-old-space-size=4096"
@@ -33,12 +34,6 @@ jobs:
3334
echo "::error::Dispatch this workflow from a branch (got ${{ github.ref_type }} '${{ github.ref_name }}'). To release a specific commit, point a branch at it first."
3435
exit 1
3536
36-
- name: Require a dist-tag
37-
if: github.event.inputs.dist_tag == ''
38-
run: |
39-
echo "::error::Specify an npm dist-tag. This is the 4.x maintenance line; do not publish to 'latest'."
40-
exit 1
41-
4237
- name: Checkout code
4338
uses: actions/checkout@v4
4439
with:
@@ -114,10 +109,18 @@ jobs:
114109
run: npm install -g npm@latest
115110
- run: npm ci
116111
- run: npm run build --if-present
117-
- run: npx lerna publish from-package --yes --dist-tag "$DIST_TAG"
112+
# If no dist-tag is given, omit --dist-tag entirely so npm doesn't move
113+
# `latest` (modern npm won't set `latest` when publishing a lower version).
114+
- name: Publish
118115
env:
119116
NPM_CONFIG_PROVENANCE: true
120117
DIST_TAG: ${{ github.event.inputs.dist_tag }}
118+
run: |
119+
if [ -n "$DIST_TAG" ]; then
120+
npx lerna publish from-package --yes --dist-tag "$DIST_TAG"
121+
else
122+
npx lerna publish from-package --yes
123+
fi
121124
122125
# Once publishing is complete, validate that the published packages are useable
123126
validate:

0 commit comments

Comments
 (0)