Skip to content

Commit

Permalink
Pull logic into functions and fix issue with url when a specific vers…
Browse files Browse the repository at this point in the history
…ion is passed
  • Loading branch information
atainter committed Jul 30, 2024
1 parent 0dbf032 commit f5fa899
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-20.04, macos-latest, macos-11, windows-latest, windows-2019]
os: [ubuntu-latest, ubuntu-20.04, macos-latest, windows-latest, windows-2019]
name: Install the cli
steps:
- name: Checkout
Expand Down
34 changes: 21 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,8 @@ run().catch(error => {

async function run() {
const version = core.getInput('version');
const downloadUrlWithVersion = `https://github.com/workos/workos-cli/releases/${version}/download`

let cliArch;
switch (process.arch) {
case "arm64":
cliArch = "arm64";
break;
case "x64":
cliArch = "x86_64";
break;
default:
throw new Error(`Unsupported architecture '${process.arch}'`);
}
const downloadUrlWithVersion = getURLForVersion(version);
const cliArch = getCliArch()

switch (process.platform) {
case "win32": {
Expand All @@ -39,6 +28,25 @@ async function run() {
}
}

function getURLForVersion(version) {
if (version === 'latest') {
return `https://github.com/workos/workos-cli/releases/${version}/download`
} else {
return `https://github.com/workos/workos-cli/releases/download/${version}`
}
}

function getCliArch() {
switch (process.arch) {
case "arm64":
return "arm64";
case "x64":
return "x86_64";
default:
throw new Error(`Unsupported architecture '${process.arch}'`);
}
}

async function installZip(url) {
const downloadPath = await tc.downloadTool(url);
const pathToCLI = await tc.extractZip(downloadPath);
Expand Down

0 comments on commit f5fa899

Please sign in to comment.