2022-07-07 10:49:16 +00:00
|
|
|
repo = "spritsail/alpine"
|
|
|
|
archs = ["amd64", "arm64"]
|
|
|
|
branches = ["master"]
|
|
|
|
versions = {
|
2024-12-08 00:32:47 +00:00
|
|
|
"3.20": [],
|
|
|
|
"3.21": ["latest"],
|
2022-07-07 10:49:16 +00:00
|
|
|
"edge": [],
|
|
|
|
}
|
|
|
|
|
2020-01-08 19:13:53 +00:00
|
|
|
def main(ctx):
|
2022-07-07 10:49:16 +00:00
|
|
|
builds = []
|
|
|
|
|
|
|
|
for ver, tags in versions.items():
|
|
|
|
depends_on = []
|
|
|
|
for arch in archs:
|
|
|
|
key = "build-%s-%s" % (ver, arch)
|
|
|
|
builds.append(step(ver, arch, key))
|
|
|
|
depends_on.append(key)
|
|
|
|
|
|
|
|
if ctx.build.branch in branches:
|
|
|
|
builds.append(publish(ver, depends_on, tags))
|
2020-01-08 19:13:53 +00:00
|
|
|
|
2022-07-07 10:49:16 +00:00
|
|
|
return builds
|
|
|
|
|
|
|
|
def step(ver, arch, key):
|
|
|
|
vertest = "grep -q '%s' /etc/alpine-release && " % ver if ver != "edge" else ""
|
2020-01-08 19:13:53 +00:00
|
|
|
return {
|
|
|
|
"kind": "pipeline",
|
2022-07-07 10:49:16 +00:00
|
|
|
"name": key,
|
|
|
|
"platform": {
|
|
|
|
"os": "linux",
|
|
|
|
"arch": arch,
|
|
|
|
},
|
|
|
|
"environment": {
|
|
|
|
"DOCKER_IMAGE_TOKEN": ver,
|
|
|
|
},
|
2020-01-08 19:13:53 +00:00
|
|
|
"steps": [
|
|
|
|
{
|
|
|
|
"name": "build",
|
|
|
|
"image": "spritsail/docker-build",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
|
|
|
"build_args": [
|
2022-07-07 10:49:16 +00:00
|
|
|
"ALPINE_TAG=%s" % ver,
|
|
|
|
],
|
|
|
|
},
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "test",
|
|
|
|
"image": "spritsail/docker-test",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
2021-01-20 17:43:59 +00:00
|
|
|
"run": vertest + "su-exec nobody apk --version",
|
2022-07-07 10:49:16 +00:00
|
|
|
"verbose": "true",
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "publish",
|
|
|
|
"image": "spritsail/docker-publish",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
2022-07-07 10:49:16 +00:00
|
|
|
"registry": {"from_secret": "registry_url"},
|
|
|
|
"login": {"from_secret": "registry_login"},
|
|
|
|
},
|
|
|
|
"when": {
|
|
|
|
"branch": branches,
|
2022-08-06 15:31:12 +00:00
|
|
|
"event": ["push", "cron"],
|
2022-07-07 10:49:16 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
def publish(ver, depends, tags=[]):
|
|
|
|
return {
|
|
|
|
"kind": "pipeline",
|
|
|
|
"name": "publish-%s" % ver,
|
|
|
|
"depends_on": depends,
|
|
|
|
"platform": {
|
|
|
|
"os": "linux",
|
|
|
|
},
|
|
|
|
"environment": {
|
|
|
|
"DOCKER_IMAGE_TOKEN": ver,
|
|
|
|
},
|
|
|
|
"steps": [
|
|
|
|
{
|
|
|
|
"name": "publish",
|
|
|
|
"image": "spritsail/docker-multiarch-publish",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
|
|
|
"src_registry": {"from_secret": "registry_url"},
|
|
|
|
"src_login": {"from_secret": "registry_login"},
|
|
|
|
"dest_repo": repo,
|
|
|
|
"dest_login": {"from_secret": "docker_login"},
|
|
|
|
"tags": [ver] + tags,
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
"when": {
|
2022-07-07 10:49:16 +00:00
|
|
|
"branch": branches,
|
2022-08-06 15:31:12 +00:00
|
|
|
"event": ["push", "cron"],
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-07-07 10:49:16 +00:00
|
|
|
# vim: ft=python sw=2
|