Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
054745b
Convert `release-branches.py` to TypeScript
mbg Mar 13, 2026
aa27731
Install `node` in `release-initialise` action
mbg Mar 13, 2026
3db9a05
Replace `release-branches.py` with TS version in `release-branches` a…
mbg Mar 13, 2026
0d87a75
Refactor backport computation into `computeReleaseBranches`
mbg Mar 13, 2026
b72f4fe
Validate inputs
mbg Mar 13, 2026
49af37b
Add tests for `release-branches.ts`
mbg Mar 13, 2026
4867f59
Add config file for excluded checks from `update-required-checks.sh`
mbg Mar 13, 2026
9813849
Add initial TS implementation of `update-required-checks.sh`
mbg Mar 13, 2026
9481177
Initialise API client
mbg Mar 13, 2026
d2008ee
Add type to represent `exclusions.yml` and loading helper
mbg Mar 13, 2026
1bc611e
Fetch and filter check runs for `ref`
mbg Mar 13, 2026
a5244bf
Fetch release branches and identify major versions
mbg Mar 13, 2026
74dd691
Identify changes before applying them
mbg Mar 13, 2026
4cec5d2
Call `updateBranch` for `main`
mbg Mar 13, 2026
0543156
Actually perform the update when necessary and requested
mbg Mar 13, 2026
c5a984e
Update `CONTRIBUTING.md`
mbg Mar 13, 2026
9fe42f6
Add some unit tests for `sync-checks.ts`
mbg Mar 13, 2026
cfc1878
Rebuild
mbg Mar 16, 2026
75ed461
Add `excluded.yml` path to `config.ts`
mbg Mar 16, 2026
9fd40ff
Tidy up `pr-checks/package.json`
mbg Mar 16, 2026
07f235e
Add `--verbose` option
mbg Mar 16, 2026
0abe92e
Configure ESLint `import/no-extraneous-dependencies` rule for `pr-che…
mbg Mar 16, 2026
0da3139
Rename to `branchName`
mbg Mar 25, 2026
fa568eb
Delete `release-branches.py`
mbg Mar 25, 2026
e7c7b68
Remove `update-required-checks.sh`
mbg Mar 25, 2026
661a8fb
Default `ref` to `main`
mbg Mar 25, 2026
fae4c28
Update `CONTRIBUTING.md`
mbg Mar 25, 2026
a5418e1
Delete `releases.ini`
mbg Mar 25, 2026
8a0b4f2
fixup! Update `CONTRIBUTING.md`
mbg Mar 25, 2026
972365e
Fix comment
mbg Mar 25, 2026
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
Prev Previous commit
Next Next commit
Refactor backport computation into computeReleaseBranches
  • Loading branch information
mbg committed Mar 25, 2026
commit 0d87a7582993b7f55f7e4917950b434ff82bb9dc
87 changes: 61 additions & 26 deletions pr-checks/release-branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,57 @@ import * as core from "@actions/core";

import { OLDEST_SUPPORTED_MAJOR_VERSION } from "./config";

/** The results of checking which release branches to backport to. */
export interface BackportInfo {
/** The source release branch. */
backportSourceBranch: string;
/**
* The computed release branches we should backport to.
* Will be empty if there are no branches we need to backport to.
*/
backportTargetBranches: string[];
}

/**
* Compute the backport source and target branches for a release.
*
* @param majorVersion - The major version string (e.g. "v4").
* @param latestTag - The most recent tag published to the repository (e.g. "v4.32.6").
* @param oldestSupportedMajorVersion - The oldest supported major version number.
* @returns The names of the source branch and target branches.
*/
export function computeBackportBranches(
majorVersion: string,
latestTag: string,
oldestSupportedMajorVersion: number,
): BackportInfo {
const majorVersionNumber = Number.parseInt(majorVersion.substring(1));
const latestTagMajor = Number.parseInt(latestTag.split(".")[0].substring(1));

// If this is a primary release, we backport to all supported branches,
// so we check whether the majorVersion taken from the package.json
// is greater than or equal to the latest tag pulled from the repo.
// For example...
// 'v1' >= 'v2' is False # we're operating from an older release branch and should not backport
// 'v2' >= 'v2' is True # the normal case where we're updating the current version
// 'v3' >= 'v2' is True # in this case we are making the first release of a new major version
const considerBackports = majorVersionNumber >= latestTagMajor;

const backportSourceBranch = `releases/v${majorVersionNumber}`;
const backportTargetBranches: string[] = [];

if (considerBackports) {
for (let i = majorVersionNumber - 1; i > 0; i--) {
const branch_name = `releases/v${i}`;
if (i >= oldestSupportedMajorVersion) {
backportTargetBranches.push(branch_name);
Comment thread
mbg marked this conversation as resolved.
Outdated
}
}
}

return { backportSourceBranch, backportTargetBranches };
}

async function main() {
const { values: options } = parseArgs({
options: {
Expand All @@ -28,38 +79,22 @@ async function main() {
throw Error("--latest-tag is required");
}

const majorVersion = Number.parseInt(options["major-version"].substring(1));
const majorVersion = options["major-version"];
const latestTag = options["latest-tag"];

console.log(`major_version: v${majorVersion}`);
console.log(`latest_tag: ${latestTag}`);

// If this is a primary release, we backport to all supported branches,
// so we check whether the major_version taken from the package.json
// is greater than or equal to the latest tag pulled from the repo.
// For example...
// 'v1' >= 'v2' is False # we're operating from an older release branch and should not backport
// 'v2' >= 'v2' is True # the normal case where we're updating the current version
// 'v3' >= 'v2' is True # in this case we are making the first release of a new major version
const latestTagMajor = Number.parseInt(latestTag.split(".")[0].substring(1));
const considerBackports = majorVersion >= latestTagMajor;

core.setOutput("backport_source_branch", `releases/v${majorVersion}`);

const backportTargetBranches: string[] = [];
console.log(`Major version: ${majorVersion}`);
console.log(`Latest tag: ${latestTag}`);

if (considerBackports) {
for (let i = latestTagMajor - 1; i > 0; i--) {
const branch_name = `releases/v${i}`;
if (i >= OLDEST_SUPPORTED_MAJOR_VERSION) {
backportTargetBranches.push(branch_name);
}
}
}
const result = computeBackportBranches(
majorVersion,
latestTag,
OLDEST_SUPPORTED_MAJOR_VERSION,
);

core.setOutput("backport_source_branch", result.backportSourceBranch);
core.setOutput(
"backport_target_branches",
JSON.stringify(backportTargetBranches),
JSON.stringify(result.backportTargetBranches),
);

process.exit(0);
Expand Down