@@ -43,19 +43,43 @@ async function main(){
43
43
const fetchPath = fpmRepo + '/releases/download/' + fpmVersion + '/' ;
44
44
const filename = getFPMFilename ( fpmVersion , process . platform ) ;
45
45
46
- console . log ( `This platform is ${ process . platform } ` ) ;
47
- console . log ( `Fetching fpm from ${ fetchPath } ${ filename } ` ) ;
46
+ console . log ( `This platform is ${ process . platform } ` ) ;
48
47
49
48
// Download release
50
49
var fpmPath ;
51
50
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 ) ;
54
56
55
57
} 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
+ }
56
79
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
+ }
59
83
}
60
84
61
85
console . log ( fpmPath ) ;
@@ -90,43 +114,42 @@ async function main(){
90
114
}
91
115
} ;
92
116
93
-
94
117
// Construct the filename for an fpm release
95
118
//
96
- // fpm-<version>-<os>-<arch>[.exe]
119
+ // fpm-<version>-<os>-<arch>[-<compiler>][ .exe]
97
120
//
98
121
// <version> is a string of form X.Y.Z corresponding to a release of fpm
99
122
// <os> is either 'linux', 'macos', or 'windows'
100
123
// <arch> here is always 'x86_64'
124
+ // <compiler> is an optional string like '-gcc-12'
101
125
//
102
- function getFPMFilename ( fpmVersion , platform ) {
103
-
126
+ function getFPMFilename ( fpmVersion , platform , compiler = '' ) {
104
127
var filename = 'fpm-' ;
128
+
129
+ // Remove the leading 'v' if it exists
130
+ filename += fpmVersion . replace ( 'v' , '' ) + '-' ;
105
131
106
- filename += fpmVersion . replace ( 'v' , '' ) + '-' ;
107
-
132
+ // Add the platform and architecture
108
133
if ( platform === 'linux' ) {
109
-
110
134
filename += 'linux-x86_64' ;
111
-
112
135
} else if ( platform === 'darwin' ) {
113
-
114
136
filename += 'macos-x86_64' ;
115
-
116
137
} else if ( platform === 'win32' ) {
117
-
118
- filename += 'windows-x86_64.exe' ;
119
-
138
+ filename += 'windows-x86_64' ;
120
139
} else {
121
-
122
140
core . setFailed ( 'Unknown platform' ) ;
123
-
124
141
}
125
142
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' ;
127
148
149
+ return filename ;
128
150
}
129
151
152
+
130
153
// Query github API to find the tag for the latest release
131
154
//
132
155
async function getLatestReleaseVersion ( token ) {
0 commit comments