Skip to content

Commit fe56be4

Browse files
authored
fix: append target to release creation [main] (#296)
2 parents 6392b45 + d3f1402 commit fe56be4

4 files changed

Lines changed: 23 additions & 19 deletions

File tree

scripts/release/gh-release-atlas-core.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = async function createAtlasCoreModule() {
4646
`No unreleased changes found in the CHANGELOG.md for ${moduleInfo.nameWithSpace} ${moduleInfo.version}.`
4747
);
4848
}
49-
await commitAndCreatePullRequest(moduleInfo);
49+
const targetBranchName = await commitAndCreatePullRequest(moduleInfo);
5050
await updateTestProject(moduleInfo, testProject, tmp);
5151

5252
const mpkOutput = await createMPK(testProject, moduleInfo, regex.excludeFiles);
@@ -57,7 +57,8 @@ module.exports = async function createAtlasCoreModule() {
5757
title: `${moduleInfo.nameWithSpace} - Marketplace Release v${moduleInfo.version}`,
5858
body: moduleChangelogs.replace(/"/g, "'"),
5959
tag: `${moduleFolderNameInRepo}-v${moduleInfo.version}`,
60-
mpkOutput,
60+
target: targetBranchName,
61+
filesToRelease: mpkOutput,
6162
isDraft: true
6263
});
6364

scripts/release/gh-release-atlas-native.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
githubAuthentication,
1111
cloneRepo,
1212
createMPK,
13-
createGithubRelease,
13+
createGithubReleaseFrom,
1414
regex
1515
} = require("./module-automation/commons");
1616

@@ -29,12 +29,19 @@ module.exports = async function createAtlasNativeContentModule() {
2929
};
3030
await githubAuthentication(moduleInfo);
3131
const moduleChangelogs = await updateModuleChangelogs(moduleInfo);
32-
await commitAndCreatePullRequest(moduleInfo);
32+
const targetBranchName = await commitAndCreatePullRequest(moduleInfo);
3333
await updateNativeComponentsTestProjectWithAtlas(moduleInfo, tmpFolder);
3434
const mpkOutput = await createMPK(tmpFolder, moduleInfo, regex.excludeFiles);
3535
console.log(`Change owner and group after module export...`);
3636
execSync(`sudo chown -R runner:docker ${tmpFolder}`, { stdio: "inherit" });
37-
await createGithubRelease(moduleInfo, moduleChangelogs, mpkOutput);
37+
console.log(`Creating Github release for module ${moduleInfo.nameWithSpace}`);
38+
await createGithubReleaseFrom({
39+
title: `${moduleInfo.nameWithSpace} ${moduleInfo.version} - Mendix ${moduleInfo.minimumMXVersion}`,
40+
body: moduleChangelogs,
41+
target: targetBranchName,
42+
tag: process.env.TAG,
43+
filesToRelease: mpkOutput
44+
});
3845
await execShellCommand(`rm -rf ${tmpFolder}`);
3946
console.log("Done.");
4047
};

scripts/release/gh-release-atlas-web-content.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = async function createAtlasWebContentModule() {
5656
`No unreleased changes found in the CHANGELOG.md for ${moduleInfo.nameWithSpace} ${moduleInfo.version}.`
5757
);
5858
}
59-
await commitAndCreatePullRequest(moduleInfo);
59+
const targetBranchName = await commitAndCreatePullRequest(moduleInfo);
6060
await updateTestProject(moduleInfo, testProject, tmp);
6161
const mpkOutput = await createMPK(testProject, moduleInfo, regex.excludeFiles);
6262
console.log(`Change owner and group after module export...`);
@@ -66,7 +66,8 @@ module.exports = async function createAtlasWebContentModule() {
6666
title: `${moduleInfo.nameWithSpace} - Marketplace Release v${moduleInfo.version}`,
6767
body: moduleChangelogs.replace(/"/g, "'"),
6868
tag: `${moduleFolderNameInRepo}-v${moduleInfo.version}`,
69-
mpkOutput,
69+
target: targetBranchName,
70+
filesToRelease: mpkOutput,
7071
isDraft: true
7172
});
7273

scripts/release/module-automation/commons.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ async function commitAndCreatePullRequest(moduleInfo) {
179179
`gh pr create --title "${moduleInfo.nameWithSpace}: Updating changelogs" --body "This is an automated PR." --base main --head ${changelogBranchName}`
180180
);
181181
console.log("Created PR for changelog updates.");
182+
183+
return changelogBranchName;
182184
}
183185

184186
async function updateWidgetChangelogs(widgetsFolders) {
@@ -248,24 +250,18 @@ async function createMPK(tmpFolder, moduleInfo, excludeFilesRegExp) {
248250
return (await getFiles(tmpFolder, [`.mpk`]))[0];
249251
}
250252

251-
async function createGithubRelease(moduleInfo, moduleChangelogs, mpkOutput) {
252-
console.log(`Creating Github release for module ${moduleInfo.nameWithSpace}`);
253-
await createGithubReleaseFrom({
254-
title: `${moduleInfo.nameWithSpace} ${moduleInfo.version} - Mendix ${moduleInfo.minimumMXVersion}`,
255-
body: moduleChangelogs,
256-
tag: process.env.TAG,
257-
mpkOutput
258-
});
259-
}
253+
async function createGithubReleaseFrom(params) {
254+
const { body, title, tag, filesToRelease = "", target, isDraft = false, repo } = params;
260255

261-
async function createGithubReleaseFrom({ title, body, tag, mpkOutput, isDraft = false }) {
262256
const command = [
263257
`gh release create`,
264258
`--title '${title}'`,
265259
`--notes '${body}'`,
266260
isDraft ? "--draft" : "",
261+
repo ? `-R '${repo}'` : "",
267262
`'${tag}'`,
268-
`'${mpkOutput}'`
263+
`--target '${target}'`,
264+
filesToRelease ? `'${filesToRelease}'` : ""
269265
]
270266
.filter(str => str !== "")
271267
.join(" ");
@@ -340,7 +336,6 @@ module.exports = {
340336
updateChangelogs,
341337
cloneRepo,
342338
createMPK,
343-
createGithubRelease,
344339
createGithubReleaseFrom,
345340
writeToWidgetChangelogs,
346341
zip,

0 commit comments

Comments
 (0)