summaryrefslogtreecommitdiff
path: root/tools/release/03_bump_cli_version.ts
blob: bd1f3d1c635369062dc8b0d0cffc7999d2eb9015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { DenoWorkspace } from "./deno_workspace.ts";

const workspace = await DenoWorkspace.load();
const repo = workspace.repo;

const cliCrate = workspace.getCliCrate();
const originalVersion = cliCrate.version;

// increment the version
await cliCrate.promptAndIncrement();
// update the lock file
await cliCrate.cargoCheck();

// 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());

async function getReleasesMdText() {
  const gitLog = await repo.getGitLogFromTags(
    "upstream",
    `v${originalVersion}`,
    undefined,
  );
  const formattedGitLog = gitLog.formatForReleaseMarkdown();
  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");
    }
  }
}