Skip to content

Commit 7fcd7d0

Browse files
committed
search compiler-specific fpm builds
1 parent 213b4d8 commit 7fcd7d0

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

index.js

+45-22
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,43 @@ async function main(){
4343
const fetchPath = fpmRepo + '/releases/download/' + fpmVersion + '/';
4444
const filename = getFPMFilename(fpmVersion,process.platform);
4545

46-
console.log(`This platform is ${process.platform}`);
47-
console.log(`Fetching fpm from ${fetchPath}${filename}`);
46+
console.log(`This platform is ${process.platform}`);
4847

4948
// Download release
5049
var fpmPath;
5150
try {
52-
53-
fpmPath = await tc.downloadTool(fetchPath+filename);
51+
52+
// Try downloading the file without the compiler suffix
53+
console.log(`Fetching fpm from ${fetchPath}${filename}`);
54+
const filename = getFPMFilename(fpmVersion, process.platform);
55+
fpmPath = await tc.downloadTool(fetchPath + filename);
5456

5557
} catch (error) {
58+
59+
// If download fails, try adding compiler suffixes
60+
const compilers = ['gcc-10', 'gcc-11', 'gcc-12', 'gcc-13', 'gcc-14'];
61+
62+
let success = false;
63+
64+
for (const compiler of compilers) {
65+
66+
// Generate the filename with the compiler suffix
67+
const filenameWithSuffix = getFPMFilename(fpmVersion, process.platform, compilers);
68+
console.log(`Trying to fetch compiler-built fpm: ${filenameWithSuffix}`);
69+
70+
try {
71+
fpmPath = await tc.downloadTool(fetchPath + filenameWithSuffix);
72+
success = true;
73+
break; // If download is successful, break out of the loop
74+
} catch (error) {
75+
console.log(` -> Failed to download ${filenameWithSuffix}`);
76+
}
77+
78+
}
5679

57-
core.setFailed(`Error while trying to fetch fpm - please check that a version exists at the above release url.`);
58-
80+
if (!success) {
81+
core.setFailed(`Error while trying to fetch fpm - please check that a version exists at the above release url.`);
82+
}
5983
}
6084

6185
console.log(fpmPath);
@@ -90,43 +114,42 @@ async function main(){
90114
}
91115
};
92116

93-
94117
// Construct the filename for an fpm release
95118
//
96-
// fpm-<version>-<os>-<arch>[.exe]
119+
// fpm-<version>-<os>-<arch>[-<compiler>][.exe]
97120
//
98121
// <version> is a string of form X.Y.Z corresponding to a release of fpm
99122
// <os> is either 'linux', 'macos', or 'windows'
100123
// <arch> here is always 'x86_64'
124+
// <compiler> is an optional string like '-gcc-12'
101125
//
102-
function getFPMFilename(fpmVersion,platform){
103-
126+
function getFPMFilename(fpmVersion, platform, compiler = '') {
104127
var filename = 'fpm-';
128+
129+
// Remove the leading 'v' if it exists
130+
filename += fpmVersion.replace('v', '') + '-';
105131

106-
filename += fpmVersion.replace('v','') + '-';
107-
132+
// Add the platform and architecture
108133
if (platform === 'linux') {
109-
110134
filename += 'linux-x86_64';
111-
112135
} else if (platform === 'darwin') {
113-
114136
filename += 'macos-x86_64';
115-
116137
} else if (platform === 'win32') {
117-
118-
filename += 'windows-x86_64.exe';
119-
138+
filename += 'windows-x86_64';
120139
} else {
121-
122140
core.setFailed('Unknown platform');
123-
124141
}
125142

126-
return filename;
143+
// If a compiler is provided, append it as a suffix
144+
if (compiler) filename += `-${compiler}`;
145+
146+
// Add the '.exe' suffix for Windows
147+
if (platform === 'win32') filename += '.exe';
127148

149+
return filename;
128150
}
129151

152+
130153
// Query github API to find the tag for the latest release
131154
//
132155
async function getLatestReleaseVersion(token){

0 commit comments

Comments
 (0)