Skip to content

Commit 55d533b

Browse files
committed
fix os matrix when running with latest os
1 parent dc6cf30 commit 55d533b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ jobs:
766766
strategy:
767767
fail-fast: false
768768
matrix:
769-
os: []
769+
os: [macos-14]
770770
runs-on: macos-latest
771771
env:
772772
PLATFORM: mac${{ matrix.os == 'macos-14' && '-arm64' || '' }}

extra/github-actions/Main.hx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,25 @@ class Main {
175175
});
176176
script = ~/\s+matrix:\s*os:\s*\[([\w\s,.-]+)\]/g.map(script, function(reg:EReg) {
177177
var matched = reg.matched(0);
178-
var osList = reg.matched(1);
179-
var manifestOs = manifest.os.name + '-' + manifest.os.version;
180-
var newOsList = osList.split(',').map(os -> os.trim()).filter(os -> manifestOs.contains(os)).join(', ');
181-
return matched.replace(osList, newOsList);
178+
var matchedList = reg.matched(1);
179+
var osList = matchedList.split(',').map(os -> os.trim());
180+
osList = if(manifest.os.version == "latest") {
181+
// if there is a matrix we use the more recent of the listed os
182+
function v(os:String):Array<Int> @:nullSafety(Off) return os.substr(os.indexOf('-') + 1).split('.').map(i -> Std.parseInt(i));
183+
function sort(a:Array<Int>, b:Array<Int>):Int {
184+
if(a.length == 0) return 1;
185+
if(b.length == 0) return -1;
186+
@:nullSafety(Off) return if(a[0] < b[0]) 1;
187+
else if(a.shift() > b.shift()) -1;
188+
else sort(a, b);
189+
}
190+
osList.sort((a,b) -> sort(v(a), v(b)));
191+
[osList[0]];
192+
} else {
193+
var manifestOs = manifest.os.name + '-' + manifest.os.version;
194+
osList.filter(os -> manifestOs.contains(os));
195+
}
196+
return matched.replace(matchedList, osList.join(', '));
182197
});
183198

184199
// Fix Ubuntu libraries

0 commit comments

Comments
 (0)