summaryrefslogtreecommitdiff
path: root/tools/release
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-07-19 16:35:58 -0400
committerGitHub <noreply@github.com>2022-07-19 16:35:58 -0400
commit9b4ae0868d5f5a5ef1d49843737f950bbb841cbf (patch)
treeb3c2f77809b8e8f7c556fa413e54be26f0b5a17c /tools/release
parent1bdf5a2081b1567ed73d8f85edae53c3f9724e2b (diff)
chore: update deno automation to 0.12 (#15248)
Diffstat (limited to 'tools/release')
-rwxr-xr-xtools/release/01_bump_crate_versions.ts16
-rwxr-xr-xtools/release/02_create_pr.ts12
-rwxr-xr-xtools/release/03_publish_crates.ts35
-rwxr-xr-xtools/release/04_post_publish.ts29
-rwxr-xr-xtools/release/05_create_release_notes.ts6
-rw-r--r--tools/release/deno_workspace.ts22
-rw-r--r--tools/release/deps.ts4
7 files changed, 47 insertions, 77 deletions
diff --git a/tools/release/01_bump_crate_versions.ts b/tools/release/01_bump_crate_versions.ts
index b2d160fc6..d2446d44c 100755
--- a/tools/release/01_bump_crate_versions.ts
+++ b/tools/release/01_bump_crate_versions.ts
@@ -1,7 +1,7 @@
-#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git,deno --allow-net --no-check --lock=tools/deno.lock.json
+#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { DenoWorkspace } from "./deno_workspace.ts";
-import { GitLogOutput, path, semver } from "./deps.ts";
+import { $, GitLogOutput, semver } from "./deps.ts";
const workspace = await DenoWorkspace.load();
const repo = workspace.repo;
@@ -25,7 +25,7 @@ for (const crate of workspace.getCliDependencyCrates()) {
}
// update the std version used in the code
-console.log("Updating std version...");
+$.logStep("Updating std version...");
await updateStdVersion();
// update the lock file
@@ -33,12 +33,12 @@ await workspace.getCliCrate().cargoUpdate("--workspace");
// try to update the Releases.md markdown text
try {
- console.log("Updating Releases.md...");
+ $.logStep("Updating Releases.md...");
await updateReleasesMd();
} catch (err) {
- console.error(err);
- console.error(
- "Updating Releases.md failed. Please manually run " +
+ $.log(err);
+ $.logError(
+ "Error Updating Releases.md failed. Please manually run " +
"`git log --oneline VERSION_FROM..VERSION_TO` and " +
"use the output to update Releases.md",
);
@@ -97,7 +97,7 @@ async function getGitLog() {
}
async function updateStdVersion() {
- const compatFilePath = path.join(cliCrate.folderPath, "compat/mod.rs");
+ const compatFilePath = $.path.join(cliCrate.folderPath, "compat/mod.rs");
const text = await Deno.readTextFile(compatFilePath);
const versionRe = /std@([0-9]+\.[0-9]+\.[0-9]+)/;
const stdVersionText = versionRe.exec(text)?.[1];
diff --git a/tools/release/02_create_pr.ts b/tools/release/02_create_pr.ts
index 165dc3d34..0c0ab7b73 100755
--- a/tools/release/02_create_pr.ts
+++ b/tools/release/02_create_pr.ts
@@ -1,7 +1,7 @@
-#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run=cargo,git --no-check --lock=tools/deno.lock.json
+#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { DenoWorkspace } from "./deno_workspace.ts";
-import { createOctoKit, getGitHubRepository } from "./deps.ts";
+import { $, createOctoKit, getGitHubRepository } from "./deps.ts";
const octoKit = createOctoKit();
const workspace = await DenoWorkspace.load();
@@ -12,15 +12,15 @@ const originalBranch = await repo.gitCurrentBranch();
const newBranchName = `release_${cliCrate.version.replace(/\./, "_")}`;
// Create and push branch
-console.log(`Creating branch ${newBranchName}...`);
+$.logStep(`Creating branch ${newBranchName}...`);
await repo.gitBranch(newBranchName);
await repo.gitAdd();
await repo.gitCommit(cliCrate.version);
-console.log("Pushing branch...");
+$.logStep("Pushing branch...");
await repo.gitPush("-u", "origin", "HEAD");
// Open PR
-console.log("Opening PR...");
+$.logStep("Opening PR...");
const openedPr = await octoKit.request("POST /repos/{owner}/{repo}/pulls", {
...getGitHubRepository(),
base: originalBranch,
@@ -29,7 +29,7 @@ const openedPr = await octoKit.request("POST /repos/{owner}/{repo}/pulls", {
title: cliCrate.version,
body: getPrBody(),
});
-console.log(`Opened PR at ${openedPr.data.url}`);
+$.log(`Opened PR at ${openedPr.data.url}`);
function getPrBody() {
let text = `Bumped versions for ${cliCrate.version}\n\n` +
diff --git a/tools/release/03_publish_crates.ts b/tools/release/03_publish_crates.ts
index 0becd3d26..4e149d3b9 100755
--- a/tools/release/03_publish_crates.ts
+++ b/tools/release/03_publish_crates.ts
@@ -1,10 +1,9 @@
-#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo --allow-net=crates.io --no-check --lock=tools/deno.lock.json
+#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { DenoWorkspace } from "./deno_workspace.ts";
-import { Crate, getCratesPublishOrder } from "./deps.ts";
+import { $, getCratesPublishOrder } from "./deps.ts";
-const isReal = parseIsReal();
-console.log(`Running a ${isReal ? "real" : "dry"} cargo publish...`);
+$.logStep(`Running cargo publish...`);
const workspace = await DenoWorkspace.load();
const cliCrate = workspace.getCliCrate();
@@ -15,34 +14,12 @@ const dependencyCrates = getCratesPublishOrder(
try {
for (const [i, crate] of dependencyCrates.entries()) {
- await publishCrate(crate);
- console.log(`Finished ${i + 1} of ${dependencyCrates.length} crates.`);
+ await crate.publish();
+ $.log(`Finished ${i + 1} of ${dependencyCrates.length} crates.`);
}
- await publishCrate(cliCrate);
+ await cliCrate.publish();
} finally {
// system beep to notify error or completion
console.log("\x07");
}
-
-async function publishCrate(crate: Crate) {
- if (isReal) {
- await crate.publish();
- } else {
- await crate.publishDryRun();
- }
-}
-
-function parseIsReal() {
- const isReal = Deno.args.some((a) => a === "--real");
- const isDry = Deno.args.some((a) => a === "--dry");
-
- // force the call to be explicit and provide one of these
- // so that it's obvious what's happening
- if (!isDry && !isReal) {
- console.error("Please run with `--dry` or `--real`.");
- Deno.exit(1);
- }
-
- return isReal;
-}
diff --git a/tools/release/04_post_publish.ts b/tools/release/04_post_publish.ts
index 228bd775c..03b005db5 100755
--- a/tools/release/04_post_publish.ts
+++ b/tools/release/04_post_publish.ts
@@ -1,20 +1,20 @@
-#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git --allow-net --allow-env --no-check --lock=tools/deno.lock.json
+#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { DenoWorkspace } from "./deno_workspace.ts";
-import { createOctoKit, getGitHubRepository } from "./deps.ts";
+import { $, createOctoKit, getGitHubRepository } from "./deps.ts";
const workspace = await DenoWorkspace.load();
const repo = workspace.repo;
const cliCrate = workspace.getCliCrate();
-console.log("Creating release tag...");
+$.logStep("Creating release tag...");
await createReleaseTag();
-console.log("Forwarding release commit to main...");
+$.logStep("Forwarding release commit to main...");
try {
await forwardReleaseCommitToMain();
} catch (err) {
- console.error("Failed. Please manually open a PR.", err);
+ $.logError("Failed. Please manually open a PR.", err);
}
async function createReleaseTag() {
@@ -23,7 +23,7 @@ async function createReleaseTag() {
const tagName = `v${cliCrate.version}`;
if (tags.has(tagName)) {
- console.log(`Tag ${tagName} already exists.`);
+ $.log(`Tag ${tagName} already exists.`);
} else {
await repo.gitTag(tagName);
await repo.gitPush("origin", tagName);
@@ -36,23 +36,22 @@ async function forwardReleaseCommitToMain() {
const isPatchRelease = currentBranch !== "main";
if (!isPatchRelease) {
- console.log("Not doing a patch release. Skipping.");
+ $.log("Not doing a patch release. Skipping.");
return;
}
- await repo.runCommandWithOutput(["git", "fetch", "origin", "main"]);
- const releaseCommitHash =
- (await repo.runCommand(["git", "rev-parse", "HEAD"])).trim();
+ await repo.command("git fetch origin main");
+ const releaseCommitHash = await repo.command("git rev-parse HEAD").text();
const newBranchName = `forward_v${cliCrate.version}`;
- console.log(`Creating branch ${newBranchName}...`);
- await repo.runCommand([
+ $.logStep(`Creating branch ${newBranchName}...`);
+ await repo.command([
"git",
"checkout",
"-b",
newBranchName,
"origin/main",
]);
- await repo.runCommand([
+ await repo.command([
"git",
"cherry-pick",
"--strategy-option",
@@ -61,7 +60,7 @@ async function forwardReleaseCommitToMain() {
]);
await repo.gitPush("origin", newBranchName);
- console.log(`Opening PR...`);
+ $.logStep(`Opening PR...`);
const openedPr = await createOctoKit().request(
"POST /repos/{owner}/{repo}/pulls",
{
@@ -73,7 +72,7 @@ async function forwardReleaseCommitToMain() {
body: getPrBody(),
},
);
- console.log(`Opened PR at ${openedPr.data.url}`);
+ $.log(`Opened PR at ${openedPr.data.url}`);
function getPrBody() {
let text =
diff --git a/tools/release/05_create_release_notes.ts b/tools/release/05_create_release_notes.ts
index af3330953..26667b5ef 100755
--- a/tools/release/05_create_release_notes.ts
+++ b/tools/release/05_create_release_notes.ts
@@ -1,12 +1,12 @@
-#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=cargo,git --no-check --lock=tools/deno.lock.json
+#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-import { path } from "./deps.ts";
+import { $ } 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"),
+ $.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 2ffac6cca..892986ac0 100644
--- a/tools/release/deno_workspace.ts
+++ b/tools/release/deno_workspace.ts
@@ -1,13 +1,13 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-import { path, ReleasesMdFile, Repo } from "./deps.ts";
+import { $, ReleasesMdFile, Repo } from "./deps.ts";
export class DenoWorkspace {
#repo: Repo;
static get rootDirPath() {
- const currentDirPath = path.dirname(path.fromFileUrl(import.meta.url));
- return path.resolve(currentDirPath, "../../");
+ const currentDirPath = $.path.dirname($.path.fromFileUrl(import.meta.url));
+ return $.path.resolve(currentDirPath, "../../");
}
static async load(): Promise<DenoWorkspace> {
@@ -48,19 +48,13 @@ export class DenoWorkspace {
getReleasesMdFile() {
return new ReleasesMdFile(
- path.join(DenoWorkspace.rootDirPath, "Releases.md"),
+ $.path.join(DenoWorkspace.rootDirPath, "Releases.md"),
);
}
- runFormatter() {
- return this.#repo.runCommandWithOutput([
- "deno",
- "run",
- "--unstable",
- "--allow-write",
- "--allow-read",
- "--allow-run",
- "./tools/format.js",
- ]);
+ async runFormatter() {
+ await this.#repo.command(
+ "deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js",
+ );
}
}
diff --git a/tools/release/deps.ts b/tools/release/deps.ts
index 4b8d6a3c2..5c33e6548 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.11.0/mod.ts";
-export * from "https://raw.githubusercontent.com/denoland/automation/0.11.0/github_actions.ts";
+export * from "https://raw.githubusercontent.com/denoland/automation/0.12.1/mod.ts";
+export * from "https://raw.githubusercontent.com/denoland/automation/0.12.1/github_actions.ts";