diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-04-02 11:25:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-02 11:25:12 -0400 |
commit | c0ee027d346191238c01d9fd35f45cc695bd1ae6 (patch) | |
tree | 69efc68445cfcdfaf823ef1b777e2cd4b842d181 | |
parent | 94885bc2932fa0e40feee877f7f68fc5e68f76c8 (diff) |
chore(ci): automatically include releases notes in release draft (#14179)
-rw-r--r-- | .github/workflows/ci.yml | 12 | ||||
-rwxr-xr-x | tools/release/01_bump_crate_versions.ts | 38 | ||||
-rwxr-xr-x | tools/release/05_create_release_notes.ts | 12 | ||||
-rw-r--r-- | tools/release/deno_workspace.ts | 8 | ||||
-rw-r--r-- | tools/release/deps.ts | 4 |
5 files changed, 41 insertions, 33 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe45bda4e..483144fcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -554,6 +554,17 @@ jobs: echo ${GITHUB_REF#refs/*/} > release-latest.txt gsutil -h "Cache-Control: no-cache" cp release-latest.txt gs://dl.deno.land/release-latest.txt + - name: Create release notes + shell: bash + if: | + matrix.job == 'test' && + matrix.profile == 'release' && + github.repository == 'denoland/deno' && + startsWith(github.ref, 'refs/tags/') + run: | + export PATH=$PATH:$(pwd)/target/release + ./tools/release/05_create_release_notes.ts + - name: Upload release to GitHub uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22 if: | @@ -570,6 +581,7 @@ jobs: target/release/deno-x86_64-apple-darwin.zip target/release/deno_src.tar.gz target/release/lib.deno.d.ts + body_path: target/release/release-notes.md draft: true publish-canary: diff --git a/tools/release/01_bump_crate_versions.ts b/tools/release/01_bump_crate_versions.ts index c87be4591..a032475fb 100755 --- a/tools/release/01_bump_crate_versions.ts +++ b/tools/release/01_bump_crate_versions.ts @@ -9,6 +9,7 @@ const cliCrate = workspace.getCliCrate(); const originalCliVersion = cliCrate.version; // update the std version used in the code +console.log("Updating std version..."); await updateStdVersion(); // increment the cli version @@ -32,6 +33,7 @@ await workspace.getCliCrate().cargoUpdate("--workspace"); // try to update the Releases.md markdown text try { + console.log("Updating Releases.md..."); await updateReleasesMd(); } catch (err) { console.error(err); @@ -43,38 +45,14 @@ try { } async function updateReleasesMd() { - const filePath = path.join(DenoWorkspace.rootDirPath, "Releases.md"); - const oldFileText = await Deno.readTextFile(filePath); - const insertText = await getReleasesMdText(); - - await Deno.writeTextFile( - filePath, - oldFileText.replace(/^### /m, insertText + "\n\n### "), - ); - - await workspace.runFormatter(); - console.log( - "Updated Release.md -- Please review the output to ensure it's correct.", - ); -} - -async function getReleasesMdText() { const gitLog = await getGitLog(); - 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}`; + const releasesMdFile = workspace.getReleasesMdFile(); + releasesMdFile.updateWithGitLog({ + version: cliCrate.version, + gitLog, + }); - function padTwoDigit(val: number) { - return val.toString().padStart(2, "0"); - } - } + await workspace.runFormatter(); } async function getGitLog() { diff --git a/tools/release/05_create_release_notes.ts b/tools/release/05_create_release_notes.ts new file mode 100755 index 000000000..7ac84de10 --- /dev/null +++ b/tools/release/05_create_release_notes.ts @@ -0,0 +1,12 @@ +#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git --no-check +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +import { path } from "./deps.ts"; +import { DenoWorkspace } from "./deno_workspace.ts"; + +const workspace = await DenoWorkspace.load(); + +// create a release notes file for the GH release draft +await Deno.writeTextFile( + path.join(DenoWorkspace.rootDirPath, "./target/release/release-notes.md"), + workspace.getReleasesMdFile().getLatestReleaseText().fullText, +); diff --git a/tools/release/deno_workspace.ts b/tools/release/deno_workspace.ts index d36a2a22f..389d8a1e1 100644 --- a/tools/release/deno_workspace.ts +++ b/tools/release/deno_workspace.ts @@ -1,6 +1,6 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { path, Repo } from "./deps.ts"; +import { path, ReleasesMdFile, Repo } from "./deps.ts"; export class DenoWorkspace { #repo: Repo; @@ -46,6 +46,12 @@ export class DenoWorkspace { return this.#repo.getCrate(name); } + getReleasesMdFile() { + return new ReleasesMdFile( + path.join(DenoWorkspace.rootDirPath, "Releases.md"), + ); + } + runFormatter() { return this.#repo.runCommandWithOutput([ "deno", diff --git a/tools/release/deps.ts b/tools/release/deps.ts index 75cc872a1..4b8d6a3c2 100644 --- a/tools/release/deps.ts +++ b/tools/release/deps.ts @@ -1,4 +1,4 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -export * from "https://raw.githubusercontent.com/denoland/automation/0.9.2/mod.ts"; -export * from "https://raw.githubusercontent.com/denoland/automation/0.9.2/github_actions.ts"; +export * from "https://raw.githubusercontent.com/denoland/automation/0.11.0/mod.ts"; +export * from "https://raw.githubusercontent.com/denoland/automation/0.11.0/github_actions.ts"; |