Skip to content

Commit 5f6aee7

Browse files
authored
Support ARM (#44)
* Support ARM * Remove log statement
1 parent b22e99c commit 5f6aee7

File tree

3 files changed

+96
-62
lines changed

3 files changed

+96
-62
lines changed

dist/index.js

Lines changed: 45 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,69 @@
11
import * as core from '@actions/core'
22
import * as tc from '@actions/tool-cache'
33

4+
function downloadUrl(version: string): string {
5+
let plat = ''
6+
let arch = ''
7+
8+
switch (process.platform) {
9+
case 'win32': {
10+
plat = 'windows'
11+
break
12+
}
13+
case 'darwin': {
14+
plat = 'darwin'
15+
break
16+
}
17+
case 'linux': {
18+
plat = 'linux'
19+
break
20+
}
21+
default: {
22+
core.setFailed(`Unsupported platform: ${process.platform}`)
23+
return ''
24+
}
25+
}
26+
27+
switch (process.arch) {
28+
case 'x64': {
29+
arch = 'amd64'
30+
break
31+
}
32+
case 'arm64': {
33+
arch = 'arm64'
34+
break
35+
}
36+
default: {
37+
core.setFailed(`Unsupported architecture: ${process.arch}`)
38+
return ''
39+
}
40+
}
41+
42+
return `https://downloads.sqlc.dev/sqlc_${version}_${plat}_${arch}.zip`
43+
}
44+
445
async function run(): Promise<void> {
546
try {
647
const version = core.getInput('sqlc-version')
748
if (!version) {
849
core.setFailed(`sqlc-version not set`)
950
return
1051
}
11-
const toolDir = tc.find('sqlc', version, 'x64')
52+
const toolDir = tc.find('sqlc', version, process.arch)
1253
if (toolDir !== '') {
1354
core.addPath(toolDir)
1455
return
1556
}
1657

17-
switch (process.platform) {
18-
case 'win32': {
19-
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_windows_amd64.zip`
20-
const downloadPath = await tc.downloadTool(toolUrl)
21-
const extPath = await tc.extractZip(downloadPath)
22-
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
23-
core.addPath(cachedPath)
24-
break
25-
}
26-
27-
case 'darwin': {
28-
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_darwin_amd64.zip`
29-
const downloadPath = await tc.downloadTool(toolUrl)
30-
const extPath = await tc.extractZip(downloadPath)
31-
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
32-
core.addPath(cachedPath)
33-
break
34-
}
35-
36-
case 'linux': {
37-
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_linux_amd64.zip`
38-
const downloadPath = await tc.downloadTool(toolUrl)
39-
const extPath = await tc.extractZip(downloadPath)
40-
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
41-
core.addPath(cachedPath)
42-
break
43-
}
44-
45-
default: {
46-
core.setFailed(`Unsupported platform: ${process.platform}`)
47-
}
58+
const toolUrl = downloadUrl(version)
59+
if (toolUrl === '') {
60+
return
4861
}
62+
63+
const downloadPath = await tc.downloadTool(toolUrl)
64+
const extPath = await tc.extractZip(downloadPath)
65+
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
66+
core.addPath(cachedPath)
4967
} catch (error) {
5068
if (error instanceof Error) core.setFailed(error.message)
5169
}

0 commit comments

Comments
 (0)