diff --git a/action.yml b/action.yml index f48074c4..407c2ad5 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,9 @@ inputs: yarn-version: description: 'Version Spec of the yarn version to use. Examples: 1.6.x, 10.15.1, >=10.15.0' default: '' + openssl-version: + description: 'Version Spec of the openssl version to use. Examples: 1.0, 1.1' + default: '' registry-url: description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc file, and set up auth to read in from env.NODE_AUTH_TOKEN' scope: diff --git a/src/index.ts b/src/index.ts index 12c044f9..270b2477 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,9 @@ async function run(): Promise { try { const authToken = core.getInput('token', { required: false }); const voltaVersion = core.getInput('volta-version', { required: false }); + const openSSLVersion = core.getInput('openssl-version', { required: false }); - await installer.getVolta(voltaVersion, authToken); + await installer.getVolta(voltaVersion, authToken, openSSLVersion); const hasPackageJSON = await findUp('package.json'); const nodeVersion = core.getInput('node-version', { required: false }); diff --git a/src/installer.test.ts b/src/installer.test.ts index f6b37c1f..7059bde6 100644 --- a/src/installer.test.ts +++ b/src/installer.test.ts @@ -23,6 +23,16 @@ describe('buildDownloadUrl', () => { ); }); + test('linux with openssl-version input', async function () { + expect(await buildDownloadUrl('linux', '0.6.4', '1.0')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"` + ); + + expect(await buildDownloadUrl('linux', '0.6.4', '1.1')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"` + ); + }); + test('win32', async function () { expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot( `"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"` diff --git a/src/installer.ts b/src/installer.ts index d2e8d5e3..21373594 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -65,6 +65,12 @@ async function execOpenSSLVersion() { } async function getOpenSSLVersion(version = ''): Promise { + const specificVersionViaInput = /^\d{1,3}\.\d{1,3}$/.test(version); + + if (specificVersionViaInput) { + return `openssl-${version}`; + } + if (version === '') { version = await execOpenSSLVersion(); } @@ -79,8 +85,10 @@ async function getOpenSSLVersion(version = ''): Promise { ); } + version = match[2]; + // should return in openssl-1.1 format - return `openssl-${match[2]}`; + return `openssl-${version}`; } /* @@ -131,14 +139,18 @@ export async function buildLayout(voltaHome: string): Promise { await setupShims(voltaHome); } -async function acquireVolta(version: string, authToken: string): Promise { +async function acquireVolta( + version: string, + authToken: string, + openSSLVersion: string +): Promise { // // Download - a tool installer intimately knows how to get the tool (and construct urls) // core.info(`downloading volta@${version}`); - const downloadUrl = await buildDownloadUrl(os.platform(), version); + const downloadUrl = await buildDownloadUrl(os.platform(), version, openSSLVersion); core.debug(`downloading from \`${downloadUrl}\``); const downloadPath = await tc.downloadTool(downloadUrl, undefined, authToken); @@ -252,14 +264,18 @@ export async function getVoltaVersion(versionSpec: string): Promise { return version; } -export async function getVolta(versionSpec: string, authToken: string): Promise { +export async function getVolta( + versionSpec: string, + authToken: string, + openSSLVersion: string +): Promise { const version = await getVoltaVersion(versionSpec); let voltaHome = tc.find('volta', version); if (voltaHome === '') { // download, extract, cache - const toolRoot = await acquireVolta(version, authToken); + const toolRoot = await acquireVolta(version, authToken, openSSLVersion); await setupVolta(version, toolRoot);