Skip to content

Commit

Permalink
Merge pull request #98 from scalvert/openssl-version
Browse files Browse the repository at this point in the history
Adding optional input for openssl-version
  • Loading branch information
rwjblue authored Aug 30, 2022
2 parents f3297f5 + 2addefa commit f2a492b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ async function run(): Promise<void> {
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 });
Expand Down
10 changes: 10 additions & 0 deletions src/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
26 changes: 21 additions & 5 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ async function execOpenSSLVersion() {
}

async function getOpenSSLVersion(version = ''): Promise<string> {
const specificVersionViaInput = /^\d{1,3}\.\d{1,3}$/.test(version);

if (specificVersionViaInput) {
return `openssl-${version}`;
}

if (version === '') {
version = await execOpenSSLVersion();
}
Expand All @@ -79,8 +85,10 @@ async function getOpenSSLVersion(version = ''): Promise<string> {
);
}

version = match[2];

// should return in openssl-1.1 format
return `openssl-${match[2]}`;
return `openssl-${version}`;
}

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

async function acquireVolta(version: string, authToken: string): Promise<string> {
async function acquireVolta(
version: string,
authToken: string,
openSSLVersion: string
): Promise<string> {
//
// 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);
Expand Down Expand Up @@ -252,14 +264,18 @@ export async function getVoltaVersion(versionSpec: string): Promise<string> {
return version;
}

export async function getVolta(versionSpec: string, authToken: string): Promise<void> {
export async function getVolta(
versionSpec: string,
authToken: string,
openSSLVersion: string
): Promise<void> {
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);

Expand Down

0 comments on commit f2a492b

Please sign in to comment.