1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00

chore(ci): automatically include releases notes in release draft (#14179)

This commit is contained in:
David Sherret 2022-04-02 11:25:12 -04:00 committed by GitHub
parent 94885bc293
commit c0ee027d34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 33 deletions

View file

@ -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:

View file

@ -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() {

View file

@ -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,
);

View file

@ -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",

View file

@ -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";