-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.star
119 lines (112 loc) · 2.83 KB
/
.drone.star
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
repo = "spritsail/mono"
architectures = ["amd64", "arm64"]
publish_branches = ["master"]
matrix = [
{
"desc": "Mono runtime without any reference assemblies",
"tags": ["runtime"],
},
{
"desc": "Mono runtime, including the 2.0 and 3.5 reference assemblies",
"pkgs": "mono-reference-assemblies-3.5",
"tags": ["3.5"],
},
{
"desc": "Mono runtime, including the default 4.5 reference assemblies",
"pkgs": "mono-reference-assemblies",
"tags": ["4.5", "latest"],
},
{
"desc": "Mono runtime, including the 4.5 and 4.x reference assemblies",
"pkgs": "mono-reference-assemblies-4.x",
"tags": ["4.x"],
},
]
def main(ctx):
builds = []
for bld in matrix:
tag = bld["tags"][0]
depends_on = []
for arch in architectures:
key = "build-%s-%s" % (tag, arch)
builds.append(step(arch, key, **bld))
depends_on.append(key)
if ctx.build.branch in publish_branches:
key = "publish-manifest-%s" % tag
builds.append(publish(key, bld["tags"], depends_on))
return builds
def step(arch, key, desc, tags, pkgs=""):
return {
"kind": "pipeline",
"name": key,
"platform": {
"os": "linux",
"arch": arch,
},
"environment": {
"DOCKER_IMAGE_TOKEN": tags[0],
},
"steps": [
{
"name": "build",
"image": "spritsail/docker-build",
"pull": "always",
"settings": {
"build_args": [
"MONO_PACKAGE=%s" % pkgs,
"MONO_DESC=%s" % desc,
],
},
},
{
"name": "test",
"image":"drone/${DRONE_REPO}/${DRONE_BUILD_NUMBER}/%s:${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}" % tags[0],
"pull": "never",
"commands": [
"mono --version",
"apk add ca-certificates-mono",
"update-ca-certificates",
],
},
{
"name": "publish",
"image": "spritsail/docker-publish",
"pull": "always",
"settings": {
"registry": {"from_secret": "registry_url"},
"login": {"from_secret": "registry_login"},
},
},
],
}
def publish(key, tags, depends_on):
return {
"kind": "pipeline",
"name": key,
"depends_on": depends_on,
"platform": {
"os": "linux",
},
"environment": {
"DOCKER_IMAGE_TOKEN": tags[0],
},
"steps": [
{
"name": "publish",
"image": "spritsail/docker-multiarch-publish",
"pull": "always",
"settings": {
"tags": tags,
"src_registry": {"from_secret": "registry_url"},
"src_login": {"from_secret": "registry_login"},
"dest_repo": repo,
"dest_login": {"from_secret": "docker_login"},
},
"when": {
"branch": publish_branches,
"event": ["push"],
},
},
],
}
# vim: ft=python sw=2