2022-08-08 19:31:45 -04:00
|
|
|
#!/usr/bin/env -S deno run -A --quiet --lock=tools/deno.lock.json
|
2022-08-06 09:45:34 -04:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { $, createOctoKit, semver } from "./deps.ts";
|
|
|
|
|
2022-08-08 19:31:45 -04:00
|
|
|
const currentDirPath = $.path.dirname($.path.fromFileUrl(import.meta.url));
|
|
|
|
|
|
|
|
$.logStep("Getting next version...");
|
|
|
|
const nextVersion = getNextVersion(semver.parse(getCliVersion())!);
|
2022-08-06 09:45:34 -04:00
|
|
|
|
|
|
|
$.logStep("Creating gist with instructions...");
|
|
|
|
const octoKit = createOctoKit();
|
|
|
|
const result = await octoKit.request("POST /gists", {
|
2022-08-08 19:31:45 -04:00
|
|
|
description: `Deno CLI v${nextVersion} release checklist`,
|
2022-08-06 09:45:34 -04:00
|
|
|
public: false,
|
|
|
|
files: {
|
2022-08-08 19:31:45 -04:00
|
|
|
[`release_${nextVersion}.md`]: {
|
2022-08-06 09:45:34 -04:00
|
|
|
content: buildDenoReleaseInstructionsDoc(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
$.log("==============================================");
|
|
|
|
$.log("Created gist with instructions!");
|
|
|
|
$.log("");
|
2022-08-08 19:31:45 -04:00
|
|
|
$.log(` ${result.data.html_url}`);
|
2022-08-06 09:45:34 -04:00
|
|
|
$.log("");
|
|
|
|
$.log("Please fork the gist and follow the checklist.");
|
|
|
|
$.log("==============================================");
|
|
|
|
|
|
|
|
function getNextVersion(originalVersion: semver.SemVer) {
|
|
|
|
if (Deno.args.some((a) => a === "--patch")) {
|
|
|
|
return originalVersion.inc("patch");
|
|
|
|
} else if (Deno.args.some((a) => a === "--minor")) {
|
|
|
|
return originalVersion.inc("minor");
|
|
|
|
} else if (Deno.args.some((a) => a === "--major")) {
|
|
|
|
return originalVersion.inc("major");
|
|
|
|
} else {
|
|
|
|
throw new Error("Missing argument");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildDenoReleaseInstructionsDoc() {
|
|
|
|
const templateText = Deno.readTextFileSync(
|
|
|
|
$.path.join(currentDirPath, "release_doc_template.md"),
|
|
|
|
);
|
|
|
|
return `# Deno CLI ${nextVersion.toString()} Release Checklist\n\n${templateText}`;
|
|
|
|
}
|
2022-08-08 19:31:45 -04:00
|
|
|
|
|
|
|
function getCliVersion() {
|
|
|
|
const cargoTomlText = Deno.readTextFileSync(
|
|
|
|
$.path.join(currentDirPath, "../../cli/Cargo.toml"),
|
|
|
|
);
|
|
|
|
const result = cargoTomlText.match(/^version\s*=\s*"([^"]+)"$/m);
|
|
|
|
if (result == null || result.length !== 2) {
|
|
|
|
$.log("Cargo.toml");
|
|
|
|
$.log("==========");
|
|
|
|
$.log(cargoTomlText);
|
|
|
|
$.log("==========");
|
|
|
|
throw new Error("Could not find version in text.");
|
|
|
|
}
|
|
|
|
return result[1];
|
|
|
|
}
|