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:
parent
94885bc293
commit
c0ee027d34
5 changed files with 41 additions and 33 deletions
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
|
@ -554,6 +554,17 @@ jobs:
|
||||||
echo ${GITHUB_REF#refs/*/} > release-latest.txt
|
echo ${GITHUB_REF#refs/*/} > release-latest.txt
|
||||||
gsutil -h "Cache-Control: no-cache" cp release-latest.txt gs://dl.deno.land/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
|
- name: Upload release to GitHub
|
||||||
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
|
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
|
||||||
if: |
|
if: |
|
||||||
|
@ -570,6 +581,7 @@ jobs:
|
||||||
target/release/deno-x86_64-apple-darwin.zip
|
target/release/deno-x86_64-apple-darwin.zip
|
||||||
target/release/deno_src.tar.gz
|
target/release/deno_src.tar.gz
|
||||||
target/release/lib.deno.d.ts
|
target/release/lib.deno.d.ts
|
||||||
|
body_path: target/release/release-notes.md
|
||||||
draft: true
|
draft: true
|
||||||
|
|
||||||
publish-canary:
|
publish-canary:
|
||||||
|
|
|
@ -9,6 +9,7 @@ const cliCrate = workspace.getCliCrate();
|
||||||
const originalCliVersion = cliCrate.version;
|
const originalCliVersion = cliCrate.version;
|
||||||
|
|
||||||
// update the std version used in the code
|
// update the std version used in the code
|
||||||
|
console.log("Updating std version...");
|
||||||
await updateStdVersion();
|
await updateStdVersion();
|
||||||
|
|
||||||
// increment the cli version
|
// increment the cli version
|
||||||
|
@ -32,6 +33,7 @@ await workspace.getCliCrate().cargoUpdate("--workspace");
|
||||||
|
|
||||||
// try to update the Releases.md markdown text
|
// try to update the Releases.md markdown text
|
||||||
try {
|
try {
|
||||||
|
console.log("Updating Releases.md...");
|
||||||
await updateReleasesMd();
|
await updateReleasesMd();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -43,38 +45,14 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateReleasesMd() {
|
async function updateReleasesMd() {
|
||||||
const filePath = path.join(DenoWorkspace.rootDirPath, "Releases.md");
|
const gitLog = await getGitLog();
|
||||||
const oldFileText = await Deno.readTextFile(filePath);
|
const releasesMdFile = workspace.getReleasesMdFile();
|
||||||
const insertText = await getReleasesMdText();
|
releasesMdFile.updateWithGitLog({
|
||||||
|
version: cliCrate.version,
|
||||||
await Deno.writeTextFile(
|
gitLog,
|
||||||
filePath,
|
});
|
||||||
oldFileText.replace(/^### /m, insertText + "\n\n### "),
|
|
||||||
);
|
|
||||||
|
|
||||||
await workspace.runFormatter();
|
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() {
|
async function getGitLog() {
|
||||||
|
|
12
tools/release/05_create_release_notes.ts
Executable file
12
tools/release/05_create_release_notes.ts
Executable 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,
|
||||||
|
);
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// 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 {
|
export class DenoWorkspace {
|
||||||
#repo: Repo;
|
#repo: Repo;
|
||||||
|
@ -46,6 +46,12 @@ export class DenoWorkspace {
|
||||||
return this.#repo.getCrate(name);
|
return this.#repo.getCrate(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getReleasesMdFile() {
|
||||||
|
return new ReleasesMdFile(
|
||||||
|
path.join(DenoWorkspace.rootDirPath, "Releases.md"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
runFormatter() {
|
runFormatter() {
|
||||||
return this.#repo.runCommandWithOutput([
|
return this.#repo.runCommandWithOutput([
|
||||||
"deno",
|
"deno",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// 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.11.0/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/github_actions.ts";
|
||||||
|
|
Loading…
Reference in a new issue