Skip to content

Commit 046213b

Browse files
committed
Make NPM_TOKEN optional for package release
Classic tokens are no longer supported by npm. We may still want to run the release script from a local machine using a fine-grained access token, but these tokens expire after 90 days at most and are thus not suitable for our release process. I set up OpenID Connect between the `@webref/*` packages in npm and GitHub Actions and dropped the former `NPM_TOKEN` secret. This update adjusts the release script not to fail if such a token cannot be found. The call to `npmPublish` gets adjusted accordingly only to pass the token if it exists. That should close #1739.
1 parent 67f6d77 commit 046213b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tools/release-package.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@ async function releasePackage(prNumber) {
8888

8989
console.log(`- Publish packages/${type} folder to npm`);
9090
const packageFolder = path.join(installFolder, "packages", type, "package.json");
91-
const pubResult = await npmPublish({
92-
package: packageFolder,
93-
token: NPM_TOKEN
91+
const pubOptions = {
92+
package: packageFolder
9493
//, debug: console.debug
95-
});
94+
};
95+
if (NPM_TOKEN) {
96+
pubOptions.token = NPM_TOKEN;
97+
}
98+
const pubResult = await npmPublish(pubOptions);
9699
console.log(`- Published version was ${pubResult.oldVersion}`);
97100
console.log(`- Version bump: ${pubResult.type}`);
98101
console.log(`- Published version is ${pubResult.version}`);
@@ -155,10 +158,6 @@ if (!GH_TOKEN) {
155158
}
156159

157160
const NPM_TOKEN = config?.NPM_TOKEN ?? process.env.NPM_TOKEN;
158-
if (!NPM_TOKEN) {
159-
console.error("NPM_TOKEN must be set to an npm token as an env variable or in a config.json file");
160-
process.exit(1);
161-
}
162161

163162
// Note: npm-publish has a bug and needs an "INPUT_TOKEN" env variable:
164163
// https://github.com/JS-DevTools/npm-publish/issues/15

0 commit comments

Comments
 (0)