Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.

Commit 43b80b9

Browse files
committed
build for windows on linux
1 parent 9eca4c9 commit 43b80b9

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ inputs:
4646
description: Maximum number of attempts for completing the build and release step
4747
required: false
4848
default: "1"
49-
skip_windows_npm_install:
50-
description: Whether to skip installing NPM dependencies on Windows
51-
required: false
52-
default: "false"
5349

5450
# Deprecated
5551
app_root:

index.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const getPlatform = () => {
2727
switch (process.platform) {
2828
case "darwin":
2929
return "mac";
30-
case "win32":
31-
return "windows";
3230
default:
3331
return "linux";
3432
}
@@ -72,7 +70,6 @@ const runAction = () => {
7270
const useVueCli = getInput("use_vue_cli") === "true";
7371
const args = getInput("args") || "";
7472
const maxAttempts = Number(getInput("max_attempts") || "1");
75-
const skipWindowsNpmInstall = getInput("skip_windows_npm_install") === "true";
7673

7774
// TODO: Deprecated option, remove in v2.0. `electron-builder` always requires a `package.json` in
7875
// the same directory as the Electron app, so the `package_root` option should be used instead
@@ -114,28 +111,40 @@ const runAction = () => {
114111
}
115112

116113
// Run NPM build script if it exists
117-
if (skipBuild) {
118-
log("Skipping build script because `skip_build` option is set");
114+
log("Running the build script…");
115+
if (useNpm) {
116+
run(`npm run ${buildScriptName} --if-present`, pkgRoot);
119117
} else {
120-
log("Running the build script…");
121-
if (useNpm) {
122-
run(`npm run ${buildScriptName} --if-present`, pkgRoot);
123-
} else {
124-
// TODO: Use `yarn run ${buildScriptName} --if-present` once supported
125-
// https://github.com/yarnpkg/yarn/issues/6894
126-
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
127-
if (pkgJson.scripts && pkgJson.scripts[buildScriptName]) {
128-
run(`yarn run ${buildScriptName}`, pkgRoot);
129-
}
118+
// TODO: Use `yarn run ${buildScriptName} --if-present` once supported
119+
// https://github.com/yarnpkg/yarn/issues/6894
120+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
121+
if (pkgJson.scripts && pkgJson.scripts[buildScriptName]) {
122+
run(`yarn run ${buildScriptName}`, pkgRoot);
130123
}
131124
}
132125

126+
if (platform === "linux") {
127+
log("Installing wine to build Windows app on Linux…");
128+
run("sudo dpkg --add-architecture i386")
129+
run("sudo apt-get update")
130+
run("sudo apt-get install -y software-properties-common")
131+
run("sudo add-apt-repository -y ppa:cybermax-dexter/sdl2-backport")
132+
run("sudo apt-get update")
133+
run(`sudo apt-get install -y \
134+
wine32 \
135+
winbind \
136+
xvfb`)
137+
// Verify Wine installation
138+
log("Verifying Wine installation…");
139+
run("wine --version")
140+
}
141+
133142
log(`Building${release ? " and releasing" : ""} the Electron app…`);
134143
const cmd = useVueCli ? "vue-cli-service electron:build" : "electron-builder";
135144
for (let i = 0; i < maxAttempts; i += 1) {
136145
try {
137146
run(
138-
`${useNpm ? "npx --no-install" : "yarn run"} ${cmd} --${platform} ${
147+
`${useNpm ? "npx --no-install" : "yarn run"} ${cmd} -${platform === "mac" ? "m" : "wl"} ${
139148
release ? "--publish always" : ""
140149
} ${args}`,
141150
appRoot,

0 commit comments

Comments
 (0)