This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.jsonnet
113 lines (107 loc) · 3.15 KB
/
.drone.jsonnet
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
# defines the target version of Go. Please do not
# update this variable unless it has been previously
# approved on the mailing list.
local golang = "golang:1.11";
# defines a temporary volume so that the Go cache can
# be shared with all pipeine steps.
local volumes = [
{
name: "gopath",
temp: {},
},
];
# defines the default Go cache location as a volume
# that is mounted into pipeline steps.
local mounts = [
{
name: "gopath",
path: "/go",
},
];
# defines a pipeline step that builds and publishes
# a docker image to a docker remote registry.
local docker(name, image, os, arch) = {
name: "publish_" + name,
image: "plugins/docker",
settings: {
repo: "drone/" + if name == "server" then "drone" else name,
auto_tag: true,
auto_tag_suffix: os + "-" + arch,
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
dockerfile: "docker/Dockerfile." + name + "." + os + "." + arch,
},
when: {
event: [ "push", "tag" ],
},
};
# defines a pipeline step that creates and publishes
# a docker manifest to a docker remote registry.
local manifest(name) = {
name: name,
image: "plugins/manifest",
settings: {
auto_tag: true,
ignore_missing: true,
spec: "docker/manifest." + name + ".tmpl",
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
},
when: {
event: [ "push", "tag" ],
},
};
# defines a pipeline that builds, tests and publishes
# docker images for the Drone agent, server and controller.
local pipeline(name, os, arch) = {
kind: "pipeline",
name: name,
volumes: volumes,
platform: {
os: os,
arch: arch,
},
steps: [
{
name: "test",
image: golang,
volumes: mounts,
commands: [ "go test -v ./..." ],
},
{
name: "build",
image: golang,
volumes: mounts,
commands: [
"go build -ldflags \"-extldflags \\\\\"-static\\\\\"\" -o release/"+ os +"/" + arch + "/drone-server github.com/drone/drone/cmd/drone-server",
"CGO_ENABLED=0 go build -o release/"+ os +"/" + arch + "/drone-agent github.com/drone/drone/cmd/drone-agent",
"CGO_ENABLED=0 go build -o release/"+ os +"/" + arch + "/drone-controller github.com/drone/drone/cmd/drone-controller",
],
when: {
event: [ "push", "tag" ],
},
},
docker("agent", "agent", os, arch),
docker("controller", "controller", os, arch),
docker("server", "drone", os, arch),
],
};
[
pipeline("linux-amd64", "linux", "amd64"),
pipeline("linux-arm", "linux", "arm"),
pipeline("linux-arm64", "linux", "arm64"),
{
kind: "pipeline",
name: "manifest",
steps: [
manifest("server"),
manifest("controller"),
manifest("agent"),
],
depends_on: [
"linux-amd64",
"linux-arm",
"linux-arm64",
],
},
]