Skip to content

Commit 2f70c05

Browse files
Merge pull request #7 from everythingfunctional/fix-latest
Fix Latest Option
2 parents 7235df1 + a4d26b1 commit 2f70c05

File tree

4 files changed

+23
-38
lines changed

4 files changed

+23
-38
lines changed

.github/workflows/test-workflow.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ jobs:
77
fail-fast: false
88
matrix:
99
os: [ubuntu-latest, macos-latest, windows-latest]
10-
use-bootstrap: [false, true]
1110
fpm-version: ['v0.1.0','v0.1.1','latest']
1211

1312
steps:
@@ -19,7 +18,6 @@ jobs:
1918
with:
2019
github-token: ${{ secrets.GITHUB_TOKEN }}
2120
fpm-version: ${{ matrix.fpm-version }}
22-
use-haskell: ${{ matrix.use-bootstrap }}
2321

2422
- name: test fpm
2523
run: fpm --help

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ __`github-token`__ (*only needed if `fpm-version` is `'latest'` or not specified
3030
__`fpm-version`__ (*optional,default:*`'latest'`) the tag corresponding a Github release from which to fetch the `fpm` binary.
3131
- If set to `'latest'` (_default_) then the latest `fpm` release at [fortran-lang/fpm](https://github.com/fortran-lang/fpm/releases/latest) will be substituted. `github-token` must be provided if `fpm-version` is `'latest'`.
3232

33-
__`use-haskell`__ (*optional,default:*`false`) whether to fetch and use the legacy Haskell implementation
34-
3533
__`fpm-repository`__ (*optional, default:* `https://github.com/fortran-lang/fpm`) which Github fork to fetch release binaries from.

action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ inputs:
88
description: 'API token needed to fetch latest fpm version'
99
required: false
1010
default: 'none'
11-
use-haskell:
12-
description: 'Whether to use the legacy Haskell implementation of fpm'
13-
required: false
14-
default: false
1511
fpm-version:
1612
description: 'The tag of an fpm release'
1713
required: false

index.js

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ async function main(){
1414
// Get inputs
1515
const token = core.getInput('github-token');
1616

17-
const useHaskell = core.getInput('use-haskell').toLowerCase() === 'true';
18-
console.log(`use-haskell: ${useHaskell}`);
19-
2017
var fpmVersion = core.getInput('fpm-version');
2118
console.log(`fpm-version: ${fpmVersion}`);
2219

@@ -25,7 +22,7 @@ async function main(){
2522

2623
// Get latest version if requested
2724
if (fpmVersion === 'latest'){
28-
25+
2926
if (token === 'none') {
3027
core.setFailed('To fetch the latest fpm version, please supply a github token. Alternatively you can specify the fpm release version manually.');
3128
}
@@ -44,74 +41,70 @@ async function main(){
4441

4542
// Build download path
4643
const fetchPath = fpmRepo + '/releases/download/' + fpmVersion + '/';
47-
const filename = getFPMFilename(useHaskell,fpmVersion,process.platform);
44+
const filename = getFPMFilename(fpmVersion,process.platform);
4845

4946
console.log(`This platform is ${process.platform}`);
5047
console.log(`Fetching fpm from ${fetchPath}${filename}`);
51-
48+
5249
// Download release
5350
var fpmPath;
5451
try {
55-
52+
5653
fpmPath = await tc.downloadTool(fetchPath+filename);
57-
54+
5855
} catch (error) {
59-
56+
6057
core.setFailed(`Error while trying to fetch fpm - please check that a version exists at the above release url.`);
61-
58+
6259
}
6360

6461
console.log(fpmPath);
6562
const downloadDir = path.dirname(fpmPath);
66-
63+
6764
// Add executable flag on unix
6865
if (process.platform === 'linux' || process.platform === 'darwin'){
69-
66+
7067
await exec.exec('chmod u+x '+fpmPath);
7168

7269
}
7370

7471
// Rename to 'fpm'
7572
if (process.platform === 'win32') {
76-
73+
7774
await io.mv(fpmPath, downloadDir + '/' + 'fpm.exe');
7875

7976
} else {
80-
77+
8178
await io.mv(fpmPath, downloadDir + '/' + 'fpm');
8279

8380
}
84-
81+
8582
// Add to path
8683
core.addPath( downloadDir );
8784
console.log(`fpm added to path at ${downloadDir}`);
88-
85+
8986
} catch (error) {
9087

9188
core.setFailed(error.message);
92-
89+
9390
}
9491
};
9592

9693

9794
// Construct the filename for an fpm release
9895
//
99-
// fpm-[haskell-]<version>-<os>-<arch>[.exe]
96+
// fpm-<version>-<os>-<arch>[.exe]
10097
//
10198
// <version> is a string of form X.Y.Z corresponding to a release of fpm
10299
// <os> is either 'linux', 'macos', or 'windows'
103100
// <arch> here is always 'x86_64'
104101
//
105-
function getFPMFilename(useHaskell,fpmVersion,platform){
102+
function getFPMFilename(fpmVersion,platform){
106103

107104
var filename = 'fpm-';
108105

109-
if (useHaskell) {
110-
filename += 'haskell-';
111-
}
112-
113106
filename += fpmVersion.replace('v','') + '-';
114-
107+
115108
if (platform === 'linux') {
116109

117110
filename += 'linux-x86_64';
@@ -137,14 +130,14 @@ function getFPMFilename(useHaskell,fpmVersion,platform){
137130
// Query github API to find the tag for the latest release
138131
//
139132
async function getLatestReleaseVersion(token){
140-
133+
141134
const octokit = github.getOctokit(token);
142-
143-
const {data: releases} = await octokit.repos.listReleases({
144-
owner:'fortran-lang',
145-
repo:'fpm'});
146135

147-
return releases[0].tag_name;
136+
const {data: latest} = await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
137+
owner: 'fortran-lang',
138+
repo: 'fpm'});
139+
140+
return latest.tag_name;
148141

149142
}
150143

0 commit comments

Comments
 (0)