Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ jobs:
run: node tools/release-package.js ${{ github.event.pull_request.number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
20 changes: 12 additions & 8 deletions tools/release-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ async function releasePackage(prNumber) {

console.log(`- Publish packages/${type} folder to npm`);
const packageFolder = path.join(installFolder, "packages", type, "package.json");
const pubResult = await npmPublish({
package: packageFolder,
token: NPM_TOKEN
const pubOptions = {
package: packageFolder
//, debug: console.debug
});
};
if (NPM_TOKEN) {
pubOptions.token = NPM_TOKEN;
}
const pubResult = await npmPublish(pubOptions);
console.log(`- Published version was ${pubResult.oldVersion}`);
console.log(`- Version bump: ${pubResult.type}`);
console.log(`- Published version is ${pubResult.version}`);
Expand Down Expand Up @@ -154,11 +157,12 @@ if (!GH_TOKEN) {
process.exit(1);
}

// An NPM token is needed to run the script from a local machine.
// Authentication from a GitHub workflow rather relies on OpenID Connect
// and the release workflow must be added as a trusted publisher for each
// npm package that can be released, see:
// https://docs.npmjs.com/trusted-publishers
const NPM_TOKEN = config?.NPM_TOKEN ?? process.env.NPM_TOKEN;
if (!NPM_TOKEN) {
console.error("NPM_TOKEN must be set to an npm token as an env variable or in a config.json file");
process.exit(1);
}

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