Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 36d0132

Browse files
authoredDec 10, 2023
feat: build multiple php versions per shopware version
1 parent b8985b8 commit 36d0132

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed
 

‎.github/workflows/build-docker-images.yaml

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php-version: ['8.1', '8.2']
20+
php-version: ['8.1', '8.2', '8.3']
2121
flavour: ['alpine', 'bullseye']
2222

2323
steps:
@@ -124,13 +124,21 @@ jobs:
124124
125125
[ "${shopware_version_tag}" == "" ] && exit 1
126126
127-
tag="${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.flavour }}"
127+
tag="${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.php-version }}-${{ matrix.flavour }}"
128128
129129
if [[ "${{ matrix.flavour }}" == "alpine" ]]; then
130-
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}"
130+
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.php-version }}"
131+
132+
if [[ "${{ matrix.is-main }}" == "true" ]]; then
133+
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}"
134+
fi
135+
elif [[ "${{ matrix.is-main }}" == "true" ]]; then
136+
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.flavour }}"
137+
fi
131138
fi
132139
133140
echo "Shopware version ${{ matrix.shopware-version }}"
141+
echo "PHP version ${{ matrix.php-version }}"
134142
echo "Image Tag: ${tag}"
135143
136144
echo "tag=${tag}" >> $GITHUB_OUTPUT

‎alpine/Dockerfile.base

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG PHP_VERSION
2-
FROM php:${PHP_VERSION}-cli-alpine3.16
2+
FROM php:${PHP_VERSION}-cli-alpine3.18
33

44
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
55

‎bin/generate-matrix.js

+38-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
const FLAVORS = [
3+
const FLAVOURS = [
44
"alpine",
55
"bullseye",
66
];
@@ -10,19 +10,16 @@ const FLAVORS = [
1010
*/
1111
const 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

5249
const 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+
6376
async 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

Comments
 (0)
Please sign in to comment.