Fix NPM publishing once and for all (#3811)

This commit is contained in:
Samy Pessé
2025-11-16 02:16:20 +01:00
committed by GitHub
parent 3d83dadb12
commit 27a461be9d
16 changed files with 43 additions and 10 deletions
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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"
},
+3
View File
@@ -29,5 +29,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -28,5 +28,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -24,5 +24,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -41,5 +41,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -40,5 +40,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -34,5 +34,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -11,6 +11,9 @@
},
"typecheck": {
"dependsOn": ["^typecheck", "generate"]
},
"publish-to-npm": {
"dependsOn": []
}
}
}
+3
View File
@@ -52,5 +52,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -35,5 +35,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -35,5 +35,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -40,5 +40,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+3
View File
@@ -57,5 +57,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"url": "https://github.com/GitbookIO/gitbook"
}
}
+1 -4
View File
@@ -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
+1 -1
View File
@@ -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": {