Skip to content

Commit

Permalink
🔨 Properly change package.json when generating changelog (#2791)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz authored Mar 13, 2022
1 parent 0cef964 commit e9095af
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/scripts/generate-changelog.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,17 @@ async function run({ nextVersion, shortDescription }) {
const changelogFilename = './CHANGELOG.md';
const previousContent = await readFile(changelogFilename);
await writeFile(changelogFilename, `${body}\n\n${nextVersion.endsWith('.0') ? `---\n\n` : ''}${previousContent}`);
await execFile('git', ['add', changelogFilename]);

// Update package.json
await execFile('npm', ['version', '--no-git-tag-version', nextVersion]);
await execFile('git', ['add', 'package.json']);

// Create another branch and commit on it
const branchName = `changelog-${nextVersion.replace(/\./g, '-')}-${Math.random().toString(16).substring(2)}`;
const commitName = `🔖 Update CHANGELOG.md for ${nextVersion}`;
await execFile('git', ['checkout', '-b', branchName]);
await execFile('git', ['add', changelogFilename]);
await execFile('git', ['commit', '-m', commitName]);
await execFile('npm', ['version', '--no-git-tag-version', nextVersion]);
await execFile('git', ['push', '--set-upstream', 'origin', branchName]);

// Return useful details
Expand Down

0 comments on commit e9095af

Please sign in to comment.