Skip to content

Commit 8cdc46f

Browse files
setup-ovr-platform-util@1.1.2 (#11)
- misc cleanup and refactoring
1 parent bb5e87d commit 8cdc46f

File tree

7 files changed

+125
-143
lines changed

7 files changed

+125
-143
lines changed

.github/workflows/validate.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ jobs:
3030
uses: ./
3131

3232
- run: 'ovr-platform-util version'
33-
shell: pwsh

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Setup OVR Platform Util
1+
# setup-ovr-platform-utility
22

3-
A GitHub Action to setup the [ovr platform utility tool](https://developer.oculus.com/resources/publish-reference-platform-command-line-utility/)
3+
A GitHub Action to setup the [`ovr-platform-utility`](https://developer.oculus.com/resources/publish-reference-platform-command-line-utility/) tool command alias.
44

55
## How to use
66

@@ -15,8 +15,10 @@ jobs:
1515
steps:
1616
# download and setup ovr platform util
1717
- uses: RageAgainstThePixel/setup-ovr-platform-util@v1
18-
1918
# run commands
2019
- run: 'ovr-platform-util version'
21-
shell: pwsh
2220
```
21+
22+
## Related actions
23+
24+
- [upload-meta-quest-build](https://github.com/RageAgainstThePixel/upload-meta-quest-build)

dist/index.js

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -33948,113 +33948,100 @@ module.exports = parseParams
3394833948
var __webpack_exports__ = {};
3394933949
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
3395033950
(() => {
33951-
const os = __nccwpck_require__(2037);
3395233951
const semver = __nccwpck_require__(1383);
3395333952
const path = __nccwpck_require__(1017);
3395433953
const core = __nccwpck_require__(2186);
3395533954
const tc = __nccwpck_require__(7784);
3395633955
const exec = __nccwpck_require__(1514);
33956+
const fs = (__nccwpck_require__(7147).promises);
3395733957

3395833958
const ovrPlatformUtil = 'ovr-platform-util';
3395933959
const IS_WINDOWS = process.platform === 'win32'
3396033960
const IS_MAC = process.platform === 'darwin'
33961+
const toolExtension = IS_WINDOWS ? '.exe' : '';
33962+
const toolPath = `${ovrPlatformUtil}${toolExtension}`;
3396133963

3396233964
const main = async () => {
3396333965
try {
33964-
const fileEx = IS_WINDOWS ? '.exe' : '';
33965-
let osPlatform = os.platform();
33966-
let pathToModule = undefined;
33967-
let pathToToolDir = tc.find(ovrPlatformUtil, '1.98.0');
33968-
33969-
if (!pathToToolDir) {
33970-
let url = undefined;
33971-
let downloadPath = undefined;
33972-
33973-
if (IS_MAC) {
33974-
url = 'https://www.oculus.com/download_app/?id=1462426033810370';
33975-
} else if (IS_WINDOWS) {
33976-
url = 'https://www.oculus.com/download_app/?id=1076686279105243';
33977-
} else {
33978-
throw Error(`${ovrPlatformUtil} not available for ${osPlatform}`);
33979-
}
33980-
33981-
let fileName = `${ovrPlatformUtil}${fileEx}`;
33982-
downloadPath = path.resolve(getTempDirectory(), fileName);
33983-
33984-
core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${downloadPath}`);
33985-
33986-
try {
33987-
downloadPath = await tc.downloadTool(url, downloadPath);
33988-
} catch (error) {
33989-
throw error;
33990-
}
33991-
33992-
core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${downloadPath}`);
33993-
33994-
if (IS_MAC) {
33995-
await exec.exec(`chmod +x ${downloadPath}`);
33996-
}
33997-
33998-
const downloadVersion = await getVersion(downloadPath);
33999-
core.debug(`Setting tool cache: ${downloadPath} | ${fileName} | ${ovrPlatformUtil} | ${downloadVersion}`);
34000-
pathToToolDir = await tc.cacheFile(downloadPath, fileName, ovrPlatformUtil, downloadVersion);
34001-
pathToModule = getExecutable(pathToToolDir);
34002-
} else {
34003-
pathToModule = getExecutable(pathToToolDir);
34004-
await exec.exec(pathToModule, 'self-update');
34005-
}
34006-
34007-
core.debug(`${ovrPlatformUtil} -> ${pathToModule}`);
34008-
core.addPath(pathToToolDir);
34009-
core.exportVariable(ovrPlatformUtil, pathToModule);
34010-
34011-
await exec.exec(pathToModule, 'help');
33966+
core.info(`Setting up ${ovrPlatformUtil}...`);
33967+
await setup_ovrPlatformUtil();
3401233968
} catch (error) {
3401333969
core.setFailed(error);
3401433970
}
3401533971
}
3401633972

3401733973
main();
3401833974

33975+
async function setup_ovrPlatformUtil() {
33976+
let toolDirectory = tc.find(ovrPlatformUtil, '*');
33977+
let tool = undefined;
33978+
if (!toolDirectory) {
33979+
const url = getDownloadUrl();
33980+
const archiveDownloadPath = path.resolve(getTempDirectory(), toolPath);
33981+
core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${archiveDownloadPath}`);
33982+
const archivePath = await tc.downloadTool(url, archiveDownloadPath);
33983+
core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${archivePath}`);
33984+
if (IS_MAC) {
33985+
await exec.exec(`chmod +x ${archivePath}`);
33986+
}
33987+
const downloadVersion = await getVersion(archivePath);
33988+
core.debug(`Setting tool cache: ${archivePath} | ${toolPath} | ${ovrPlatformUtil} | ${downloadVersion}`);
33989+
toolDirectory = await tc.cacheFile(archivePath, toolPath, ovrPlatformUtil, downloadVersion);
33990+
tool = getExecutable(toolDirectory);
33991+
} else {
33992+
tool = getExecutable(toolDirectory);
33993+
fs.access(tool);
33994+
core.debug(`Found ${tool} in ${toolDirectory}`);
33995+
await exec.exec(tool, 'self-update');
33996+
}
33997+
core.debug(`${ovrPlatformUtil} -> ${toolDirectory}`)
33998+
core.addPath(toolDirectory);
33999+
await exec.exec(ovrPlatformUtil, 'help');
34000+
}
34001+
34002+
function getDownloadUrl() {
34003+
if (IS_MAC) {
34004+
return 'https://www.oculus.com/download_app/?id=1462426033810370';
34005+
} else if (IS_WINDOWS) {
34006+
return 'https://www.oculus.com/download_app/?id=1076686279105243';
34007+
} else {
34008+
throw Error(`${ovrPlatformUtil} not available for ${process.platform}`);
34009+
}
34010+
}
34011+
3401934012
function getTempDirectory() {
3402034013
const tempDirectory = process.env['RUNNER_TEMP'] || ''
3402134014
return tempDirectory
3402234015
}
3402334016

34024-
function getExecutable(dir) {
34025-
const fileEx = IS_WINDOWS ? '.exe' : '';
34026-
const moduleName = `${ovrPlatformUtil}${fileEx}`;
34027-
return path.resolve(dir, moduleName);
34017+
function getExecutable(directory) {
34018+
return path.resolve(directory, toolPath);
3402834019
}
3402934020

34030-
async function getVersion(module) {
34021+
async function getVersion(tool) {
3403134022
const semVerRegEx = new RegExp(/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)?/);
3403234023
let output = '';
3403334024

34034-
await exec.exec(module, 'version', {
34025+
await exec.exec(tool, 'version', {
3403534026
listeners: {
3403634027
stdout: (data) => {
3403734028
output += data.toString();
3403834029
}
3403934030
}
3404034031
});
34041-
3404234032
const match = output.match(semVerRegEx)[0];
34043-
3404434033
if (!match) {
3404534034
throw Error("Failed to find a valid version match");
3404634035
}
34047-
3404834036
const lastPeriodIndex = match.lastIndexOf('.');
3404934037
const semVerStr = match.substring(0, lastPeriodIndex) + '+' + match.substring(lastPeriodIndex + 1);
3405034038
const version = semver.clean(semVerStr);
34051-
3405234039
if (!version) {
3405334040
throw Error("Failed to find a valid version");
3405434041
}
34055-
3405634042
return version
3405734043
}
34044+
3405834045
})();
3405934046

3406034047
module.exports = __webpack_exports__;

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
{
22
"name": "setup-ovr-platform-util",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "A GitHub Action to setup the ovr platform utility tool",
5+
"author": "RageAgainstThePixel",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/RageAgainstThePixel/setup-ovr-platform-util.git"
9+
},
10+
"license": "MIT",
11+
"bugs": {
12+
"url": "https://github.com/RageAgainstThePixel/setup-ovr-platform-util/issues"
13+
},
14+
"homepage": "https://github.com/RageAgainstThePixel/setup-ovr-platform-util#readme",
15+
"keywords": [
16+
"oculus",
17+
"ovr",
18+
"platform",
19+
"utility",
20+
"setup",
21+
"github",
22+
"action"
23+
],
524
"main": "src/index.js",
625
"dependencies": {
726
"@actions/core": "^1.10.1",
@@ -15,16 +34,5 @@
1534
"scripts": {
1635
"test": "echo \"Error: no test specified\" && exit 1",
1736
"build": "ncc build src/index.js -o dist --source-map --license licenses.txt"
18-
},
19-
"repository": {
20-
"type": "git",
21-
"url": "git+https://github.com/RageAgainstThePixel/setup-ovr-platform-util.git"
22-
},
23-
"keywords": [],
24-
"author": "Stephen Hodgson",
25-
"license": "MIT",
26-
"bugs": {
27-
"url": "https://github.com/RageAgainstThePixel/setup-ovr-platform-util/issues"
28-
},
29-
"homepage": "https://github.com/RageAgainstThePixel/setup-ovr-platform-util#readme"
30-
}
37+
}
38+
}

0 commit comments

Comments
 (0)