-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.ts
More file actions
executable file
·54 lines (48 loc) · 1.61 KB
/
main.ts
File metadata and controls
executable file
·54 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
async function run(): Promise<void> {
try {
const version = core.getInput('sqlc-version')
if (!version) {
core.setFailed(`sqlc-version not set`)
return
}
const toolDir = tc.find('sqlc', version, 'x64')
if (toolDir !== '') {
core.addPath(toolDir)
return
}
switch (process.platform) {
case 'win32': {
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_windows_amd64.zip`
const downloadPath = await tc.downloadTool(toolUrl)
const extPath = await tc.extractZip(downloadPath)
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
core.addPath(cachedPath)
break
}
case 'darwin': {
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_darwin_amd64.zip`
const downloadPath = await tc.downloadTool(toolUrl)
const extPath = await tc.extractZip(downloadPath)
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
core.addPath(cachedPath)
break
}
case 'linux': {
const toolUrl = `https://downloads.sqlc.dev/sqlc_${version}_linux_amd64.zip`
const downloadPath = await tc.downloadTool(toolUrl)
const extPath = await tc.extractZip(downloadPath)
const cachedPath = await tc.cacheDir(extPath, 'sqlc', version)
core.addPath(cachedPath)
break
}
default: {
core.setFailed(`Unsupported platform: ${process.platform}`)
}
}
} catch (error) {
core.setFailed(error.message)
}
}
run()