-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
99 lines (83 loc) · 2.28 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const core = require('@actions/core')
const exec = require('@actions/exec')
const os = require('os')
try {
main()
} catch (error) {
core.setFailed(error.message);
}
async function installXcodegen() {
const xcodegenDir = os.homedir() + '/action-xcodegen/'
const zipFile = xcodegenDir + 'xcodegen.zip'
const version = core.getInput('version')
const url = version === 'latest'
? 'https://github.com/yonaskolb/XcodeGen/releases/latest/download/xcodegen.zip'
: `https://github.com/yonaskolb/XcodeGen/releases/download/${version}/xcodegen.zip`
await exec.exec('curl', [
'--silent',
'--create-dirs',
'--location',
'--output',
zipFile,
url
])
await exec.exec('unzip', ['-q', '-o', zipFile], { cwd: xcodegenDir })
await exec.exec('rm', [zipFile])
await exec.exec('sudo', ['chown', 'runner:admin', '/usr/local/share'])
await exec.exec('xcodegen/install.sh', null, { cwd: xcodegenDir })
await exec.exec('rm -rf', [xcodegenDir])
}
async function runXcodegen() {
const input = {
cachePath: core.getInput('cache-path'),
noEnv: core.getInput('no-env'),
onlyPlists: core.getInput('only-plists'),
project: core.getInput('project'),
projectRoot: core.getInput('project-root'),
quiet: core.getInput('quiet'),
spec: core.getInput('spec'),
useCache: core.getInput('use-cache')
}
let options = []
if (input.cachePath) {
options.push('--cache-path')
options.push(input.cachePath)
}
if (input.noEnv) {
options.push('--no-env')
}
if (input.onlyPlists) {
options.push('--only-plists')
}
if (input.project) {
options.push('--project')
options.push(input.project)
}
if (input.projectRoot) {
options.push('--project-root')
options.push(input.projectRoot)
}
if (input.quiet) {
options.push('--quiet')
}
if (input.spec) {
options.push('--spec')
options.push(input.spec)
}
if (input.useCache) {
options.push('--use-cache')
}
await exec.exec('xcodegen', options)
}
async function main() {
const input = {
install: core.getInput('install'),
run: core.getInput('run'),
}
if (!input.install || input.install === 'true') {
await installXcodegen()
}
if (!input.run || input.run === 'true') {
await runXcodegen()
}
}