Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions ng-dev/release/publish/actions/renovate-config-updates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {existsSync} from 'node:fs';
import {green, Log} from '../../../utils/logging.js';
import {join} from 'node:path';
import {writeFile, readFile} from 'node:fs/promises';

/**
* Updates the `renovate.json` configuration file to include a new base branch.
*
* @param projectDir - The project directory path.
* @param newBranchName - The name of the new branch to add to the base branches list.
* @returns A promise that resolves to an string containing the path to the modified `renovate.json` file,
* or null if config updating is disabled.
*/
export async function updateRenovateConfig(
projectDir: string,
newBranchName: string,
): Promise<string | null> {
const renovateConfigPath = join(projectDir, 'renovate.json');
if (!existsSync(renovateConfigPath)) {
Log.warn(` ✘ Skipped updating Renovate config as it was not found.`);

return null;
}

const config = await readFile(renovateConfigPath, 'utf-8');
const configJson = JSON.parse(config) as Record<string, unknown>;
const baseBranches = configJson.baseBranches;
if (!Array.isArray(baseBranches) || baseBranches.length !== 2) {
Log.warn(
` ✘ Skipped updating Renovate config: "baseBranches" must contain exactly 2 branches.`,
);

return null;
}

configJson.baseBranches = ['main', newBranchName];
await writeFile(renovateConfigPath, JSON.stringify(configJson, undefined, 2));
Log.info(green(` ✓ Updated Renovate config.`));

return renovateConfigPath;
}
11 changes: 9 additions & 2 deletions ng-dev/release/publish/actions/shared/branch-off-next-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {CutNpmNextPrereleaseAction} from '../cut-npm-next-prerelease.js';
import {CutNpmNextReleaseCandidateAction} from '../cut-npm-next-release-candidate.js';
import {ActiveReleaseTrains} from '../../../versioning/active-release-trains.js';
import {updateRenovateConfig} from '../renovate-config-updates.js';

/**
* Base action that can be used to move the next release-train into the dedicated FF/RC
Expand Down Expand Up @@ -139,11 +140,17 @@ export abstract class BranchOffNextBranchBaseAction extends CutNpmNextPrerelease

// Create an individual commit for the next version bump. The changelog should go into
// a separate commit that makes it clear where the changelog is cherry-picked from.
await this.createCommit(bumpCommitMessage, [
const filesToCommit: string[] = [
workspaceRelativePackageJsonPath,
...this.getAspectLockFiles(),
]);
];

const renovateConfigPath = await updateRenovateConfig(this.projectDir, nextBranch);
if (renovateConfigPath) {
filesToCommit.push(renovateConfigPath);
}

await this.createCommit(bumpCommitMessage, filesToCommit);
await this.prependReleaseNotesToChangelog(releaseNotes);

const commitMessage = getReleaseNoteCherryPickCommitMessage(releaseNotes.version);
Expand Down