|
11 | 11 | description: '[Optional] Override semantic versioning with explict version (allowed values: "patch", "minor", "major", or explicit version)' |
12 | 12 | default: '' |
13 | 13 | 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: '' |
16 | 17 |
|
17 | 18 | env: |
18 | 19 | NODE_OPTIONS: "--max-old-space-size=4096" |
|
33 | 34 | 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." |
34 | 35 | exit 1 |
35 | 36 |
|
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 | | -
|
42 | 37 | - name: Checkout code |
43 | 38 | uses: actions/checkout@v4 |
44 | 39 | with: |
@@ -114,10 +109,18 @@ jobs: |
114 | 109 | run: npm install -g npm@latest |
115 | 110 | - run: npm ci |
116 | 111 | - 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 |
118 | 115 | env: |
119 | 116 | NPM_CONFIG_PROVENANCE: true |
120 | 117 | 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 |
121 | 124 |
|
122 | 125 | # Once publishing is complete, validate that the published packages are useable |
123 | 126 | validate: |
|
0 commit comments