From 27a461be9d508ef41865e00814f5c7a403f8fc6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Sun, 16 Nov 2025 02:16:20 +0100 Subject: [PATCH] Fix NPM publishing once and for all (#3811) --- .github/workflows/publish.yaml | 8 ++++---- package.json | 2 +- packages/browser-types/package.json | 3 +++ packages/cache-tags/package.json | 3 +++ packages/colors/package.json | 3 +++ packages/embed/package.json | 3 +++ packages/expr/package.json | 3 +++ packages/fonts/package.json | 3 +++ packages/gitbook/turbo.json | 3 +++ packages/icons/package.json | 3 +++ packages/openapi-parser/package.json | 3 +++ packages/react-contentkit/package.json | 3 +++ packages/react-math/package.json | 3 +++ packages/react-openapi/package.json | 3 +++ scripts/publish-if-new.sh | 5 +---- turbo.json | 2 +- 16 files changed, 43 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ff032ba9c..16de2a9e3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -29,6 +29,9 @@ jobs: with: node-version: 22 registry-url: 'https://registry.npmjs.org' + # Ensure npm 11.5.1 or later is installed + - name: Update npm + run: npm install -g npm@latest - name: Setup Bun uses: ./.github/composite/setup-bun - name: Install dependencies @@ -39,13 +42,10 @@ jobs: id: changesets uses: changesets/action@v1 with: + publish: bun run publish-all-packages version: bun run changeset-version env: # Using a PAT instead of GITHUB_TOKEN because we need to run workflows when releases are created # https://github.com/orgs/community/discussions/26875#discussioncomment-3253761 GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }} - # We use a dedicated step to publish to npm because it needs the top level GITHUB_TOKEN and not the GH_PERSONAL_TOKEN one - - name: Publish to NPM - if: steps.changesets.outputs.hasChangesets == 'false' - run: bun run publish-all-packages diff --git a/package.json b/package.json index d1e7a35aa..aa7424641 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "e2e-customers": "turbo run e2e-customers", "changeset": "changeset", "changeset-version": "changeset version && bun run format && bun update", - "publish-all-packages": "turbo run publish-to-npm", + "publish-all-packages": "turbo run publish-to-npm --continue=dependencies-successful", "download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local", "clean": "turbo run clean" }, diff --git a/packages/browser-types/package.json b/packages/browser-types/package.json index afc9bb8c6..06d7819a8 100644 --- a/packages/browser-types/package.json +++ b/packages/browser-types/package.json @@ -29,5 +29,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/cache-tags/package.json b/packages/cache-tags/package.json index 9de13a118..60d658ad7 100644 --- a/packages/cache-tags/package.json +++ b/packages/cache-tags/package.json @@ -28,5 +28,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/colors/package.json b/packages/colors/package.json index 2518e44df..d0f0b54cb 100644 --- a/packages/colors/package.json +++ b/packages/colors/package.json @@ -24,5 +24,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/embed/package.json b/packages/embed/package.json index dbba237b2..7211f1962 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -41,5 +41,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/expr/package.json b/packages/expr/package.json index be314e509..79aaffb05 100644 --- a/packages/expr/package.json +++ b/packages/expr/package.json @@ -40,5 +40,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/fonts/package.json b/packages/fonts/package.json index 11ee311f9..935019b01 100644 --- a/packages/fonts/package.json +++ b/packages/fonts/package.json @@ -34,5 +34,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/gitbook/turbo.json b/packages/gitbook/turbo.json index b1c2d2ae5..b597d01e2 100644 --- a/packages/gitbook/turbo.json +++ b/packages/gitbook/turbo.json @@ -11,6 +11,9 @@ }, "typecheck": { "dependsOn": ["^typecheck", "generate"] + }, + "publish-to-npm": { + "dependsOn": [] } } } diff --git a/packages/icons/package.json b/packages/icons/package.json index 9eb2109e4..d135416d0 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -52,5 +52,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/openapi-parser/package.json b/packages/openapi-parser/package.json index 723f6abcd..6ba681067 100644 --- a/packages/openapi-parser/package.json +++ b/packages/openapi-parser/package.json @@ -35,5 +35,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/react-contentkit/package.json b/packages/react-contentkit/package.json index 51e29ab72..fcf7a3ffa 100644 --- a/packages/react-contentkit/package.json +++ b/packages/react-contentkit/package.json @@ -35,5 +35,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/react-math/package.json b/packages/react-math/package.json index d05e0aad5..482e030bf 100644 --- a/packages/react-math/package.json +++ b/packages/react-math/package.json @@ -40,5 +40,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/packages/react-openapi/package.json b/packages/react-openapi/package.json index 546f0c180..6c31d0268 100644 --- a/packages/react-openapi/package.json +++ b/packages/react-openapi/package.json @@ -57,5 +57,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "repository": { + "url": "https://github.com/GitbookIO/gitbook" } } diff --git a/scripts/publish-if-new.sh b/scripts/publish-if-new.sh index 20c96d8b2..5af3f5b18 100755 --- a/scripts/publish-if-new.sh +++ b/scripts/publish-if-new.sh @@ -8,9 +8,6 @@ set -euo pipefail -echo "Node auth token: ${NODE_AUTH_TOKEN}" -echo "NPM config userconfig: ${NPM_CONFIG_USERCONFIG}" - NAME=$(node -p "require('./package.json').name") VERSION=$(node -p "require('./package.json').version") @@ -41,4 +38,4 @@ fi trap 'rm -f "${TARBALL_PATH}"' EXIT # Publish with verbose logging to aid debugging -npm publish "${TARBALL_PATH}" --no-workspaces --provenance --loglevel=verbose +npm publish "${TARBALL_PATH}" --no-workspaces --provenance diff --git a/turbo.json b/turbo.json index 36092d10a..d9031e75c 100644 --- a/turbo.json +++ b/turbo.json @@ -57,7 +57,7 @@ "publish-to-npm": { "dependsOn": ["build"], "cache": false, - "env": ["NODE_AUTH_TOKEN", "NPM_CONFIG_USERCONFIG", "ACTIONS_ID_TOKEN_*"] + "env": ["NODE_AUTH_TOKEN", "NPM_*", "ACTIONS_ID_TOKEN_*", "SIGSTORE_*"] }, // Clean up the package "clean": {