diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe45bda4e6..483144fcfb 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 c87be4591d..a032475fb2 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### "), - ); + const gitLog = await getGitLog(); + const releasesMdFile = workspace.getReleasesMdFile(); + releasesMdFile.updateWithGitLog({ + version: cliCrate.version, + gitLog, + }); 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}`; - - function padTwoDigit(val: number) { - return val.toString().padStart(2, "0"); - } - } } 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 0000000000..7ac84de108 --- /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 d36a2a22fc..389d8a1e1a 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 75cc872a12..4b8d6a3c2c 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";