Skip to content

Commit

Permalink
[release script] Update changelog script
Browse files Browse the repository at this point in the history
  • Loading branch information
duailibe committed Jun 7, 2019
1 parent 4483282 commit 277b92a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 367 deletions.
1 change: 0 additions & 1 deletion scripts/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"execa": "0.10.0",
"minimist": "1.2.0",
"node-fetch": "2.1.2",
"prs-merged-since": "1.0.1",
"semver": "5.5.0",
"string-width": "2.1.1"
}
Expand Down
34 changes: 3 additions & 31 deletions scripts/release/steps/update-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const chalk = require("chalk");
const dedent = require("dedent");
const execa = require("execa");
const fs = require("fs");
const prsMergedSince = require("prs-merged-since");
const semver = require("semver");
const { logPromise, waitForEnter } = require("../utils");
const { waitForEnter } = require("../utils");

function getBlogPostInfo(version) {
const date = new Date();
Expand All @@ -20,17 +19,6 @@ function getBlogPostInfo(version) {
};
}

async function getMergedPrs(previousVersion) {
const prs = await prsMergedSince({
repo: "prettier/prettier",
tag: previousVersion,
githubApiToken: process.env.GITHUB_API_TOKEN
});
return prs
.map(pr => `- ${pr.title} ([#${pr.number}](${pr.html_url}))`)
.join("\n");
}

function writeChangelog({ version, previousVersion, releaseNotes }) {
const changelog = fs.readFileSync("CHANGELOG.md", "utf-8");
const newEntry = dedent`
Expand Down Expand Up @@ -65,28 +53,12 @@ module.exports = async function({ version, previousVersion }) {
`)
);
} else {
if (!process.env.GITHUB_API_TOKEN) {
console.log(
chalk`{yellow warning} GitHub API access token missing. You can expose a token via {bold GITHUB_API_TOKEN} environment variable.`
);
}

const releaseNotes = await logPromise(
"Fetching merged PRs",
getMergedPrs(previousVersion)
);
writeChangelog({
version,
previousVersion,
releaseNotes
});
console.log();
console.log(
dedent(chalk`
{yellow.bold A manual step is necessary.}
The script has updated the file {bold CHANGELOG.md} with all the merged PRs since the last release.
You must edit it to focus only on relevant changes and make sure they have meaningful titles.
You can copy the entries from {bold CHANGELOG.unreleased.md} to {bold CHANGELOG.md}
and update it accordingly.
You don't need to commit the file, the script will take care of that.
Expand Down

0 comments on commit 277b92a

Please sign in to comment.