Skip to content

Commit 8f20b88

Browse files
authored
[Fix] Release docker for mx9 (#1832)
2 parents 265d298 + 720e2f4 commit 8f20b88

6 files changed

Lines changed: 94 additions & 97 deletions

File tree

automation/utils/bin/rui-prepare-release.ts

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,29 @@ async function main(): Promise<void> {
1010
try {
1111
console.log(chalk.bold.cyan("\n🚀 RELEASE PREPARATION WIZARD 🚀\n"));
1212

13-
// Check for GitHub token
14-
const githubToken = process.env.GH_PAT;
15-
if (!githubToken) {
16-
console.warn(chalk.yellow("⚠️ GH_PAT environment variable not set"));
17-
console.warn(chalk.yellow(" GitHub workflow will need manual triggering"));
13+
console.log(chalk.bold("📋 STEP 1: Initialize Jira and GitHub"));
14+
15+
// Check GitHub authentication
16+
try {
17+
await gh.ensureAuth();
18+
console.log(chalk.green("✅ GitHub authentication verified"));
19+
} catch (error) {
20+
console.log(chalk.red(`❌ GitHub authentication failed: ${(error as Error).message}`));
21+
console.log(chalk.yellow("\n💡 First, make sure GitHub CLI is installed:"));
22+
console.log(chalk.cyan(" Download from: https://cli.github.com/"));
23+
console.log(chalk.cyan(" Or install via brew: brew install gh"));
24+
console.log(chalk.yellow("\n💡 Then authenticate with GitHub using one of these options:"));
25+
console.log(chalk.yellow(" 1. Set GITHUB_TOKEN environment variable:"));
26+
console.log(chalk.cyan(" export GITHUB_TOKEN=your_token_here"));
27+
console.log(chalk.yellow(" 2. Set GH_PAT environment variable:"));
28+
console.log(chalk.cyan(" export GH_PAT=your_token_here"));
29+
console.log(chalk.yellow(" 3. Use GitHub CLI to authenticate:"));
30+
console.log(chalk.cyan(" gh auth login"));
31+
console.log(chalk.yellow("\n Get a token at: https://github.com/settings/tokens"));
32+
process.exit(1);
1833
}
1934

2035
// Step 1: Initialize Jira client
21-
console.log(chalk.bold("📋 STEP 1: Initialize Jira"));
2236
let jira: Jira;
2337
try {
2438
jira = await initializeJiraClient();
@@ -87,7 +101,7 @@ async function main(): Promise<void> {
87101
console.log(chalk.green("✅ Branch pushed to GitHub"));
88102

89103
console.log(chalk.bold("\n📋 STEP 5: GitHub Release Workflow"));
90-
await triggerGitHubReleaseWorkflow(pkg.name, tmpBranchName, githubToken);
104+
await triggerGitHubReleaseWorkflow(pkg.name, tmpBranchName);
91105

92106
console.log(chalk.bold("\n📋 STEP 6: Jira Issue Management"));
93107
await manageIssuesForVersion(jira, jiraVersion.id, jiraVersionName);
@@ -229,29 +243,21 @@ async function manageIssuesForVersion(jira: Jira, versionId: string, versionName
229243
}
230244
}
231245

232-
async function triggerGitHubReleaseWorkflow(
233-
packageName: string,
234-
branchName: string,
235-
githubToken?: string
236-
): Promise<void> {
237-
if (githubToken) {
238-
const { triggerWorkflow } = await prompt<{ triggerWorkflow: boolean }>({
239-
type: "confirm",
240-
name: "triggerWorkflow",
241-
message: "❓ Trigger GitHub release workflow now?",
242-
initial: true
243-
});
246+
async function triggerGitHubReleaseWorkflow(packageName: string, branchName: string): Promise<void> {
247+
const { triggerWorkflow } = await prompt<{ triggerWorkflow: boolean }>({
248+
type: "confirm",
249+
name: "triggerWorkflow",
250+
message: "❓ Trigger GitHub release workflow now?",
251+
initial: true
252+
});
244253

245-
if (triggerWorkflow) {
246-
console.log(chalk.blue("🔄 Triggering GitHub release workflow..."));
247-
try {
248-
await gh.triggerCreateReleaseWorkflow(packageName, branchName);
249-
console.log(chalk.green("✅ GitHub Release Workflow triggered"));
250-
} catch (error) {
251-
console.error(chalk.red(`❌ Failed to trigger workflow: ${(error as Error).message}`));
252-
showManualTriggerInstructions(packageName, branchName);
253-
}
254-
} else {
254+
if (triggerWorkflow) {
255+
console.log(chalk.blue("🔄 Triggering GitHub release workflow..."));
256+
try {
257+
await gh.triggerCreateReleaseWorkflow(packageName, branchName);
258+
console.log(chalk.green("✅ GitHub Release Workflow triggered"));
259+
} catch (error) {
260+
console.error(chalk.red(`❌ Failed to trigger workflow: ${(error as Error).message}`));
255261
showManualTriggerInstructions(packageName, branchName);
256262
}
257263
} else {
@@ -260,7 +266,7 @@ async function triggerGitHubReleaseWorkflow(
260266
}
261267

262268
async function createReleaseBranch(packageName: string, version: string): Promise<string> {
263-
const tmpBranchName = `tmp-release/${packageName}-v${version}`;
269+
const tmpBranchName = `tmp/${packageName}-v${version}`;
264270

265271
let branchToUse = tmpBranchName;
266272
let branchesAreReady = false;
@@ -347,7 +353,6 @@ async function createReleaseBranch(packageName: string, version: string): Promis
347353
}
348354

349355
async function initializeJiraClient(): Promise<Jira> {
350-
console.log(chalk.bold("🔍 Checking Jira environment variables"));
351356
const projectKey = process.env.JIRA_PROJECT_KEY;
352357
const baseUrl = process.env.JIRA_BASE_URL;
353358
const apiToken = process.env.JIRA_API_TOKEN;
@@ -358,6 +363,7 @@ async function initializeJiraClient(): Promise<Jira> {
358363
console.log(chalk.dim(" export JIRA_PROJECT_KEY=WEB"));
359364
console.log(chalk.dim(" export JIRA_BASE_URL=https://your-company.atlassian.net"));
360365
console.log(chalk.dim(" export JIRA_API_TOKEN=username@your-company.com:ATATT3xFfGF0..."));
366+
console.log(chalk.dim(" Get your API token at: https://id.atlassian.com/manage-profile/security/api-tokens"));
361367
throw new Error("Missing Jira environment variables");
362368
}
363369

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
1-
FROM mono:6.12
1+
FROM --platform=$BUILDPLATFORM eclipse-temurin:17-jdk-jammy
2+
23
ARG MENDIX_VERSION
4+
ARG BUILDPLATFORM
35

6+
SHELL ["/bin/bash", "-c"]
47
RUN \
5-
echo "Installing Java..." && \
6-
apt-get -qq update && \
7-
apt-get -qq install -y wget && \
8-
wget -q https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk.tar.gz && \
9-
mkdir /usr/lib/jvm && \
10-
tar xfz /tmp/openjdk.tar.gz --directory /usr/lib/jvm && \
11-
rm /tmp/openjdk.tar.gz && \
12-
\
13-
echo "Downloading mxbuild ${MENDIX_VERSION}..." && \
14-
wget -q https://cdn.mendix.com/runtime/mxbuild-${MENDIX_VERSION}.tar.gz -O /tmp/mxbuild.tar.gz && \
15-
mkdir /tmp/mxbuild && \
16-
tar xfz /tmp/mxbuild.tar.gz --directory /tmp/mxbuild && \
17-
rm /tmp/mxbuild.tar.gz && \
8+
echo "Downloading mxbuild ${MENDIX_VERSION} and docker building for ${BUILDPLATFORM}..." \
9+
&& case "${BUILDPLATFORM}" in \
10+
linux/arm64) \
11+
BINARY_URL="https://cdn.mendix.com/runtime/arm64-mxbuild-${MENDIX_VERSION}.tar.gz"; \
12+
;; \
13+
linux/amd64) \
14+
BINARY_URL="https://cdn.mendix.com/runtime/mxbuild-${MENDIX_VERSION}.tar.gz"; \
15+
;; \
16+
*) \
17+
echo "Unsupported architecture: ${BUILDPLATFORM}" >&2; \
18+
exit 1; \
19+
;; \
20+
esac \
21+
&& echo "Downloading from: ${BINARY_URL}" \
22+
&& wget -q "${BINARY_URL}" -O /tmp/mxbuild.tar.gz \
23+
&& mkdir /tmp/mxbuild \
24+
&& tar xfz /tmp/mxbuild.tar.gz --directory /tmp/mxbuild \
25+
&& rm /tmp/mxbuild.tar.gz && \
1826
\
19-
apt-get -qq remove -y wget && \
27+
apt-get update -qqy && \
28+
apt-get install -qqy libicu70 libgdiplus && \
29+
apt-get -qqy remove --auto-remove wget && \
2030
apt-get clean && \
2131
\
2232
echo "#!/bin/bash -x" >/bin/mxbuild && \
23-
echo "mono /tmp/mxbuild/modeler/mxbuild.exe --java-home=/usr/lib/jvm/jdk-11.0.2 --java-exe-path=/usr/lib/jvm/jdk-11.0.2/bin/java \$@" >>/bin/mxbuild && \
33+
echo "/tmp/mxbuild/modeler/mxbuild --java-home=/opt/java/openjdk --java-exe-path=/opt/java/openjdk/bin/java \$@" >>/bin/mxbuild && \
2434
chmod +x /bin/mxbuild && \
2535
\
2636
echo "#!/bin/bash -x" >/bin/mx && \
27-
echo "mono /tmp/mxbuild/modeler/mx.exe \$@" >>/bin/mx && \
37+
echo "/tmp/mxbuild/modeler/mx \$@" >>/bin/mx && \
2838
chmod +x /bin/mx

automation/utils/docker/mxbuildMx10.Dockerfile

Lines changed: 0 additions & 38 deletions
This file was deleted.

automation/utils/src/github.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,33 @@ export class GitHub {
3030
authSet = false;
3131
tmpPrefix = "gh-";
3232

33-
private async ensureAuth(): Promise<void> {
33+
async ensureAuth(): Promise<void> {
3434
if (!this.authSet) {
35-
await exec(`echo "${process.env.GH_PAT}" | gh auth login --with-token`);
35+
if (process.env.GITHUB_TOKEN) {
36+
// when using GITHUB_TOKEN, gh will automatically use it
37+
} else if (process.env.GH_PAT) {
38+
await exec(`echo "${process.env.GH_PAT}" | gh auth login --with-token`);
39+
} else {
40+
// No environment variables set, check if already authenticated
41+
if (!(await this.isAuthenticated())) {
42+
throw new Error(
43+
"GitHub CLI is not authenticated. Please set GITHUB_TOKEN or GH_PAT environment variable, or run 'gh auth login'."
44+
);
45+
}
46+
}
47+
48+
this.authSet = true;
49+
}
50+
}
51+
52+
private async isAuthenticated(): Promise<boolean> {
53+
try {
54+
// Try to run 'gh auth status' to check if authenticated
55+
await exec("gh auth status", { stdio: "pipe" });
56+
return true;
57+
} catch (error) {
58+
// If the command fails, the user is not authenticated
59+
return false;
3660
}
3761
}
3862

automation/utils/src/mpk.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ async function ensureMxBuildDockerImageExists(mendixVersion: Version): Promise<v
99
const existingImages = (await exec(`docker image ls -q mxbuild:${version}`, { stdio: "pipe" })).stdout.trim();
1010
if (!existingImages) {
1111
console.log(`Creating new mxbuild:${version} docker image...`);
12-
const versionMajor = mendixVersion.major;
13-
const dockerfilePath =
14-
versionMajor < 10
15-
? join(__dirname, "../docker/mxbuild.Dockerfile")
16-
: join(__dirname, "../docker/mxbuildMx10.Dockerfile");
12+
const dockerfilePath = join(__dirname, "../docker/mxbuild.Dockerfile");
1713
await exec(
1814
`docker build -f ${dockerfilePath} ` +
1915
`--build-arg MENDIX_VERSION=${version} ` +
@@ -45,10 +41,8 @@ export async function createModuleMpkInDocker(
4541
"&&",
4642

4743
// and create module
48-
versionMajor < 10 ? "mono" : "",
49-
versionMajor >= 10
50-
? "/tmp/mxbuild/modeler/mx create-module-package"
51-
: "/tmp/mxbuild/modeler/mxutil.exe create-module-package",
44+
versionMajor < 10 ? "/tmp/mxbuild/modeler/mxutil" : "/tmp/mxbuild/modeler/mx",
45+
"create-module-package",
5246
excludeFilesRegExp ? `--exclude-files='${excludeFilesRegExp}'` : "",
5347
`/source/${projectFile}`,
5448
moduleName

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"publish-marketplace": "turbo run publish-marketplace",
1919
"version": "pnpm --filter @mendix/automation-utils run version",
2020
"changelog": "pnpm --filter @mendix/automation-utils run changelog",
21+
"prepare-release": "pnpm --filter @mendix/automation-utils run prepare-release",
2122
"postinstall": "turbo run agent-rules"
2223
},
2324
"devDependencies": {

0 commit comments

Comments
 (0)