forked from AckeeCZ/load-xcode-version
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (19 loc) · 807 Bytes
/
index.js
File metadata and controls
27 lines (19 loc) · 807 Bytes
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
const core = require('@actions/core');
const { execSync } = require("child_process");
const fs = require('fs');
try {
const location = core.getInput('xcode_version_location');
console.log(`Reading Xcode version from ${location}`);
const xcodeFileContent = fs.readFileSync(location, 'utf8');
const xcodeVersion = xcodeFileContent.trim();
core.setOutput("xcode_version", xcodeVersion);
console.log(`Loaded Xcode version is ${xcodeVersion}`);
const autoselect = core.getInput("autoselect_xcode")
if (autoselect == 'true') {
const xcodePath = `/Applications/Xcode_${xcodeVersion}.app`
console.log(`Selecting Xcode at ${xcodePath}`)
execSync(`sudo xcode-select -switch ${xcodePath}`)
}
} catch (error) {
core.setFailed(error.message);
}