Skip to content

Commit 5a1ad1d

Browse files
committed
fix(ng-dev): remove renovate target label update during release
The logic to update the renovate config during the release to switch the target labels from `target: rc` to `target: patch` has been removed. Instead, a static `target: automation` label is added to the default renovate preset. This simplifies the release process by removing the need to update the renovate config during the release.
1 parent 0f0f951 commit 5a1ad1d

File tree

5 files changed

+1
-104
lines changed

5 files changed

+1
-104
lines changed

ng-dev/release/publish/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ ts_project(
1818
"//ng-dev:node_modules/semver",
1919
"//ng-dev:node_modules/typed-graphqlify",
2020
"//ng-dev/commit-message",
21-
"//ng-dev/pr/common/labels",
2221
"//ng-dev/pr/merge",
2322
"//ng-dev/release/build",
2423
"//ng-dev/release/config",

ng-dev/release/publish/actions.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import {promptToInitiatePullRequestMerge} from './prompt-merge.js';
4343
import {Prompt} from '../../utils/prompt.js';
4444
import {PnpmVersioning} from './pnpm-versioning.js';
4545
import {Commit} from '../../utils/git/octokit-types.js';
46-
import {updateRenovateConfigTargetLabels} from './actions/renovate-config-updates.js';
47-
import {targetLabels} from '../../pr/common/labels/target.js';
4846

4947
/** Interface describing a Github repository. */
5048
export interface GithubRepo {
@@ -567,19 +565,6 @@ export abstract class ReleaseAction {
567565

568566
const filesToCommit: string[] = [workspaceRelativeChangelogPath];
569567

570-
if (version.patch === 0 && version.prerelease.length === 0) {
571-
// Switch the renovate labels for `target: rc` to `target: patch`
572-
const renovateConfigPath = await updateRenovateConfigTargetLabels(
573-
this.projectDir,
574-
targetLabels['TARGET_RC'].name,
575-
targetLabels['TARGET_PATCH'].name,
576-
);
577-
578-
if (renovateConfigPath) {
579-
filesToCommit.push(renovateConfigPath);
580-
}
581-
}
582-
583568
await this.createCommit(commitMessage, filesToCommit);
584569
Log.info(green(` ✓ Created changelog cherry-pick commit for: "${version}".`));
585570

ng-dev/release/publish/actions/renovate-config-updates.ts

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {existsSync} from 'node:fs';
22
import {green, Log} from '../../../utils/logging.js';
33
import {join} from 'node:path';
44
import {writeFile, readFile} from 'node:fs/promises';
5-
import {targetLabels} from '../../../pr/common/labels/target.js';
65

76
/**
87
* Updates the `renovate.json` configuration file to include a new base branch.
@@ -37,92 +36,8 @@ export async function updateRenovateConfig(
3736

3837
configJson['baseBranchPatterns'] = ['main', newBranchName];
3938

40-
updateRenovateTargetLabel(
41-
configJson,
42-
targetLabels['TARGET_PATCH'].name,
43-
targetLabels['TARGET_RC'].name,
44-
);
4539
await writeFile(renovateConfigPath, JSON.stringify(configJson, undefined, 2));
4640

4741
Log.info(green(` ✓ Updated Renovate config.`));
4842
return renovateConfigPath;
4943
}
50-
51-
/**
52-
* Updates a specific target label in the `renovate.json` configuration file.
53-
* This function specifically targets and replaces one label with another within the `packageRules`.
54-
*
55-
* @param projectDir - The path to the project directory.
56-
* @param fromLabel - The label name to be replaced.
57-
* @param toLabel - The new label name to replace `fromLabel` with.
58-
* @returns A promise that resolves to the path of the modified `renovate.json` file if updated,
59-
* or `null` if the file was not found or the `baseBranchPatterns` array has an unexpected format.
60-
*/
61-
export async function updateRenovateConfigTargetLabels(
62-
projectDir: string,
63-
fromLabel: string,
64-
toLabel: string,
65-
): Promise<string | null> {
66-
const renovateConfigPath = join(projectDir, 'renovate.json');
67-
if (!existsSync(renovateConfigPath)) {
68-
Log.warn(` ✘ Skipped updating Renovate config as it was not found.`);
69-
70-
return null;
71-
}
72-
73-
const config = await readFile(renovateConfigPath, 'utf-8');
74-
const configJson = JSON.parse(config) as Record<string, unknown>;
75-
76-
// Check baseBranchPatterns just in case, though this function's primary focus is labels
77-
const baseBranchPatterns = configJson['baseBranchPatterns'];
78-
if (!Array.isArray(baseBranchPatterns) || baseBranchPatterns.length !== 2) {
79-
Log.warn(
80-
` ✘ Skipped updating Renovate config: "baseBranchPatterns" must contain exactly 2 branches.`,
81-
);
82-
83-
return null;
84-
}
85-
86-
if (updateRenovateTargetLabel(configJson, fromLabel, toLabel)) {
87-
await writeFile(renovateConfigPath, JSON.stringify(configJson, undefined, 2));
88-
Log.info(green(` ✓ Updated target label in Renovate config.`));
89-
90-
return renovateConfigPath;
91-
} else {
92-
Log.info(green(` ✓ No changes to target labels in Renovate config.`));
93-
return null;
94-
}
95-
}
96-
97-
/**
98-
* Updates a specific target label within the `packageRules` of a Renovate configuration.
99-
*
100-
* @param configJson - The parsed JSON object of the Renovate configuration.
101-
* @param fromLabel - The label name to be replaced.
102-
* @param toLabel - The new label name to replace `fromLabel` with.
103-
* @returns `true` is the label has been updated, otherwise `false`.
104-
*/
105-
function updateRenovateTargetLabel(
106-
configJson: Record<string, unknown>,
107-
fromLabel: string,
108-
toLabel: string,
109-
): boolean {
110-
if (!Array.isArray(configJson['packageRules'])) {
111-
return false;
112-
}
113-
114-
let updated = false;
115-
for (const rule of configJson['packageRules']) {
116-
if (!Array.isArray(rule.addLabels)) {
117-
continue;
118-
}
119-
120-
const idx = (rule.addLabels as string[]).findIndex((x) => x === fromLabel);
121-
if (idx >= 0) {
122-
rule.addLabels[idx] = toLabel;
123-
updated = true;
124-
}
125-
}
126-
127-
return updated;
128-
}

ng-dev/release/publish/test/common.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,9 @@ describe('common release action logic', () => {
617617
'packageRules': [
618618
{
619619
'matchBaseBranches': ['main'],
620-
'addLabels': ['target: minor'],
621620
},
622621
{
623622
'matchBaseBranches': ['!main'],
624-
'addLabels': ['target: rc'],
625623
},
626624
],
627625
}),

renovate-presets/default.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
semanticCommits: 'enabled',
1717
semanticCommitScope: '',
1818
semanticCommitType: 'build',
19-
labels: ['area: build & ci', 'action: merge'],
19+
labels: ['area: build & ci', 'action: merge', 'target: automation'],
2020

2121
lockFileMaintenance: {
2222
enabled: true,

0 commit comments

Comments
 (0)