Skip to content

Commit

Permalink
ci: use a fork for denobot bumping versions (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Sep 19, 2023
2 parents 3112acf + 15f2f97 commit b68779b
Showing 1 changed file with 16 additions and 13 deletions.
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");
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

0 comments on commit b68779b

Please sign in to comment.