@@ -19430,7 +19430,7 @@ var require_exec = __commonJS({
19430
19430
exports2.getExecOutput = exports2.exec = void 0;
19431
19431
var string_decoder_1 = require("string_decoder");
19432
19432
var tr = __importStar2(require_toolrunner());
19433
- function exec (commandLine, args, options) {
19433
+ function exec2 (commandLine, args, options) {
19434
19434
return __awaiter(this, void 0, void 0, function* () {
19435
19435
const commandArgs = tr.argStringToArray(commandLine);
19436
19436
if (commandArgs.length === 0) {
@@ -19442,7 +19442,7 @@ var require_exec = __commonJS({
19442
19442
return runner.exec();
19443
19443
});
19444
19444
}
19445
- exports2.exec = exec ;
19445
+ exports2.exec = exec2 ;
19446
19446
function getExecOutput(commandLine, args, options) {
19447
19447
var _a, _b;
19448
19448
return __awaiter(this, void 0, void 0, function* () {
@@ -19465,7 +19465,7 @@ var require_exec = __commonJS({
19465
19465
}
19466
19466
};
19467
19467
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
19468
- const exitCode = yield exec (commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
19468
+ const exitCode = yield exec2 (commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
19469
19469
stdout += stdoutDecoder.end();
19470
19470
stderr += stderrDecoder.end();
19471
19471
return {
@@ -19543,12 +19543,12 @@ var require_platform = __commonJS({
19543
19543
Object.defineProperty(exports2, "__esModule", { value: true });
19544
19544
exports2.getDetails = exports2.isLinux = exports2.isMacOS = exports2.isWindows = exports2.arch = exports2.platform = void 0;
19545
19545
var os_1 = __importDefault(require("os"));
19546
- var exec = __importStar2(require_exec());
19546
+ var exec2 = __importStar2(require_exec());
19547
19547
var getWindowsInfo = () => __awaiter(void 0, void 0, void 0, function* () {
19548
- const { stdout: version } = yield exec .getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', void 0, {
19548
+ const { stdout: version } = yield exec2 .getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', void 0, {
19549
19549
silent: true
19550
19550
});
19551
- const { stdout: name } = yield exec .getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', void 0, {
19551
+ const { stdout: name } = yield exec2 .getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', void 0, {
19552
19552
silent: true
19553
19553
});
19554
19554
return {
@@ -19558,7 +19558,7 @@ var require_platform = __commonJS({
19558
19558
});
19559
19559
var getMacOsInfo = () => __awaiter(void 0, void 0, void 0, function* () {
19560
19560
var _a, _b, _c, _d;
19561
- const { stdout } = yield exec .getExecOutput("sw_vers", void 0, {
19561
+ const { stdout } = yield exec2 .getExecOutput("sw_vers", void 0, {
19562
19562
silent: true
19563
19563
});
19564
19564
const version = (_b = (_a = stdout.match(/ProductVersion:\s*(.+)/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : "";
@@ -19569,7 +19569,7 @@ var require_platform = __commonJS({
19569
19569
};
19570
19570
});
19571
19571
var getLinuxInfo = () => __awaiter(void 0, void 0, void 0, function* () {
19572
- const { stdout } = yield exec .getExecOutput("lsb_release", ["-i", "-r", "-s"], {
19572
+ const { stdout } = yield exec2 .getExecOutput("lsb_release", ["-i", "-r", "-s"], {
19573
19573
silent: true
19574
19574
});
19575
19575
const [name, version] = stdout.trim().split("\n");
@@ -31492,6 +31492,7 @@ var __importStar = exports && exports.__importStar || function(mod) {
31492
31492
Object.defineProperty(exports, "__esModule", { value: true });
31493
31493
require_dnt_polyfills();
31494
31494
var core = __importStar(require_core());
31495
+ var exec = __importStar(require_exec());
31495
31496
var tc = __importStar(require_tool_cache());
31496
31497
var semver = __importStar(require_mod());
31497
31498
var octokit_1 = (init_dist_bundle14(), __toCommonJS(dist_bundle_exports3));
@@ -31531,40 +31532,67 @@ async function resolveVersion(gh, version) {
31531
31532
}
31532
31533
throw new Error(`Invalid version: ${version}`);
31533
31534
}
31534
- async function getDownloadUrl(gh, version) {
31535
+ async function downloadFlatc(gh, version) {
31536
+ const platformDetails = await core.platform.getDetails();
31537
+ core.info(JSON.stringify(platformDetails));
31535
31538
const platformMap = {
31536
- linux: /Linux\.flatc\.binary\.g\+\+-\d+\.zip/,
31537
- darwin: /Mac\.flatc\.binary\.zip/,
31538
- win32: /Windows\.flatc\.binary\.zip/
31539
+ "linux-x64": /Linux\.flatc\.binary\.g\+\+-\d+\.zip/,
31540
+ "darwin-arm64": /Mac\.flatc\.binary\.zip/,
31541
+ "darwin-x64": /MacIntel\.flatc\.binary\.zip/,
31542
+ "win32-x64": /Windows\.flatc\.binary\.zip/
31539
31543
};
31540
- const fileRegex = platformMap[core.platform.platform];
31541
- if (!fileRegex) {
31542
- throw new Error(`Unsupported platform: ${core.platform.platform}`);
31543
- }
31544
+ const key = `${platformDetails.platform}-${platformDetails.arch}`;
31545
+ const fileRegex = platformMap[key];
31544
31546
const resp = await gh.rest.repos.getReleaseByTag({
31545
31547
owner: "google",
31546
31548
repo: "flatbuffers",
31547
31549
tag: `v${version}`
31548
31550
});
31549
- for (const asset of resp.data.assets) {
31550
- if (fileRegex.test(asset.name)) {
31551
- return asset.browser_download_url;
31552
- }
31551
+ if (fileRegex) {
31552
+ let url = null;
31553
+ for (const asset of resp.data.assets) {
31554
+ if (fileRegex.test(asset.name)) {
31555
+ url = asset.browser_download_url;
31556
+ }
31557
+ }
31558
+ if (!url) {
31559
+ throw new Error("No matching asset found for platform");
31560
+ }
31561
+ core.info(`Downloading URL: ${url}`);
31562
+ const downloadPath = await tc.downloadTool(url);
31563
+ core.info(`Downloaded to: ${downloadPath}`);
31564
+ const extractPath = await tc.extractZip(downloadPath);
31565
+ core.info(`Extracted to: ${extractPath}`);
31566
+ return await tc.cacheDir(extractPath, "flatc", version);
31567
+ } else {
31568
+ const url = resp.data.tarball_url;
31569
+ if (!url) {
31570
+ throw new Error("No tarball found for platform");
31571
+ }
31572
+ core.info(`Downloading URL: ${url}`);
31573
+ const downloadPath = await tc.downloadTool(url);
31574
+ core.info(`Downloaded to: ${downloadPath}`);
31575
+ const extractPath = await tc.extractTar(downloadPath);
31576
+ core.info(`Extracted to: ${extractPath}`);
31577
+ const sourcePath = extractPath + "/" + (await ls(extractPath)).trim();
31578
+ core.info("Building flatc from source");
31579
+ await exec.exec("cmake", ["-G", "Unix Makefiles"], { cwd: sourcePath });
31580
+ await exec.exec("make", ["-j"], { cwd: sourcePath });
31581
+ core.info("Built flatc from source");
31582
+ return await tc.cacheDir(sourcePath, "flatc", version);
31553
31583
}
31554
- throw new Error("No matching asset found for platform");
31555
31584
}
31556
- async function downloadFlatc(version, url) {
31557
- let cachedPath = tc.find("flatc", version);
31558
- if (cachedPath) {
31559
- return cachedPath;
31560
- }
31561
- core.info(`Downloading URL: ${url}`);
31562
- const downloadPath = await tc.downloadTool(url);
31563
- core.info(`Downloaded to: ${downloadPath}`);
31564
- const extractPath = await tc.extractZip(downloadPath);
31565
- core.info(`Extracted to: ${extractPath}`);
31566
- cachedPath = await tc.cacheDir(extractPath, "flatc", version);
31567
- return cachedPath;
31585
+ async function ls(path) {
31586
+ let stdout = "";
31587
+ const options = {
31588
+ listeners: {
31589
+ stdout: (data) => {
31590
+ stdout += data.toString();
31591
+ }
31592
+ }
31593
+ };
31594
+ await exec.exec("ls", [path], options);
31595
+ return stdout;
31568
31596
}
31569
31597
async function main() {
31570
31598
const githubToken = core.getInput("github-token") ?? void 0;
@@ -31573,8 +31601,10 @@ async function main() {
31573
31601
core.info(`Input version: ${inputVersion}`);
31574
31602
const version = await resolveVersion(gh, inputVersion);
31575
31603
core.info(`Resolved version: ${version}`);
31576
- const url = await getDownloadUrl(gh, version);
31577
- const cachedPath = await downloadFlatc(version, url);
31604
+ let cachedPath = tc.find("flatc", version);
31605
+ if (!cachedPath) {
31606
+ cachedPath = await downloadFlatc(gh, version);
31607
+ }
31578
31608
core.info(`Cached at: ${cachedPath}`);
31579
31609
core.addPath(cachedPath);
31580
31610
core.info("Added cached path to environment variables");
0 commit comments