2022-07-19 16:35:58 -04:00
|
|
|
#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json
|
2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2022-03-30 16:37:00 -04:00
|
|
|
import { DenoWorkspace } from "./deno_workspace.ts";
|
2022-07-19 16:35:58 -04:00
|
|
|
import { $, createOctoKit, getGitHubRepository } from "./deps.ts";
|
2022-03-30 16:37:00 -04:00
|
|
|
|
|
|
|
const octoKit = createOctoKit();
|
|
|
|
const workspace = await DenoWorkspace.load();
|
|
|
|
const repo = workspace.repo;
|
|
|
|
const cliCrate = workspace.getCliCrate();
|
|
|
|
|
|
|
|
const originalBranch = await repo.gitCurrentBranch();
|
|
|
|
const newBranchName = `release_${cliCrate.version.replace(/\./, "_")}`;
|
|
|
|
|
|
|
|
// Create and push branch
|
2022-07-19 16:35:58 -04:00
|
|
|
$.logStep(`Creating branch ${newBranchName}...`);
|
2022-03-30 16:37:00 -04:00
|
|
|
await repo.gitBranch(newBranchName);
|
|
|
|
await repo.gitAdd();
|
|
|
|
await repo.gitCommit(cliCrate.version);
|
2022-07-19 16:35:58 -04:00
|
|
|
$.logStep("Pushing branch...");
|
2022-03-30 16:37:00 -04:00
|
|
|
await repo.gitPush("-u", "origin", "HEAD");
|
|
|
|
|
|
|
|
// Open PR
|
2022-07-19 16:35:58 -04:00
|
|
|
$.logStep("Opening PR...");
|
2022-03-30 16:37:00 -04:00
|
|
|
const openedPr = await octoKit.request("POST /repos/{owner}/{repo}/pulls", {
|
|
|
|
...getGitHubRepository(),
|
|
|
|
base: originalBranch,
|
|
|
|
head: newBranchName,
|
|
|
|
draft: true,
|
|
|
|
title: cliCrate.version,
|
|
|
|
body: getPrBody(),
|
|
|
|
});
|
2022-07-19 16:35:58 -04:00
|
|
|
$.log(`Opened PR at ${openedPr.data.url}`);
|
2022-03-30 16:37:00 -04:00
|
|
|
|
|
|
|
function getPrBody() {
|
|
|
|
let text = `Bumped versions for ${cliCrate.version}\n\n` +
|
|
|
|
`Please ensure:\n` +
|
2022-04-15 09:39:41 -04:00
|
|
|
`- [ ] Target branch is correct\n` +
|
2022-03-30 16:37:00 -04:00
|
|
|
`- [ ] Crate versions are bumped correctly\n` +
|
2022-08-29 14:19:54 -04:00
|
|
|
`- [ ] deno_std version is incremented in the code (see \`cli/deno_std.rs\`)\n` +
|
2022-03-30 16:37:00 -04:00
|
|
|
`- [ ] Releases.md is updated correctly\n\n` +
|
|
|
|
`To make edits to this PR:\n` +
|
|
|
|
"```shell\n" +
|
|
|
|
`git fetch upstream ${newBranchName} && git checkout -b ${newBranchName} upstream/${newBranchName}\n` +
|
|
|
|
"```\n";
|
|
|
|
|
|
|
|
const actor = Deno.env.get("GH_WORKFLOW_ACTOR");
|
|
|
|
if (actor != null) {
|
|
|
|
text += `\ncc @${actor}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|