mirror of
https://github.com/GoTestTools/gotestfmt-action.git
synced 2026-02-17 13:11:46 +00:00
Extract archive directly into workspace
Signed-off-by: Yuri Norwood <106889957+norwd@users.noreply.github.com>
This commit is contained in:
parent
7becac8391
commit
3988f359dc
1 changed files with 3 additions and 12 deletions
15
index.js
15
index.js
|
|
@ -13,16 +13,10 @@ async function downloadRelease(octokit, os, org, repo, release, token) {
|
||||||
// Determine environment specific details, paths etc...
|
// Determine environment specific details, paths etc...
|
||||||
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
|
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
|
||||||
const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/";
|
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 extract = os === "windows" ? "tar -xvf" : "tar -xvzf";
|
||||||
const binfile = os === "windows" ? "gotestfmt.exe" : "gotestfmt";
|
const binfile = os === "windows" ? "gotestfmt.exe" : "gotestfmt";
|
||||||
const archive = `${tempdir}gotestfmt${postfix}`;
|
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
|
// Search through the latest release assets for an install canidate
|
||||||
for (let asset of releaseAssets.data) {
|
for (let asset of releaseAssets.data) {
|
||||||
// Check if the asset name matches the determined postfix
|
// 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
|
// Extract the archive into the install target
|
||||||
console.log("Unpacking archive file...")
|
console.log("Unpacking archive file...")
|
||||||
|
core.addPath(process.env.GITHUB_WORKSPACE)
|
||||||
|
process.chdir(process.env.GITHUB_WORKSPACE)
|
||||||
execSync(`${extract} "${archive}"`)
|
execSync(`${extract} "${archive}"`)
|
||||||
fs.copyFile(binfile, `${binpath}${binfile}`, fs.constants.COPYFILE_EXCL, function (err) {
|
fs.readdirSync(process.env.GITHUB_WORKSPACE).forEach(file => {
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs.readdirSync(binpath).forEach(file => {
|
|
||||||
console.log("Installed: " + file);
|
console.log("Installed: " + file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue