generated from dkoshkin/golang-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoke-binary.js
40 lines (35 loc) · 1.17 KB
/
invoke-binary.js
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
const childProcess = require('child_process')
const os = require('os')
const fs = require("fs")
const process = require('process')
const core = require('@actions/core');
function chooseBinary() {
const platform = os.platform()
const arch = os.arch()
// otherwise assume it's a released version
if (platform === 'linux' && arch === 'x64') {
return `bin/status-writer-action_linux_amd64`
}
if (platform === 'linux' && arch === 'arm64') {
return `bin/status-writer-action_linux_arm64`
}
if (platform === 'darwin' && arch === 'x64') {
return `bin/status-writer-action_darwin_amd64`
}
if (platform === 'darwin' && arch === 'arm64') {
return `bin/status-writer-action_darwin_arm64`
}
core.setFailed(`Unsupported platform (${platform}) and architecture (${arch})`)
}
function main() {
const binary = chooseBinary()
const mainScript = `${__dirname}/${binary}`
const spawnSyncReturns = childProcess.spawnSync(mainScript, { stdio: 'inherit' })
const status = spawnSyncReturns.status
if (status !== 0) {
core.setFailed(spawnSyncReturns.error)
}
}
if (require.main === module) {
main()
}