Skip to content

Commit

Permalink
feat: support arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
minchao committed Jun 5, 2024
1 parent 6cc2c90 commit 4bb2bf1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
23 changes: 17 additions & 6 deletions dist/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/index.js.map

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,31 @@ export async function download(
return cachedPath
}

function getArchitecture(): string {
const arch = os.arch()
switch (arch) {
case 'arm64': {
return arch
}
case 'x64': {
return 'amd64'
}
default: {
throw new Error(`Unsupported architecture: ${arch}`)
}
}
}

function getDownloadURL(toolName: string, version: string): string {
const baseURL =
'https://github.com/open-policy-agent/gatekeeper/releases/download/'

const arch = os.arch()
if (arch !== 'x64') {
throw new Error(`Unsupported architecture: ${arch}`)
}
const arch = getArchitecture()

switch (os.type()) {
case 'Darwin':
return `${baseURL}${version}/${toolName}-${version}-darwin-amd64.tar.gz`
return `${baseURL}${version}/${toolName}-${version}-darwin-${arch}.tar.gz`
case 'Linux':
return `${baseURL}${version}/${toolName}-${version}-linux-amd64.tar.gz`
return `${baseURL}${version}/${toolName}-${version}-linux-${arch}.tar.gz`
default:
throw new Error(`Unsupported OS: ${os.type()}`)
}
Expand Down

0 comments on commit 4bb2bf1

Please sign in to comment.