Skip to content

Commit 5c44c83

Browse files
authored
feat(publish): Use trusted publishing (OIDC) for canary releases (facebook#11712)
* Fix canary publish, use trusted publishing (OIDC) * verbose lerna publish logs * test upgrade Lerna * refactor: apply lint autofix * do not checkout main, get verbose logs * test publish * cleanup workflow * downgrade Lerna for nodejs compatibility reason * downgrade Lerna for nodejs compatibility reason * use Lerna 9 only in publish workflow * use Lerna 9 only in publish workflow * cleanup publish script * cleanup script * downgrade lerna * refactor: apply lint autofix * empty --------- Co-authored-by: slorber <749374+slorber@users.noreply.github.com>
1 parent bbc7269 commit 5c44c83

4 files changed

Lines changed: 652 additions & 1135 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Canary Release
1+
name: Publish
22

33
on:
44
workflow_dispatch:
@@ -7,12 +7,13 @@ on:
77
- main
88
- docusaurus-v**
99
paths:
10-
- .github/workflows/canary-release.yml
10+
- .github/workflows/publish.yml
1111
- package.json
12-
- packages/**
12+
- packages/*
1313

1414
permissions:
1515
contents: read
16+
id-token: write # For OIDC, see https://docs.npmjs.com/trusted-publishers
1617

1718
jobs:
1819
publish-canary:
@@ -32,18 +33,14 @@ jobs:
3233
run: |
3334
git config --global user.name "Docusaurus Canary"
3435
git config --global user.email "canary@docusaurus.io"
35-
git fetch
36-
git checkout main
37-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
38-
cat .npmrc
39-
echo "npm whoami"
40-
npm whoami
41-
env:
42-
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
4336
- name: Installation
4437
run: yarn || yarn || yarn
38+
# TODO Docusaurus v4: remove after we upgrade the Node version
39+
- name: Upgrade Lerna
40+
run: |
41+
yarn add -D -W lerna@9.0.3 --ignore-scripts
42+
git commit -am "chore: upgrade lerna"
4543
- name: Publish Canary release
4644
run: |
47-
yarn canary
48-
env:
49-
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
45+
yarn canary:bumpVersion
46+
yarn canary:publish

lerna.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"version": "3.9.2",
33
"npmClient": "yarn",
4-
"useWorkspaces": true,
54
"useNx": false,
65
"changelog": {
76
"repo": "facebook/docusaurus",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"canary": "yarn canary:bumpVersion && yarn canary:publish",
5151
"canary:getCoreVersion": "node -p \"require('./packages/docusaurus/package.json').version\"",
5252
"canary:version": "echo `yarn --silent canary:getCoreVersion`-canary-`git rev-list --count HEAD`+`git rev-parse --short HEAD`",
53-
"canary:bumpVersion": "yarn lerna version `yarn --silent canary:version` --exact --no-push --yes",
54-
"canary:publish": "yarn lerna publish from-package --dist-tag canary --yes --no-verify-access",
53+
"canary:bumpVersion": "yarn lerna version `yarn --silent canary:version` --exact --no-push --yes --loglevel verbose",
54+
"canary:publish": "yarn lerna publish from-package --dist-tag canary --yes --no-verify-access --loglevel verbose",
5555
"changelog": "lerna-changelog",
5656
"postinstall": "patch-package && yarn lock:update && yarn build:packages",
5757
"prepare": "husky install",
@@ -111,7 +111,7 @@
111111
"jest-environment-jsdom": "^30.2.0",
112112
"jest-serializer-ansi-escapes": "^4.0.0",
113113
"jest-serializer-react-helmet-async": "^1.0.21",
114-
"lerna": "^6.6.2",
114+
"lerna": "^7.4.2",
115115
"lerna-changelog": "^2.2.0",
116116
"lint-staged": "~13.2.3",
117117
"lockfile-lint": "^4.14.0",

0 commit comments

Comments
 (0)