Skip to content

Commit

Permalink
Improve release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jan 16, 2024
1 parent e257ed0 commit c911303
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
dry-run:
description: "Only create a tarball, do not publish to npm or create a release on GitHub."
type: boolean
default: true
required: true

jobs:
Expand All @@ -33,6 +34,7 @@ jobs:
- run: ./scripts/release.js --version ${{ github.event.inputs.version }} ${{ github.event.inputs.dry-run == 'true' && '--dry-run' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Archive npm package tarball
uses: actions/upload-artifact@v3
Expand Down
6 changes: 4 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ if (!process.env.CI) {
exitWithError("The script should only be run in CI");
}

exec('echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc');

exec('git config --global user.name "Zihua Li"');
exec('git config --global user.email "635902+luin@users.noreply.github.com"');

Expand Down Expand Up @@ -97,7 +99,7 @@ if (index === -1) {
}
let nextVersionIndex = changelog.indexOf("\n# v", index);
if (nextVersionIndex === -1) {
nextVersionIndex = change.length - 1;
nextVersionIndex = changelog.length - 1;
}

const releaseNots = changelog
Expand All @@ -120,7 +122,7 @@ exec(`npm version ${version} --workspaces --force`);
exec("git add **/package.json");
exec(`npm version ${version} --include-workspace-root --force`);

const pushCommand = "git push --tags";
const pushCommand = `git push origin ${process.env.GITHUB_REF_NAME} --follow-tags`;
if (dryRun) {
console.log(`Skipping: "${pushCommand}" in dry-run mode`);
} else {
Expand Down

0 comments on commit c911303

Please sign in to comment.