Skip to content

Commit

Permalink
WIP: Support ARM macOS too
Browse files Browse the repository at this point in the history
  • Loading branch information
samhh committed Jul 24, 2024
1 parent 828fdbc commit 97e7bd3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ on:
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest
- macos-latest
version:
- 0.8.0
- 0.8.1
- 0.8.3
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: ./
Expand Down
22 changes: 20 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30544,14 +30544,32 @@ var core = __nccwpck_require__(9093);
var tool_cache = __nccwpck_require__(5561);
;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
;// CONCATENATED MODULE: external "node:os"
const external_node_os_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:os");
;// CONCATENATED MODULE: ./src/main.ts



const downloadURL = (version) => `https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}-linux-x86_64`;

const getDownloadURL = (version) => {
const sys = `${external_node_os_namespaceObject.platform()} ${external_node_os_namespaceObject.arch()}`;
const prefix = `https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}`;
switch (sys) {
case "linux x64":
return `${prefix}-linux-x86_64`;
case "darwin arm64":
return `${prefix}-macos-aarch64`;
default: {
core.setFailed(`Unsupported os/arch pair: ${sys}`);
return null;
}
}
};
const main = async () => {
const version = core.getInput("version");
const url = downloadURL(version);
const url = getDownloadURL(version);
if (url === null)
return;
core.info(`Downloading v${version} from ${url}`);
const temporary = await tool_cache.downloadTool(url);
core.debug(`Setting permissions on ${temporary}`);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import * as fs from "node:fs";
import * as os from "node:os";

const downloadURL = (version: string): string =>
`https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}-linux-x86_64`;
const getDownloadURL = (version: string): string | null => {
const sys = `${os.platform()} ${os.arch()}`;
const prefix = `https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}`;
switch (sys) {
case "linux x64":
return `${prefix}-linux-x86_64`;
case "darwin arm64":
return `${prefix}-macos-aarch64`;
default: {
core.setFailed(`Unsupported os/arch pair: ${sys}`);
return null;
}
}
};

const main = async (): Promise<void> => {
const version = core.getInput("version");
const url = downloadURL(version);
const url = getDownloadURL(version);
if (url === null) return;

core.info(`Downloading v${version} from ${url}`);
const temporary = await tc.downloadTool(url);
Expand Down

0 comments on commit 97e7bd3

Please sign in to comment.