fix latest
This commit is contained in:
parent
d44adaf4fe
commit
67efaf1f63
1 changed files with 21 additions and 21 deletions
42
index.js
42
index.js
|
@ -1,48 +1,48 @@
|
||||||
const core = require('@actions/core');
|
const core = require("@actions/core");
|
||||||
const tc = require('@actions/tool-cache');
|
const tc = require("@actions/tool-cache");
|
||||||
const io = require('@actions/io');
|
const io = require("@actions/io");
|
||||||
const exec = require('@actions/exec');
|
const exec = require("@actions/exec");
|
||||||
|
|
||||||
|
|
||||||
// most @actions toolkit packages have async methods
|
// most @actions toolkit packages have async methods
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
let hugoVersion = core.getInput('hugo-version');
|
let hugoVersion = core.getInput("hugo-version");
|
||||||
if (!hugoVersion) {
|
if (!hugoVersion) {
|
||||||
|
hugoVersion = "latest";
|
||||||
|
} else if (hugoVersion === "latest") {
|
||||||
// TODO: get latest version of Hugo
|
// TODO: get latest version of Hugo
|
||||||
hugoVersion = '0.58.2';
|
hugoVersion = "0.58.2";
|
||||||
}
|
}
|
||||||
core.debug('Hugo version:', hugoVersion);
|
core.debug("Hugo version:", hugoVersion);
|
||||||
|
|
||||||
let extended = core.getInput('extended');
|
let extended = core.getInput("extended");
|
||||||
if (!extended) {
|
if (!extended) {
|
||||||
extended = false;
|
extended = false;
|
||||||
}
|
}
|
||||||
core.debug('Hugo extended:', extended);
|
core.debug("Hugo extended:", extended);
|
||||||
|
|
||||||
let extendedStr = '';
|
let extendedStr = "";
|
||||||
if (extended) {
|
if (extended) {
|
||||||
extendedStr = 'extended_';
|
extendedStr = "extended_";
|
||||||
}
|
}
|
||||||
|
|
||||||
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
|
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
|
||||||
core.debug('hugoName:', hugoName);
|
core.debug("hugoName:", hugoName);
|
||||||
|
|
||||||
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;
|
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;
|
||||||
core.debug('hugoURL:', hugoURL);
|
core.debug("hugoURL:", hugoURL);
|
||||||
|
|
||||||
const hugoPath = '/usr/local/bin';
|
const hugoPath = "/usr/local/bin";
|
||||||
await io.mkdirP(hugoPath);
|
await io.mkdirP(hugoPath);
|
||||||
|
|
||||||
// Download and extract Hugo binary
|
// Download and extract Hugo binary
|
||||||
const hugoTarball = await tc.downloadTool(hugoURL);
|
const hugoTarball = await tc.downloadTool(hugoURL);
|
||||||
const hugoExtractedFolder = await tc.extractTar(hugoTarball, '/tmp');
|
const hugoExtractedFolder = await tc.extractTar(hugoTarball, "/tmp");
|
||||||
core.debug('hugoExtractedFolder:', hugoExtractedFolder);
|
core.debug("hugoExtractedFolder:", hugoExtractedFolder);
|
||||||
await exec.exec('sudo', ['mv', `${hugoExtractedFolder}/hugo`, hugoPath]);
|
await exec.exec("sudo", ["mv", `${hugoExtractedFolder}/hugo`, hugoPath]);
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
run();
|
||||||
|
|
Loading…
Reference in a new issue