mirror of
https://github.com/Minionguyjpro/Inno-Setup-Action
synced 2026-02-18 09:31:19 +01:00
[AUTO]Update CJS script
Files changed: M dist/index.js M src/index.js
This commit is contained in:
130
dist/index.js
vendored
130
dist/index.js
vendored
@@ -27428,6 +27428,13 @@ var __webpack_exports__ = {};
|
|||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9896);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9896);
|
||||||
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(5317);
|
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(5317);
|
||||||
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(9023);
|
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(9023);
|
||||||
|
/* harmony import */ var https__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(5692);
|
||||||
|
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(857);
|
||||||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(6928);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -27438,7 +27445,12 @@ const execFilePromise = (0,util__WEBPACK_IMPORTED_MODULE_3__.promisify)(child_pr
|
|||||||
|
|
||||||
const workspacePath = process.env.GITHUB_WORKSPACE;
|
const workspacePath = process.env.GITHUB_WORKSPACE;
|
||||||
const options = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("options");
|
const options = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("options");
|
||||||
const path = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("path");
|
const scriptInput = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("path");
|
||||||
|
const installLatest =
|
||||||
|
(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("install_latest") || "false").toLowerCase() === "true";
|
||||||
|
const installerUrl =
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("installer_url") ||
|
||||||
|
"https://jrsoftware.org/download.php/is.exe?site=1";
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@@ -27465,27 +27477,127 @@ async function run() {
|
|||||||
|
|
||||||
const escapedOptions = options.map((str) => str.replace(/(["'])/g, "$1"));
|
const escapedOptions = options.map((str) => str.replace(/(["'])/g, "$1"));
|
||||||
|
|
||||||
// Install Inno Setup silently
|
async function downloadFile(url, dest) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const maxRedirects = 5;
|
||||||
|
function getUrl(u, redirects) {
|
||||||
|
if (redirects > maxRedirects)
|
||||||
|
return reject(
|
||||||
|
new Error("Too many redirects while downloading installer"),
|
||||||
|
);
|
||||||
|
https__WEBPACK_IMPORTED_MODULE_4__.get(u, (res) => {
|
||||||
|
if (
|
||||||
|
res.statusCode >= 300 &&
|
||||||
|
res.statusCode < 400 &&
|
||||||
|
res.headers.location
|
||||||
|
) {
|
||||||
|
return getUrl(res.headers.location, redirects + 1);
|
||||||
|
}
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
return reject(
|
||||||
|
new Error(`Download failed with status ${res.statusCode}`),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const file = (0,fs__WEBPACK_IMPORTED_MODULE_1__.createWriteStream)(dest);
|
||||||
|
res.pipe(file);
|
||||||
|
file.on("finish", () => file.close(resolve));
|
||||||
|
file.on("error", reject);
|
||||||
|
})
|
||||||
|
.on("error", reject);
|
||||||
|
}
|
||||||
|
getUrl(url, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function findIscc() {
|
||||||
|
const candidates = [];
|
||||||
|
const pf86 = process.env["ProgramFiles(x86)"];
|
||||||
|
const pf = process.env["ProgramFiles"];
|
||||||
|
if (pf86) {
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf86, "Inno Setup 6", "iscc.exe"));
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf86, "Inno Setup 7", "iscc.exe"));
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf86, "Inno Setup", "iscc.exe"));
|
||||||
|
}
|
||||||
|
if (pf) {
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf, "Inno Setup 6", "iscc.exe"));
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf, "Inno Setup 7", "iscc.exe"));
|
||||||
|
candidates.push(path__WEBPACK_IMPORTED_MODULE_6__.join(pf, "Inno Setup", "iscc.exe"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const p of candidates) {
|
||||||
try {
|
try {
|
||||||
const { stdout, stderr } = await execPromise(`choco install innosetup`);
|
await fs__WEBPACK_IMPORTED_MODULE_1__.promises.access(p);
|
||||||
console.error(stderr);
|
return p;
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to 'where' to see if it's on PATH
|
||||||
|
try {
|
||||||
|
const { stdout } = await execPromise("where iscc.exe");
|
||||||
|
const line = stdout.split(/\r?\n/).find(Boolean);
|
||||||
|
if (line) return line.trim();
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install Inno Setup: either download+install latest or fallback to choco
|
||||||
|
if (installLatest) {
|
||||||
|
const tmpExe = path__WEBPACK_IMPORTED_MODULE_6__.join(
|
||||||
|
os__WEBPACK_IMPORTED_MODULE_5__.tmpdir(),
|
||||||
|
`inno-setup-installer-${Date.now()}.exe`,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Downloading Inno Setup from ${installerUrl} ...`);
|
||||||
|
await downloadFile(installerUrl, tmpExe);
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Running installer silently: ${tmpExe}`);
|
||||||
|
await execFilePromise(tmpExe, [
|
||||||
|
"/VERYSILENT",
|
||||||
|
"/SUPPRESSMSGBOXES",
|
||||||
|
"/NORESTART",
|
||||||
|
"/SP-",
|
||||||
|
]);
|
||||||
|
} catch (err) {
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.warning(
|
||||||
|
`Download/install failed: ${err.message}. Falling back to Chocolatey.`,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await execPromise(`choco install innosetup -y`);
|
||||||
|
} catch (err2) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to install Inno Setup: ${err2.stderr || err2.message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await execPromise(`choco install innosetup -y`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to install Inno Setup: ${err.stderr || err.message}`,
|
`Failed to install Inno Setup: ${err.stderr || err.message}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run Inno Setup Compiler
|
// Locate iscc.exe
|
||||||
const isccPath = `${process.env["ProgramFiles(x86)"]}\\Inno Setup 6\\iscc.exe`;
|
const isccPath = await findIscc();
|
||||||
const scriptPath = `${workspacePath}\\${path}`;
|
if (!isccPath) {
|
||||||
|
throw new Error("Could not locate iscc.exe after installation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const scriptPath = path__WEBPACK_IMPORTED_MODULE_6__.join(workspacePath, scriptInput);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { stdout, stderr } = await execFilePromise(isccPath, [
|
const { stdout, stderr } = await execFilePromise(isccPath, [
|
||||||
scriptPath,
|
scriptPath,
|
||||||
...escapedOptions,
|
...escapedOptions,
|
||||||
]);
|
]);
|
||||||
console.log(stdout);
|
if (stdout) console.log(stdout);
|
||||||
console.error(stderr);
|
if (stderr) console.error(stderr);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Execution failed: ${err.stderr || err.message}`);
|
throw new Error(`Execution failed: ${err.stderr || err.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
57
src/index.js
57
src/index.js
@@ -13,8 +13,11 @@ const execFilePromise = promisify(execFile);
|
|||||||
const workspacePath = process.env.GITHUB_WORKSPACE;
|
const workspacePath = process.env.GITHUB_WORKSPACE;
|
||||||
const options = core.getMultilineInput("options");
|
const options = core.getMultilineInput("options");
|
||||||
const scriptInput = core.getInput("path");
|
const scriptInput = core.getInput("path");
|
||||||
const installLatest = (core.getInput("install_latest") || "false").toLowerCase() === "true";
|
const installLatest =
|
||||||
const installerUrl = core.getInput("installer_url") || "https://jrsoftware.org/download.php/is.exe?site=1";
|
(core.getInput("install_latest") || "false").toLowerCase() === "true";
|
||||||
|
const installerUrl =
|
||||||
|
core.getInput("installer_url") ||
|
||||||
|
"https://jrsoftware.org/download.php/is.exe?site=1";
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@@ -45,19 +48,30 @@ async function run() {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const maxRedirects = 5;
|
const maxRedirects = 5;
|
||||||
function getUrl(u, redirects) {
|
function getUrl(u, redirects) {
|
||||||
if (redirects > maxRedirects) return reject(new Error("Too many redirects while downloading installer"));
|
if (redirects > maxRedirects)
|
||||||
https.get(u, (res) => {
|
return reject(
|
||||||
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
new Error("Too many redirects while downloading installer"),
|
||||||
|
);
|
||||||
|
https
|
||||||
|
.get(u, (res) => {
|
||||||
|
if (
|
||||||
|
res.statusCode >= 300 &&
|
||||||
|
res.statusCode < 400 &&
|
||||||
|
res.headers.location
|
||||||
|
) {
|
||||||
return getUrl(res.headers.location, redirects + 1);
|
return getUrl(res.headers.location, redirects + 1);
|
||||||
}
|
}
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
return reject(new Error(`Download failed with status ${res.statusCode}`));
|
return reject(
|
||||||
|
new Error(`Download failed with status ${res.statusCode}`),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const file = createWriteStream(dest);
|
const file = createWriteStream(dest);
|
||||||
res.pipe(file);
|
res.pipe(file);
|
||||||
file.on("finish", () => file.close(resolve));
|
file.on("finish", () => file.close(resolve));
|
||||||
file.on("error", reject);
|
file.on("error", reject);
|
||||||
}).on("error", reject);
|
})
|
||||||
|
.on("error", reject);
|
||||||
}
|
}
|
||||||
getUrl(url, 0);
|
getUrl(url, 0);
|
||||||
});
|
});
|
||||||
@@ -101,25 +115,39 @@ async function run() {
|
|||||||
|
|
||||||
// Install Inno Setup: either download+install latest or fallback to choco
|
// Install Inno Setup: either download+install latest or fallback to choco
|
||||||
if (installLatest) {
|
if (installLatest) {
|
||||||
const tmpExe = pathModule.join(os.tmpdir(), `inno-setup-installer-${Date.now()}.exe`);
|
const tmpExe = pathModule.join(
|
||||||
|
os.tmpdir(),
|
||||||
|
`inno-setup-installer-${Date.now()}.exe`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
core.info(`Downloading Inno Setup from ${installerUrl} ...`);
|
core.info(`Downloading Inno Setup from ${installerUrl} ...`);
|
||||||
await downloadFile(installerUrl, tmpExe);
|
await downloadFile(installerUrl, tmpExe);
|
||||||
core.info(`Running installer silently: ${tmpExe}`);
|
core.info(`Running installer silently: ${tmpExe}`);
|
||||||
await execFilePromise(tmpExe, ["/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART", "/SP-"]);
|
await execFilePromise(tmpExe, [
|
||||||
|
"/VERYSILENT",
|
||||||
|
"/SUPPRESSMSGBOXES",
|
||||||
|
"/NORESTART",
|
||||||
|
"/SP-",
|
||||||
|
]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.warning(`Download/install failed: ${err.message}. Falling back to Chocolatey.`);
|
core.warning(
|
||||||
|
`Download/install failed: ${err.message}. Falling back to Chocolatey.`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
await execPromise(`choco install innosetup -y`);
|
await execPromise(`choco install innosetup -y`);
|
||||||
} catch (err2) {
|
} catch (err2) {
|
||||||
throw new Error(`Failed to install Inno Setup: ${err2.stderr || err2.message}`);
|
throw new Error(
|
||||||
|
`Failed to install Inno Setup: ${err2.stderr || err2.message}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await execPromise(`choco install innosetup -y`);
|
await execPromise(`choco install innosetup -y`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Failed to install Inno Setup: ${err.stderr || err.message}`);
|
throw new Error(
|
||||||
|
`Failed to install Inno Setup: ${err.stderr || err.message}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +160,10 @@ async function run() {
|
|||||||
const scriptPath = pathModule.join(workspacePath, scriptInput);
|
const scriptPath = pathModule.join(workspacePath, scriptInput);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { stdout, stderr } = await execFilePromise(isccPath, [scriptPath, ...escapedOptions]);
|
const { stdout, stderr } = await execFilePromise(isccPath, [
|
||||||
|
scriptPath,
|
||||||
|
...escapedOptions,
|
||||||
|
]);
|
||||||
if (stdout) console.log(stdout);
|
if (stdout) console.log(stdout);
|
||||||
if (stderr) console.error(stderr);
|
if (stderr) console.error(stderr);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user