forked from shyim/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
76 lines (59 loc) · 1.9 KB
/
build.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import * as semver from "https://deno.land/x/semver/mod.ts";
async function main() {
let releases = await getReleases();
const ghConfig = {
'fail-fast': false,
matrix: {
include: [] as any
}
};
// Build
for (let release of releases) {
for (let tag of release.tags) {
ghConfig.matrix.include.push({
name: `Shopware ${tag}`,
runs: {
build: `docker buildx build --platform linux/amd64,linux/arm64 --build-arg SHOPWARE_DL=${release.download} --build-arg SHOPWARE_VERSION=${release.version} --tag ghcr.io/shyim/shopware:${tag} --tag shyim/shopware:${tag} --push .`
}
});
}
}
await Deno.stdout.write(new TextEncoder().encode(JSON.stringify(ghConfig)));
}
function getMajorVersion(version: string) {
let majorVersion = /\d+\.\d+/gm.exec(version);
if (majorVersion && majorVersion[0]) {
return majorVersion[0];
}
return '';
}
main();
async function getReleases() {
let json = await (await fetch('https://update-api.shopware.com/v1/releases/install?major=6')).json();
let releases = [];
let givenTags: string[] = [];
for (let release of json) {
try {
if (semver.lt(release.version, '6.2.0')) {
continue;
}
} catch (e) {
}
const majorVersion = getMajorVersion(release.version);
let image = {
version: release.version,
download: release.uri,
tags: [release.version]
}
if (!givenTags.includes(majorVersion)) {
image.tags.push(majorVersion);
givenTags.push(majorVersion);
}
if (!givenTags.includes('latest')) {
image.tags.push('latest');
givenTags.push('latest');
}
releases.push(image);
}
return releases;
}