This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
54 lines (44 loc) · 1.46 KB
/
main.ts
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 exec from '@actions/exec'
import * as tc from '@actions/tool-cache'
import * as fs from 'fs'
import * as os from 'os'
async function run(): Promise<void> {
try {
const installerUrl = core.getInput('installer')
const unityVersion = core.getInput('version')
let UnityPath = tc.find('unity', unityVersion, os.platform())
if (UnityPath != null) {
const UnitySetup64 = await tc.downloadTool(
installerUrl,
'.\\UnitySetup.exe'
)
core.debug(`Running under ${os.platform()}`)
const exitCode = await exec.exec(fs.realpathSync(UnitySetup64), [
'/S'
])
core.debug(`exit code ${exitCode}`)
UnityPath = await tc.cacheDir(
'C:\\Program Files\\Unity',
'unity',
unityVersion,
os.platform()
)
}
core.addPath(`${UnityPath}\\Editor`)
const license = core.getInput('license')
if (license !== '' && license !== null) {
fs.writeFileSync('unity-license.ulf', license)
await exec.exec('Unity.exe', [
'-nographics',
'-quit',
'-batchmode',
'-manualLicenseFile',
'unity-license.ulf'
])
}
} catch (error) {
core.setFailed(error.message)
}
}
run()