Skip to content

Commit

Permalink
setup-ovr-platform-util@v1.1.6 (#20)
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 226103f commit 43dd0d3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 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, macos, windows ]
os: [ubuntu-latest, macos-latest, windows-latest, macos, windows]
steps:
- uses: actions/checkout@v4
- name: RageAgainstThePixel/setup-ovr-platform-util
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest, macos, windows ]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
# download and setup ovr platform util
- uses: RageAgainstThePixel/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 @@ -33961,6 +33961,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 @@ -33974,15 +33975,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 @@ -34024,13 +34031,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.1.5",
"version": "1.1.6",
"description": "A GitHub Action to setup the ovr-platform-util tool command alias.",
"author": "RageAgainstThePixel",
"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 43dd0d3

Please sign in to comment.