2022-06-17 12:29:39 +00:00
|
|
|
repo = "spritsail/alpine"
|
|
|
|
archs = ["amd64", "arm64"]
|
|
|
|
versions = ["edge", "3.14", "3.15", "3.16"]
|
|
|
|
branches = ["master"]
|
|
|
|
|
2020-01-08 19:13:53 +00:00
|
|
|
def main(ctx):
|
2022-06-17 12:29:39 +00:00
|
|
|
builds = []
|
|
|
|
|
|
|
|
for ver in versions:
|
|
|
|
depends_on = []
|
|
|
|
srctpl = "drone/%s/${DRONE_BUILD_NUMBER}:%s-ARCH" % (ctx.repo.slug, ver)
|
|
|
|
for arch in archs:
|
|
|
|
key = "build-%s-%s" % (ver, arch)
|
|
|
|
tmprepo = "drone/%s/${DRONE_BUILD_NUMBER}:%s-%s" % (ctx.repo.slug, ver, arch)
|
|
|
|
builds.append(step(ver, arch, key, tmprepo))
|
|
|
|
depends_on.append(key)
|
|
|
|
|
|
|
|
if ctx.build.branch in branches:
|
|
|
|
tags = []
|
|
|
|
if ver == versions[-1]:
|
|
|
|
tags.append("latest")
|
|
|
|
builds.append(publish(ver, srctpl, depends_on, tags))
|
2020-01-08 19:13:53 +00:00
|
|
|
|
2022-06-17 12:29:39 +00:00
|
|
|
return builds
|
|
|
|
|
|
|
|
def step(ver, arch, key, tmprepo):
|
|
|
|
vertest = "grep -q '%s' /etc/alpine-release && " % ver if ver != "edge" else ""
|
2020-01-08 19:13:53 +00:00
|
|
|
return {
|
|
|
|
"kind": "pipeline",
|
2022-06-17 12:29:39 +00:00
|
|
|
"name": key,
|
|
|
|
"platform": {
|
|
|
|
"os": "linux",
|
|
|
|
"arch": arch,
|
|
|
|
},
|
2020-01-08 19:13:53 +00:00
|
|
|
"steps": [
|
|
|
|
{
|
|
|
|
"name": "build",
|
|
|
|
"image": "spritsail/docker-build",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
|
|
|
"build_args": [
|
2022-06-17 12:29:39 +00:00
|
|
|
"ALPINE_TAG=%s" % ver,
|
2020-01-08 19:13:53 +00:00
|
|
|
],
|
2022-06-17 12:29:39 +00:00
|
|
|
"repo": tmprepo,
|
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-06-17 12:29:39 +00:00
|
|
|
"repo": tmprepo,
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "publish",
|
|
|
|
"image": "spritsail/docker-publish",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
2022-06-17 12:29:39 +00:00
|
|
|
"from": tmprepo,
|
|
|
|
"repo": tmprepo,
|
|
|
|
"registry": {"from_secret": "registry_url"},
|
|
|
|
"username": {"from_secret": "registry_username"},
|
|
|
|
"password": {"from_secret": "registry_password"},
|
|
|
|
},
|
|
|
|
"when": {
|
|
|
|
"branch": branches,
|
|
|
|
"event": ["push"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
def publish(ver, srctpl, depends, tags=[]):
|
|
|
|
return {
|
|
|
|
"kind": "pipeline",
|
|
|
|
"name": "publish-%s" % ver,
|
|
|
|
"depends_on": depends,
|
|
|
|
"platform": {
|
|
|
|
"os": "linux",
|
|
|
|
},
|
|
|
|
"steps": [
|
|
|
|
{
|
|
|
|
"name": "publish",
|
|
|
|
"image": "spritsail/docker-multiarch-publish",
|
|
|
|
"pull": "always",
|
|
|
|
"settings": {
|
|
|
|
"src_template": srctpl,
|
|
|
|
"src_registry": {"from_secret": "registry_url"},
|
|
|
|
"src_username": {"from_secret": "registry_username"},
|
|
|
|
"src_password": {"from_secret": "registry_password"},
|
|
|
|
"dest_repo": repo,
|
|
|
|
"dest_username": {"from_secret": "docker_username"},
|
|
|
|
"dest_password": {"from_secret": "docker_password"},
|
|
|
|
"tags": [ver] + tags,
|
2020-01-08 19:13:53 +00:00
|
|
|
},
|
|
|
|
"when": {
|
2022-06-17 12:29:39 +00:00
|
|
|
"branch": branches,
|
2020-01-08 19:13:53 +00:00
|
|
|
"event": ["push"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-06-17 12:29:39 +00:00
|
|
|
# vim: ft=python sw=2
|