Extract archive directly into workspace

Signed-off-by: Yuri Norwood <106889957+norwd@users.noreply.github.com>
This commit is contained in:
Yuri Norwood 2022-11-07 16:35:45 +13:00 committed by GitHub
parent 7becac8391
commit 3988f359dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,16 +13,10 @@ async function downloadRelease(octokit, os, org, repo, release, token) {
// Determine environment specific details, paths etc...
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/";
const binpath = os === "windows" ? "C:\\Program Files\\GoTestTools\\bin\\" : "/usr/local/bin/";
const extract = os === "windows" ? "tar -xvf" : "tar -xvzf";
const binfile = os === "windows" ? "gotestfmt.exe" : "gotestfmt";
const archive = `${tempdir}gotestfmt${postfix}`;
if (os === "windows") {
fs.mkdirSync(binpath, { recursive: true })
execSync(`echo "${binpath}" >> ${process.env.GITHUB_PATH}`)
}
// Search through the latest release assets for an install canidate
for (let asset of releaseAssets.data) {
// Check if the asset name matches the determined postfix
@ -40,13 +34,10 @@ async function downloadRelease(octokit, os, org, repo, release, token) {
// Extract the archive into the install target
console.log("Unpacking archive file...")
core.addPath(process.env.GITHUB_WORKSPACE)
process.chdir(process.env.GITHUB_WORKSPACE)
execSync(`${extract} "${archive}"`)
fs.copyFile(binfile, `${binpath}${binfile}`, fs.constants.COPYFILE_EXCL, function (err) {
if (err) {
throw err;
}
});
fs.readdirSync(binpath).forEach(file => {
fs.readdirSync(process.env.GITHUB_WORKSPACE).forEach(file => {
console.log("Installed: " + file);
});