From afb487ab13f62b918325b34a9521348ba81ffd17 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 12 Jun 2024 16:51:43 +0100 Subject: [PATCH] fix: download url --- action/dist/index.js | 38 ++++++++++++++++++++++++++++++++------ action/src/index.js | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/action/dist/index.js b/action/dist/index.js index 89daf30..291a753 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -30693,13 +30693,39 @@ const tc = __nccwpck_require__(7784); * @returns {Promise} */ async function getDownloadURL(version) { - // Get the platform (i.e. linux, darwin, win32) - const platform = process.platform; - // Get the architecture (i.e. x64, arm64) - const arch = process.arch; + let platform; - core.info(`Platform: ${platform}, Arch: ${arch}`) - const url = `https://github.com/vechain/networkhub/releases/download/${version}/network-hub-${platform}-${arch}${platform === 'win32' ? '.exe' : ''}`; + switch (process.platform) { + case 'win32': + platform = 'windows'; + break; + case 'darwin': + platform = 'macos'; + break; + case 'linux': + platform = 'linux'; + break; + default: + throw new Error(`Unsupported platform: ${process.platform}`); + } + + let arch; + + switch (process.arch) { + case 'x64': + arch = 'amd64'; + break; + case 'arm64': + arch = 'arm64'; + break; + default: + throw new Error(`Unsupported architecture: ${process.arch}`); + } + + core.info(`Platform: ${platform}`) + core.info(`Arch: ${arch}`) + + const url = `https://github.com/vechain/networkhub/releases/download/${version}/network-hub-${platform}-${arch}${process.platform === 'win32' ? '.exe' : ''}`; core.info(`Download URL: ${url}`) return url; } diff --git a/action/src/index.js b/action/src/index.js index 4ef6fb1..17786da 100644 --- a/action/src/index.js +++ b/action/src/index.js @@ -7,13 +7,39 @@ const tc = require('@actions/tool-cache'); * @returns {Promise} */ async function getDownloadURL(version) { - // Get the platform (i.e. linux, darwin, win32) - const platform = process.platform; - // Get the architecture (i.e. x64, arm64) - const arch = process.arch; + let platform; - core.info(`Platform: ${platform}, Arch: ${arch}`) - const url = `https://github.com/vechain/networkhub/releases/download/${version}/network-hub-${platform}-${arch}${platform === 'win32' ? '.exe' : ''}`; + switch (process.platform) { + case 'win32': + platform = 'windows'; + break; + case 'darwin': + platform = 'macos'; + break; + case 'linux': + platform = 'linux'; + break; + default: + throw new Error(`Unsupported platform: ${process.platform}`); + } + + let arch; + + switch (process.arch) { + case 'x64': + arch = 'amd64'; + break; + case 'arm64': + arch = 'arm64'; + break; + default: + throw new Error(`Unsupported architecture: ${process.arch}`); + } + + core.info(`Platform: ${platform}`) + core.info(`Arch: ${arch}`) + + const url = `https://github.com/vechain/networkhub/releases/download/${version}/network-hub-${platform}-${arch}${process.platform === 'win32' ? '.exe' : ''}`; core.info(`Download URL: ${url}`) return url; }