Skip to content

Commit

Permalink
feat: dev-2024-10 support and fixes (#46)
Browse files Browse the repository at this point in the history
* fix: look for linux or ubuntu release name

* debug: add 'ls'

* fix: add general handling of 'mv dist/* .' where the name of 'dist' is unknown

* fix: remove nested zip after extract

* feat: check for dynamic llvm to forgo installing deps if not needed
  • Loading branch information
laytan authored Oct 2, 2024
1 parent da35b0f commit 455724c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 37 deletions.
53 changes: 35 additions & 18 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

53 changes: 35 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,30 @@ async function downloadRelease(inputs) {
}

const releaseOS = {
'darwin': 'macos',
'linux': 'ubuntu',
'win32': 'windows',
'darwin': ['macos'],
'linux': ['linux', 'ubuntu'],
'win32': ['windows'],
}[os.platform()];

const releaseArch = {
'x64': 'amd64',
'arm64': 'arm64',
}[os.arch()];
const releaseAssetPrefix = `odin-${releaseOS}-${releaseArch}`;

core.info(`Release has ${release.data.assets.length} assets, Looking for asset prefix: ${releaseAssetPrefix}`);
let asset;
for (const tryOS of releaseOS) {
const releaseAssetPrefix = `odin-${tryOS}-${releaseArch}`;
core.info(`Release has ${release.data.assets.length} assets, Looking for asset prefix: ${releaseAssetPrefix}`);

asset = release.data.assets.find(asset => asset.name.startsWith(releaseAssetPrefix));
if (asset) {
break;
}
}

const asset = release.data.assets.find(asset => asset.name.startsWith(releaseAssetPrefix));
if (!asset) {
core.warning('could not find release asset to download, falling back to git based install.');
return false;
core.warning('could not find release asset to download, falling back to git based install.');
return false;
}

// Linux/Darwin GitHub action runners come with LLVM 14 installed, we add it to path here so we can use
Expand Down Expand Up @@ -313,24 +320,23 @@ async function downloadRelease(inputs) {
core.info('Unzipping nested zip');
const zipInZip = new AdmZip(maybeZipInZip);
zipInZip.extractAllTo(common.odinPath(), false, true);
fs.unlinkSync(maybeZipInZip);
}

// NOTE: after dev-2024-06 releases don't seem to be doubly zipped anymore
// but do still have the nested dist folder we need to move.

// NOTE: dev-2024-07 has 'windows_artifacts' on windows, all others have 'dist'.

let maybeNestedDistName = 'windows_artifacts';
if (!fs.existsSync(`${common.odinPath()}/${maybeNestedDistName}`)) {
maybeNestedDistName = 'dist';
}

const maybeNestedDist = `${common.odinPath()}/${maybeNestedDistName}`;
if (fs.existsSync(maybeNestedDist)) {
const dir = fs.readdirSync(common.odinPath());
if (dir.length == 1) {
core.info('Moving dist folder');

const distDir = `${common.odinPath()}/${dir[0]}`;

// Basically does a `mv dist/* .`
const entries = fs.readdirSync(maybeNestedDist);
await Promise.all(entries.map((entry) => io.mv(`${maybeNestedDist}/${entry}`, `${common.odinPath()}/${entry}`)));
const entries = fs.readdirSync(distDir);
await Promise.all(entries.map((entry) => io.mv(`${distDir}/${entry}`, `${common.odinPath()}/${entry}`)));

// NOTE: somehow after dev-2024-06 we also need to make it executable again...
finalizeRelease(inputs);
Expand Down Expand Up @@ -364,7 +370,18 @@ async function finalizeRelease(inputs) {
fs.cpSync(possibleLibLLVMToRename, `${common.odinPath()}/libLLVM-18.so.18.1`);
}

await pullOdinBuildDependencies({...inputs, llvmVersion: '18'});
let hasDynamicLLVM = false;
const dir = fs.readdirSync(common.odinPath());
for (const file of dir) {
if (file.includes("libLLVM") && file.includes(".so")) {
hasDynamicLLVM = true;
break;
}
}

if (hasDynamicLLVM) {
await pullOdinBuildDependencies({...inputs, llvmVersion: '18'});
}
}
}

Expand Down

0 comments on commit 455724c

Please sign in to comment.