Skip to content

Commit

Permalink
setup-ovr-platform-util@v1.0.4 (#5)
Browse files Browse the repository at this point in the history
- Add linux platform support
  • Loading branch information
StephenHodgson authored Sep 27, 2024
1 parent 09140cf commit 2581324
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: buildalon/setup-ovr-platform-util
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ A GitHub Action to setup the [`ovr-platform-utility`](https://developer.oculus.c
## How to use

```yaml
jobs:
validate:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest, macos, windows ]
steps:
# download and setup ovr platform util
- uses: buildalon/setup-ovr-platform-util@v1
Expand Down
17 changes: 13 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33246,6 +33246,7 @@ const fs = __nccwpck_require__(7147);
const ovrPlatformUtil = 'ovr-platform-util';
const IS_WINDOWS = process.platform === 'win32';
const IS_MAC = process.platform === 'darwin';
const IS_LINUX = process.platform === 'linux';
const toolExtension = IS_WINDOWS ? '.exe' : '';
const toolPath = `${ovrPlatformUtil}${toolExtension}`;
const main = async () => {
Expand All @@ -33259,15 +33260,21 @@ const main = async () => {
};
main();
async function setup_ovrPlatformUtil() {
let toolDirectory = tc.find(ovrPlatformUtil, '*');
let toolDirectory = undefined;
try {
toolDirectory = tc.find(ovrPlatformUtil, '*');
}
catch (error) {
core.debug(`Failed to find ${ovrPlatformUtil} in cache: ${error.message}`);
}
let tool = undefined;
if (!toolDirectory) {
const url = getDownloadUrl();
const archiveDownloadPath = path.resolve(getTempDirectory(), toolPath);
core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${archiveDownloadPath}`);
const archivePath = await tc.downloadTool(url, archiveDownloadPath);
core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${archivePath}`);
if (IS_MAC) {
if (IS_MAC || IS_LINUX) {
await exec.exec(`chmod +x ${archivePath}`);
}
const downloadVersion = await getVersion(archivePath);
Expand Down Expand Up @@ -33309,13 +33316,15 @@ function getDownloadUrl() {
else if (IS_WINDOWS) {
return 'https://www.oculus.com/download_app/?id=1076686279105243';
}
else if (IS_LINUX) {
return 'https://www.oculus.com/download_app/?id=5159709737372459';
}
else {
throw Error(`${ovrPlatformUtil} not available for ${process.platform}`);
}
}
function getTempDirectory() {
const tempDirectory = process.env['RUNNER_TEMP'] || '';
return tempDirectory;
return process.env['RUNNER_TEMP'] || '';
}
async function getExecutable(directory) {
const tool = path.join(directory, toolPath);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-ovr-platform-util",
"version": "1.0.3",
"version": "1.0.4",
"description": "A GitHub Action to setup the ovr-platform-util tool command alias.",
"author": "buildalon",
"repository": {
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import fs = require('fs');
const ovrPlatformUtil = 'ovr-platform-util';
const IS_WINDOWS = process.platform === 'win32'
const IS_MAC = process.platform === 'darwin'
const IS_LINUX = process.platform === 'linux'
const toolExtension = IS_WINDOWS ? '.exe' : '';
const toolPath = `${ovrPlatformUtil}${toolExtension}`;

Expand All @@ -23,15 +24,20 @@ const main = async () => {
main();

async function setup_ovrPlatformUtil(): Promise<void> {
let toolDirectory = tc.find(ovrPlatformUtil, '*');
let toolDirectory = undefined;
try {
toolDirectory = tc.find(ovrPlatformUtil, '*');
} catch (error) {
core.debug(`Failed to find ${ovrPlatformUtil} in cache: ${error.message}`);
}
let tool = undefined;
if (!toolDirectory) {
const url = getDownloadUrl();
const archiveDownloadPath = path.resolve(getTempDirectory(), toolPath);
core.debug(`Attempting to download ${ovrPlatformUtil} from ${url} to ${archiveDownloadPath}`);
const archivePath = await tc.downloadTool(url, archiveDownloadPath);
core.debug(`Successfully downloaded ${ovrPlatformUtil} to ${archivePath}`);
if (IS_MAC) {
if (IS_MAC || IS_LINUX) {
await exec.exec(`chmod +x ${archivePath}`);
}
const downloadVersion = await getVersion(archivePath);
Expand Down Expand Up @@ -70,14 +76,15 @@ function getDownloadUrl(): string {
return 'https://www.oculus.com/download_app/?id=1462426033810370';
} else if (IS_WINDOWS) {
return 'https://www.oculus.com/download_app/?id=1076686279105243';
} else if (IS_LINUX) {
return 'https://www.oculus.com/download_app/?id=5159709737372459';
} else {
throw Error(`${ovrPlatformUtil} not available for ${process.platform}`);
}
}

function getTempDirectory(): string {
const tempDirectory = process.env['RUNNER_TEMP'] || ''
return tempDirectory
return process.env['RUNNER_TEMP'] || ''
}

async function getExecutable(directory: string): Promise<string> {
Expand All @@ -90,7 +97,6 @@ async function getExecutable(directory: string): Promise<string> {
async function getVersion(tool: string): Promise<string> {
const semVerRegEx = new RegExp(/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)?/);
let output = '';

await exec.exec(tool, ['version'], {
listeners: {
stdout: (data) => {
Expand Down

0 comments on commit 2581324

Please sign in to comment.