Add support for protoc and grpc_php_plugin

This commit is contained in:
Shivam Mathur
2020-07-31 20:43:06 +05:30
parent e63d25d41f
commit cb25b9c13a
9 changed files with 253 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import * as utils from './utils';
import * as httpm from '@actions/http-client';
import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces';
import * as path from 'path';
/**
* Function to get command to setup tools
@ -38,6 +39,8 @@ export async function getToolVersion(version: string): Promise<string> {
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, '');
switch (true) {
case version.charAt(0) == 'v':
return version.replace('v', '');
case composer_regex.test(version):
case semver_regex.test(version):
return version;
@ -439,6 +442,27 @@ export async function addPackage(
return tool_command + tool + ' ' + release + ' ' + prefix;
}
/**
* Function to get script to add tools with custom support.
*
* @param tool
* @param version
* @param os_version
*/
export async function addCustomTool(
tool: string,
version: string,
os_version: string
): Promise<string> {
const script_extension: string = await utils.scriptExtension(os_version);
const script: string = path.join(
__dirname,
'../src/scripts/tools/' + tool + script_extension
);
const command: string = await getCommand(os_version, tool);
return '. ' + script + '\n' + command + version;
}
/**
* Setup tools
*
@ -522,6 +546,10 @@ export async function addTools(
case 'flex':
script += await addPackage(tool, release, 'symfony/', os_version);
break;
case 'grpc_php_plugin':
case 'protoc':
script += await addCustomTool(tool, version, os_version);
break;
case 'infection':
url = github + 'infection/infection/' + uri;
script += await addArchive(tool, version, url, os_version);