Skip to content

Commit

Permalink
bump up to v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Sep 18, 2019
1 parent 9c61286 commit 2a4f9b9
Show file tree
Hide file tree
Showing 173 changed files with 13,533 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/node_modules/
/lib/
/__test__/runner/
114 changes: 114 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
const core = __importStar(require("@actions/core"));
const tc = __importStar(require("@actions/tool-cache"));
const os = __importStar(require("os"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
const osPlat = os.platform();
const osArch = os.arch();
if (!tempDirectory) {
let baseLocation;
if (process.platform === 'win32') {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
const availableVersions = [
'5.30.0',
'5.28.2',
'5.28.1',
'5.28.0',
'5.26.3',
'5.26.2',
'5.26.1',
'5.26.0'
];
function determineVersion(version) {
for (let v of availableVersions) {
if (semver.satisfies(v, version)) {
return v;
}
}
throw new Error('unable to get latest version');
}
async function getPerl(version) {
const selected = determineVersion(version);
// check cache
let toolPath;
toolPath = tc.find('perl', selected);
if (!toolPath) {
// download, extract, cache
toolPath = await acquirePerl(selected);
core.debug('Perl tool is cached under ' + toolPath);
}
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
core.addPath(toolPath);
}
exports.getPerl = getPerl;
async function acquirePerl(version) {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
const fileName = getFileName(version);
const downloadUrl = await getDownloadUrl(fileName);
let downloadPath = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
}
catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Extract
//
let extPath = tempDirectory;
if (!extPath) {
throw new Error('Temp directory not set');
}
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
}
else {
extPath = await tc.extractTar(downloadPath);
}
return await tc.cacheDir(extPath, 'perl', version);
}
function getFileName(version) {
return `perl-${version}-${osPlat}-${osArch}.tar.gz`;
}
async function getDownloadUrl(filename) {
return new Promise((resolve, reject) => {
fs.readFile(path.join(__dirname, '..', 'package.json'), (err, data) => {
if (err) {
reject(err);
}
const info = JSON.parse(data.toString());
resolve(info);
});
}).then(info => {
const actionsVersion = info.version;
return `https://shogo82148-actions-setup-perl.s3.amazonaws.com/v${actionsVersion}/${filename}`;
});
}
26 changes: 26 additions & 0 deletions lib/setup-perl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const installer = __importStar(require("./installer"));
const path = __importStar(require("path"));
async function run() {
try {
const version = core.getInput('perl-version');
if (version) {
await installer.getPerl(version);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'perl.json')}`);
}
catch (error) {
core.setFailed(error.message);
}
}
run();
7 changes: 7 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a4f9b9

Please sign in to comment.