11#!/usr/bin/env node
22
3- const FLAVORS = [
3+ const FLAVOURS = [
44 "alpine" ,
55 "bullseye" ,
66] ;
@@ -10,19 +10,16 @@ const FLAVORS = [
1010 */
1111const HARDCODED_MATRIX = [
1212 {
13- "shopware-version" : "6.4" ,
14- "php-version" : "8.1" ,
15- "template" : "https://github.com/shopware/shopware" ,
13+ "shopwareVersion" : "6.4" ,
14+ "phpVersions" : [ "8.1" , "8.2" ] ,
1615 } ,
1716 {
18- "shopware-version" : "6.5.x" ,
19- "php-version" : "8.1" ,
20- "template" : "https://github.com/shopware/shopware" ,
17+ "shopwareVersion" : "6.5.x" ,
18+ "phpVersions" : [ "8.1" , "8.2" , "8.3" ] ,
2119 } ,
2220 {
23- "shopware-version" : "trunk" ,
24- "php-version" : "8.2" ,
25- "template" : "https://github.com/shopware/shopware" ,
21+ "shopwareVersion" : "trunk" ,
22+ "phpVersions" : [ "8.2" , "8.3" ] ,
2623 } ,
2724] ;
2825
@@ -50,16 +47,32 @@ const parseMinorVersion = (version) => {
5047}
5148
5249const getTemplate = ( version ) => {
53- const minor = parseMinorVersion ( version ) ;
50+ try {
51+ const minor = parseMinorVersion ( version ) ;
5452
55- // For everything below 6.5, we need the shopware/production template.
56- if ( minor <= 4 ) {
57- return "https://github.com/shopware/production" ;
53+ // For everything below 6.5, we need the shopware/production template.
54+ if ( minor <= 4 ) {
55+ return "https://github.com/shopware/production" ;
56+ }
57+ } catch ( e ) {
58+ // Ignore
5859 }
5960
6061 return "https://github.com/shopware/shopware" ;
6162}
6263
64+ function addMatrixEntries ( matrix , shopwareVersion , phpVersion , isMain ) {
65+ FLAVOURS . forEach ( ( flavour ) => {
66+ matrix . push ( {
67+ "shopware-version" : shopwareVersion ,
68+ "php-version" : phpVersion ,
69+ "flavour" : flavour ,
70+ "template" : getTemplate ( shopwareVersion ) ,
71+ "is-main" : isMain ,
72+ } ) ;
73+ } ) ;
74+ }
75+
6376async function main ( ) {
6477 const minPHPVersion = await loadMinPHPVersion ( ) ;
6578
@@ -84,22 +97,17 @@ async function main() {
8497
8598 }
8699
87- let matrix = [ ] ;
100+ if ( Object . entries ( shopwareMinorVersions ) . length === 0 ) {
101+ throw new Error ( "No shopwareMinorVersions entries generated." ) ;
102+ }
88103
89- for ( const [ _ , line ] of Object . entries ( shopwareMinorVersions ) ) {
90- const minPhpVersions = line . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
104+ let matrix = [ ] ;
91105
92- if ( minPhpVersions . length === 0 ) {
93- continue ;
94- }
106+ for ( const [ _ , entry ] of Object . entries ( shopwareMinorVersions ) ) {
107+ const supportedPhpVersions = entry . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
95108
96- FLAVORS . forEach ( ( flavor ) => {
97- matrix . push ( {
98- "shopware-version" : 'v' + line . shopwareVersion ,
99- "php-version" : minPhpVersions [ 0 ] ,
100- "flavour" : flavor ,
101- "template" : getTemplate ( line . shopwareVersion ) ,
102- } ) ;
109+ supportedPhpVersions . forEach ( ( phpVersion , i ) => {
110+ addMatrixEntries ( matrix , 'v' + entry . shopwareVersion , phpVersion , i === supportedPhpVersions . length - 1 ) ;
103111 } ) ;
104112 }
105113
@@ -108,10 +116,10 @@ async function main() {
108116 }
109117
110118 HARDCODED_MATRIX . forEach ( ( entry ) => {
111- FLAVORS . forEach ( ( flavor ) => {
112- entry . flavour = flavor ;
119+ const supportedPhpVersions = entry . phpVersions . filter ( ( phpVersion ) => phpVersion >= minPHPVersion ) ;
113120
114- matrix . push ( entry ) ;
121+ supportedPhpVersions . forEach ( ( phpVersion , i ) => {
122+ addMatrixEntries ( matrix , entry . shopwareVersion , phpVersion , i === supportedPhpVersions . length - 1 ) ;
115123 } ) ;
116124 } ) ;
117125
0 commit comments