Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow explicitly specifying openssl-version (on self-hosted environments the openssl command may not be on $PATH) #98

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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