Skip to content

Commit

Permalink
feat: build multiple php versions per shopware version
Browse files Browse the repository at this point in the history
  • Loading branch information
tinect committed Dec 23, 2023
1 parent 203e4c2 commit 592303d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build-docker-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.1', '8.2', '8.3']
flavour: ['alpine', 'bullseye']

steps:
Expand Down Expand Up @@ -124,13 +124,20 @@ jobs:
[ "${shopware_version_tag}" == "" ] && exit 1
tag="${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.flavour }}"
tag="${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.php-version }}-${{ matrix.flavour }}"
if [[ "${{ matrix.flavour }}" == "alpine" ]]; then
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}"
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.php-version }}"
if [[ "${{ matrix.is-main }}" == "true" ]]; then
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}"
fi
elif [[ "${{ matrix.is-main }}" == "true" ]]; then
tag="$tag, ${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}-${{ matrix.flavour }}"
fi
echo "Shopware version ${{ matrix.shopware-version }}"
echo "PHP version ${{ matrix.php-version }}"
echo "Image Tag: ${tag}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion alpine/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-alpine3.16
FROM php:${PHP_VERSION}-cli-alpine3.18

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

Expand Down
68 changes: 38 additions & 30 deletions bin/generate-matrix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const FLAVORS = [
const FLAVOURS = [
"alpine",
"bullseye",
];
Expand All @@ -10,19 +10,16 @@ const FLAVORS = [
*/
const HARDCODED_MATRIX = [
{
"shopware-version": "6.4",
"php-version": "8.1",
"template": "https://github.com/shopware/shopware",
"shopwareVersion": "6.4",
"phpVersions": ["8.1", "8.2"],
},
{
"shopware-version": "6.5.x",
"php-version": "8.1",
"template": "https://github.com/shopware/shopware",
"shopwareVersion": "6.5.x",
"phpVersions": ["8.1", "8.2", "8.3"],
},
{
"shopware-version": "trunk",
"php-version": "8.2",
"template": "https://github.com/shopware/shopware",
"shopwareVersion": "trunk",
"phpVersions": ["8.2", "8.3"],
},
];

Expand Down Expand Up @@ -50,16 +47,32 @@ const parseMinorVersion = (version) => {
}

const getTemplate = (version) => {
const minor = parseMinorVersion(version);
try {
const minor = parseMinorVersion(version);

// For everything below 6.5, we need the shopware/production template.
if (minor <= 4) {
return "https://github.com/shopware/production";
// For everything below 6.5, we need the shopware/production template.
if (minor <= 4) {
return "https://github.com/shopware/production";
}
} catch (e) {
// Ignore
}

return "https://github.com/shopware/shopware";
}

function addMatrixEntries(matrix, shopwareVersion, phpVersion, isMain) {
FLAVOURS.forEach((flavour) => {
matrix.push({
"shopware-version": shopwareVersion,
"php-version": phpVersion,
"flavour": flavour,
"template": getTemplate(shopwareVersion),
"is-main": isMain,
});
});
}

async function main() {
const minPHPVersion = await loadMinPHPVersion();

Expand All @@ -84,22 +97,17 @@ async function main() {

}

let matrix = [];
if (Object.entries(shopwareMinorVersions).length === 0) {
throw new Error("No shopwareMinorVersions entries generated.");
}

for (const [_, line] of Object.entries(shopwareMinorVersions)) {
const minPhpVersions = line.phpVersions.filter((phpVersion) => phpVersion >= minPHPVersion);
let matrix = [];

if (minPhpVersions.length === 0) {
continue;
}
for (const [_, entry] of Object.entries(shopwareMinorVersions)) {
const supportedPhpVersions = entry.phpVersions.filter((phpVersion) => phpVersion >= minPHPVersion);

FLAVORS.forEach((flavor) => {
matrix.push({
"shopware-version": 'v' + line.shopwareVersion,
"php-version": minPhpVersions[0],
"flavour": flavor,
"template": getTemplate(line.shopwareVersion),
});
supportedPhpVersions.forEach((phpVersion, i) => {
addMatrixEntries(matrix, 'v' + entry.shopwareVersion, phpVersion, i === supportedPhpVersions.length - 1);
});
}

Expand All @@ -108,10 +116,10 @@ async function main() {
}

HARDCODED_MATRIX.forEach((entry) => {
FLAVORS.forEach((flavor) => {
entry.flavour = flavor;
const supportedPhpVersions = entry.phpVersions.filter((phpVersion) => phpVersion >= minPHPVersion);

matrix.push(entry);
supportedPhpVersions.forEach((phpVersion, i) => {
addMatrixEntries(matrix, entry.shopwareVersion, phpVersion, i === supportedPhpVersions.length - 1);
});
});

Expand Down

0 comments on commit 592303d

Please sign in to comment.