Skip to content

Commit f2a492b

Browse files
author
Robert Jackson
authored
Merge pull request #98 from scalvert/openssl-version
Adding optional input for openssl-version
2 parents f3297f5 + 2addefa commit f2a492b

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ inputs:
1414
yarn-version:
1515
description: 'Version Spec of the yarn version to use. Examples: 1.6.x, 10.15.1, >=10.15.0'
1616
default: ''
17+
openssl-version:
18+
description: 'Version Spec of the openssl version to use. Examples: 1.0, 1.1'
19+
default: ''
1720
registry-url:
1821
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'
1922
scope:

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ async function run(): Promise<void> {
88
try {
99
const authToken = core.getInput('token', { required: false });
1010
const voltaVersion = core.getInput('volta-version', { required: false });
11+
const openSSLVersion = core.getInput('openssl-version', { required: false });
1112

12-
await installer.getVolta(voltaVersion, authToken);
13+
await installer.getVolta(voltaVersion, authToken, openSSLVersion);
1314

1415
const hasPackageJSON = await findUp('package.json');
1516
const nodeVersion = core.getInput('node-version', { required: false });

src/installer.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ describe('buildDownloadUrl', () => {
2323
);
2424
});
2525

26+
test('linux with openssl-version input', async function () {
27+
expect(await buildDownloadUrl('linux', '0.6.4', '1.0')).toMatchInlineSnapshot(
28+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
29+
);
30+
31+
expect(await buildDownloadUrl('linux', '0.6.4', '1.1')).toMatchInlineSnapshot(
32+
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
33+
);
34+
});
35+
2636
test('win32', async function () {
2737
expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
2838
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`

src/installer.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ async function execOpenSSLVersion() {
6565
}
6666

6767
async function getOpenSSLVersion(version = ''): Promise<string> {
68+
const specificVersionViaInput = /^\d{1,3}\.\d{1,3}$/.test(version);
69+
70+
if (specificVersionViaInput) {
71+
return `openssl-${version}`;
72+
}
73+
6874
if (version === '') {
6975
version = await execOpenSSLVersion();
7076
}
@@ -79,8 +85,10 @@ async function getOpenSSLVersion(version = ''): Promise<string> {
7985
);
8086
}
8187

88+
version = match[2];
89+
8290
// should return in openssl-1.1 format
83-
return `openssl-${match[2]}`;
91+
return `openssl-${version}`;
8492
}
8593

8694
/*
@@ -131,14 +139,18 @@ export async function buildLayout(voltaHome: string): Promise<void> {
131139
await setupShims(voltaHome);
132140
}
133141

134-
async function acquireVolta(version: string, authToken: string): Promise<string> {
142+
async function acquireVolta(
143+
version: string,
144+
authToken: string,
145+
openSSLVersion: string
146+
): Promise<string> {
135147
//
136148
// Download - a tool installer intimately knows how to get the tool (and construct urls)
137149
//
138150

139151
core.info(`downloading volta@${version}`);
140152

141-
const downloadUrl = await buildDownloadUrl(os.platform(), version);
153+
const downloadUrl = await buildDownloadUrl(os.platform(), version, openSSLVersion);
142154

143155
core.debug(`downloading from \`${downloadUrl}\``);
144156
const downloadPath = await tc.downloadTool(downloadUrl, undefined, authToken);
@@ -252,14 +264,18 @@ export async function getVoltaVersion(versionSpec: string): Promise<string> {
252264
return version;
253265
}
254266

255-
export async function getVolta(versionSpec: string, authToken: string): Promise<void> {
267+
export async function getVolta(
268+
versionSpec: string,
269+
authToken: string,
270+
openSSLVersion: string
271+
): Promise<void> {
256272
const version = await getVoltaVersion(versionSpec);
257273

258274
let voltaHome = tc.find('volta', version);
259275

260276
if (voltaHome === '') {
261277
// download, extract, cache
262-
const toolRoot = await acquireVolta(version, authToken);
278+
const toolRoot = await acquireVolta(version, authToken, openSSLVersion);
263279

264280
await setupVolta(version, toolRoot);
265281

0 commit comments

Comments
 (0)