Skip to content

Commit

Permalink
Merge pull request digitalocean#77 from digitalocean/asb/issues/76
Browse files Browse the repository at this point in the history
Use process over os for backwards compatibility.
  • Loading branch information
andrewsomething authored Aug 28, 2023
2 parents 595d91d + d6c4a6e commit cf10ddb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
24 changes: 11 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17455,7 +17455,6 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const os = __nccwpck_require__(2037);
const core = __nccwpck_require__(2186);
const exec = __nccwpck_require__(1514);
const tc = __nccwpck_require__(7784);
Expand All @@ -17465,40 +17464,39 @@ const baseDownloadURL = "https://github.com/digitalocean/doctl/releases/download
const fallbackVersion = "1.98.1";
const octokit = new Octokit();

async function downloadDoctl(version, osType, osMachine) {
async function downloadDoctl(version, type, architecture) {
var platform = 'linux';
var arch = 'amd64';
var extension = 'tar.gz';

switch (osType) {
case 'Darwin':
switch (type) {
case 'darwin':
platform = 'darwin';
break;
case 'Windows_NT':
case 'win32':
platform = 'windows';
extension = 'zip'
break;
case 'Linux':
case 'linux':
platform = 'linux';
break;
default:
core.warning(`unknown platform: ${osType}; defaulting to ${platform}`);
core.warning(`unknown platform: ${type}; defaulting to ${platform}`);
break;
}

switch (osMachine) {
switch (architecture) {
case 'arm64':
arch = 'arm64';
break;
case 'x86_64':
case 'x64':
arch = 'amd64';
break;
case 'i386':
case 'i686':
case 'ia32':
arch = '386';
break;
default:
core.warning(`unknown architecture: ${osMachine}; defaulting to ${arch}`);
core.warning(`unknown architecture: ${architecture}; defaulting to ${arch}`);
break;
}

Expand Down Expand Up @@ -17534,7 +17532,7 @@ Failed to retrieve latest version; falling back to: ${fallbackVersion}`);

var path = tc.find("doctl", version);
if (!path) {
const installPath = await downloadDoctl(version, os.type(), os.machine());
const installPath = await downloadDoctl(version, process.platform, process.arch);
path = await tc.cacheDir(installPath, 'doctl', version);
}
core.addPath(path);
Expand Down
24 changes: 11 additions & 13 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const os = require('os');
const core = require('@actions/core');
const exec = require('@actions/exec');
const tc = require('@actions/tool-cache');
Expand All @@ -8,40 +7,39 @@ const baseDownloadURL = "https://github.com/digitalocean/doctl/releases/download
const fallbackVersion = "1.98.1";
const octokit = new Octokit();

async function downloadDoctl(version, osType, osMachine) {
async function downloadDoctl(version, type, architecture) {
var platform = 'linux';
var arch = 'amd64';
var extension = 'tar.gz';

switch (osType) {
case 'Darwin':
switch (type) {
case 'darwin':
platform = 'darwin';
break;
case 'Windows_NT':
case 'win32':
platform = 'windows';
extension = 'zip'
break;
case 'Linux':
case 'linux':
platform = 'linux';
break;
default:
core.warning(`unknown platform: ${osType}; defaulting to ${platform}`);
core.warning(`unknown platform: ${type}; defaulting to ${platform}`);
break;
}

switch (osMachine) {
switch (architecture) {
case 'arm64':
arch = 'arm64';
break;
case 'x86_64':
case 'x64':
arch = 'amd64';
break;
case 'i386':
case 'i686':
case 'ia32':
arch = '386';
break;
default:
core.warning(`unknown architecture: ${osMachine}; defaulting to ${arch}`);
core.warning(`unknown architecture: ${architecture}; defaulting to ${arch}`);
break;
}

Expand Down Expand Up @@ -77,7 +75,7 @@ Failed to retrieve latest version; falling back to: ${fallbackVersion}`);

var path = tc.find("doctl", version);
if (!path) {
const installPath = await downloadDoctl(version, os.type(), os.machine());
const installPath = await downloadDoctl(version, process.platform, process.arch);
path = await tc.cacheDir(installPath, 'doctl', version);
}
core.addPath(path);
Expand Down

0 comments on commit cf10ddb

Please sign in to comment.