diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-25 09:02:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 09:02:22 -0400 |
commit | dce70d32a47801025b3b67a97ec9ebed90dfc8a2 (patch) | |
tree | f08176bdad18f931956f24cd7d3b92ba313c4493 /tools/release/03_bump_cli_version.ts | |
parent | dccf4cbe36d66140f9e35a6ee755c3c440d745f9 (diff) |
chore: add scripts for helping with a release (#11832)
Diffstat (limited to 'tools/release/03_bump_cli_version.ts')
-rw-r--r-- | tools/release/03_bump_cli_version.ts | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/release/03_bump_cli_version.ts b/tools/release/03_bump_cli_version.ts new file mode 100644 index 000000000..5ecf3bf6e --- /dev/null +++ b/tools/release/03_bump_cli_version.ts @@ -0,0 +1,55 @@ +#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run="cargo,git" +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +import { + DenoWorkspace, + formatGitLogForMarkdown, + getGitLogFromTag, +} from "./helpers/mod.ts"; + +const workspace = await DenoWorkspace.load(); + +const cliCrate = workspace.getCliCrate(); +const originalVersion = cliCrate.version; + +// increment the version +await cliCrate.increment(getVersionIncrement()); + +// output the Releases.md markdown text +console.log( + "You may use the following as a template for updating Releases.md:\n", +); +console.log(await getReleasesMdText()); + +function getVersionIncrement() { + if (confirm("Increment patch?")) { + return "patch"; + } else if (confirm("Increment minor?")) { + return "minor"; + } else if (confirm("Increment major?")) { + return "major"; + } else { + throw new Error("No decision."); + } +} + +async function getReleasesMdText() { + const gitLogOutput = await getGitLogFromTag( + DenoWorkspace.rootDirPath, + `v${originalVersion}`, + ); + const formattedGitLog = formatGitLogForMarkdown(gitLogOutput); + const formattedDate = getFormattedDate(new Date()); + + return `### ${cliCrate.version} / ${formattedDate}\n\n` + + `${formattedGitLog}`; + + function getFormattedDate(date: Date) { + const formattedMonth = padTwoDigit(date.getMonth() + 1); + const formattedDay = padTwoDigit(date.getDate()); + return `${date.getFullYear()}.${formattedMonth}.${formattedDay}`; + + function padTwoDigit(val: number) { + return val.toString().padStart(2, "0"); + } + } +} |