Skip to content

Commit 2b99d1a

Browse files
authored
ci(publish-to-npm): align publish workflow with contrib repo (#5970)
1 parent 09bf31e commit 2b99d1a

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

.github/workflows/publish-to-npm.yml

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,24 @@ permissions:
77
contents: read
88

99
jobs:
10-
setup-and-compile:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout Repository
14-
uses: actions/checkout@v5
15-
with:
16-
fetch-depth: 0
17-
- name: Setup Node
18-
uses: actions/setup-node@v5
19-
with:
20-
node-version: 24
21-
registry-url: 'https://registry.npmjs.org'
22-
- run: npm ci
23-
# NOTE: in the past, we've had situations where the compiled files were missing as the `prepublishOnly` script was
24-
# missing in some packages. `npx lerna publish` *should* also run compile, but this is intended as a safeguard
25-
# when that does not happen for whatever reason.
26-
- run: npm run compile
27-
- name: Upload contents for publish
28-
uses: actions/upload-artifact@v4
29-
with:
30-
name: publish-cache-${{ github.run_number }}
31-
path: .
32-
include-hidden-files: true
33-
if-no-files-found: error
34-
retention-days: 10
3510
npm-publish:
36-
needs: setup-and-compile
37-
runs-on: ubuntu-latest
3811
permissions:
3912
contents: read
40-
id-token: write # to generate npm OIDC and provenance statements
13+
id-token: write # needed for OIDC and provenance
14+
runs-on: ubuntu-latest
4115
environment: npm-publish-environment
4216
steps:
43-
- name: Setup Node
44-
uses: actions/setup-node@v5
17+
- uses: actions/checkout@v5
18+
- uses: actions/setup-node@v5
4519
with:
20+
# Require npm 11.5.1 or later for https://docs.npmjs.com/trusted-publishers.
4621
node-version: 24
4722
registry-url: 'https://registry.npmjs.org'
48-
- name: Download contents for publish
49-
uses: actions/download-artifact@v5
50-
with:
51-
name: publish-cache-${{ github.run_number }}
23+
- run: npm ci --ignore-scripts
24+
- run: npm run compile
25+
# Release Please has already incremented versions and published tags, so we just
26+
# need to publish all unpublished versions to npm here
27+
# See: https://github.com/lerna/lerna/tree/main/libs/commands/publish#bump-from-package
5228
- name: Publish to npm
5329
env:
5430
NPM_CONFIG_PROVENANCE: true
@@ -58,4 +34,4 @@ jobs:
5834
# (packages are in-fact published in the correct order), but the race on the registry still applies.
5935
# If this happens, run the workflow again - there should be enough time for everything to settle until this workflow
6036
# attempts to publish again.
61-
run: npx lerna publish --concurrency 1 from-package --no-push --no-private --no-git-tag-version --no-verify-access --dist-tag=latest --yes
37+
run: npx lerna publish --concurrency 1 from-package --no-push --no-private --no-git-tag-version --dist-tag=latest --yes

0 commit comments

Comments
 (0)