Skip to content

Commit

Permalink
fix: getting latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
everythingfunctional committed Nov 5, 2021
1 parent 7235df1 commit 491d550
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function main(){

// Get latest version if requested
if (fpmVersion === 'latest'){

if (token === 'none') {
core.setFailed('To fetch the latest fpm version, please supply a github token. Alternatively you can specify the fpm release version manually.');
}
Expand All @@ -48,48 +48,48 @@ async function main(){

console.log(`This platform is ${process.platform}`);
console.log(`Fetching fpm from ${fetchPath}${filename}`);

// Download release
var fpmPath;
try {

fpmPath = await tc.downloadTool(fetchPath+filename);

} catch (error) {

core.setFailed(`Error while trying to fetch fpm - please check that a version exists at the above release url.`);

}

console.log(fpmPath);
const downloadDir = path.dirname(fpmPath);

// Add executable flag on unix
if (process.platform === 'linux' || process.platform === 'darwin'){

await exec.exec('chmod u+x '+fpmPath);

}

// Rename to 'fpm'
if (process.platform === 'win32') {

await io.mv(fpmPath, downloadDir + '/' + 'fpm.exe');

} else {

await io.mv(fpmPath, downloadDir + '/' + 'fpm');

}

// Add to path
core.addPath( downloadDir );
console.log(`fpm added to path at ${downloadDir}`);

} catch (error) {

core.setFailed(error.message);

}
};

Expand All @@ -111,7 +111,7 @@ function getFPMFilename(useHaskell,fpmVersion,platform){
}

filename += fpmVersion.replace('v','') + '-';

if (platform === 'linux') {

filename += 'linux-x86_64';
Expand All @@ -137,14 +137,14 @@ function getFPMFilename(useHaskell,fpmVersion,platform){
// Query github API to find the tag for the latest release
//
async function getLatestReleaseVersion(token){

const octokit = github.getOctokit(token);

const {data: releases} = await octokit.repos.listReleases({
owner:'fortran-lang',
repo:'fpm'});

return releases[0].tag_name;
const {data: latest} = await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
owner: 'fortran-lang',
repo: 'fpm'});

return latest.tag_name;

}

Expand Down

0 comments on commit 491d550

Please sign in to comment.