Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use a fork for denobot bumping versions #126

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions .github/workflows/update_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ interface ReplacementsData {
}

const replacementsFile = $.path("replacements.json");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think I can try running this before merging. One second.

const latestCliTag = await getLatestTagForRepo("deno");
const latestStdTag = await getLatestTagForRepo("deno_std");
const latestCliVersion = (await getLatestTagForRepo("deno")).replace("v", "");
const latestStdVersion = await getLatestTagForRepo("deno_std");

$.log(`cli tag: ${latestCliTag}`);
$.log(`std tag: ${latestStdTag}`);
$.log(`cli version: ${latestCliVersion}`);
$.log(`std version: ${latestStdVersion}`);

const replacements = replacementsFile.readJsonSync<ReplacementsData>();

replacements.CLI_VERSION = latestCliTag;
replacements.STD_VERSION = latestStdTag;
replacements.CLI_VERSION = latestCliVersion;
replacements.STD_VERSION = latestStdVersion;

replacementsFile.writeJsonPrettySync(replacements);

Expand Down Expand Up @@ -49,31 +49,34 @@ async function tryCreatePr() {
}

// commit and push
const branchName = `bump_version${latestCliTag}`;
const commitMessage = `Updated files for ${latestCliTag}`;
const branchName = `bump_version${latestCliVersion}`;
const commitMessage = `Updated files for ${latestCliVersion}`;
await $`git checkout -b ${branchName}`;
await $`git commit -m ${commitMessage}`;
await $`git remote add denobot https://github.com/denobot/deno-docs`;
$.logStep("Pushing branch...");
await $`git push -u origin HEAD`;
// note: if this push fails because of not having a "workflow" PAT permission,
// just ensure that denobot's main branch is synced with this repo
await $`git push -u denobot HEAD`;

// open a PR
$.logStep("Opening PR...");
const octoKit = createOctoKit();
const openedPr = await octoKit.request("POST /repos/{owner}/{repo}/pulls", {
...getGitHubRepository(),
base: "main",
head: branchName,
head: `denobot:${branchName}`,
draft: false,
title: `chore: update for ${latestCliTag}`,
title: `chore: update for ${latestCliVersion}`,
body: getPrBody(),
});
$.log(`Opened PR at ${openedPr.data.url}`);

function getPrBody() {
let text = `Bumped versions for ${latestCliTag}\n\n` +
let text = `Bumped versions for ${latestCliVersion}\n\n` +
`To make edits to this PR:\n` +
"```shell\n" +
`git fetch upstream ${branchName} && git checkout -b ${branchName} upstream/${branchName}\n` +
`gh pr checkout <THIS PR NUMBER>\n` +
"```\n";

const actor = Deno.env.get("GH_WORKFLOW_ACTOR");
Expand Down