2019-01-20 22:51:59 +00:00
|
|
|
local PipelineTesting = {
|
|
|
|
kind: "pipeline",
|
|
|
|
name: "testing",
|
|
|
|
platform: {
|
|
|
|
os: "linux",
|
|
|
|
arch: "amd64",
|
|
|
|
},
|
|
|
|
steps: [
|
|
|
|
{
|
|
|
|
name: "vet",
|
|
|
|
image: "golang:1.11",
|
|
|
|
pull: "always",
|
|
|
|
environment: {
|
|
|
|
GO111MODULE: "on",
|
|
|
|
},
|
|
|
|
commands: [
|
|
|
|
"go vet ./...",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "test",
|
|
|
|
image: "golang:1.11",
|
|
|
|
pull: "always",
|
|
|
|
environment: {
|
|
|
|
GO111MODULE: "on",
|
|
|
|
},
|
|
|
|
commands: [
|
|
|
|
"go test -cover ./...",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
trigger: {
|
|
|
|
branch: [ "master" ],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-01-21 00:05:01 +00:00
|
|
|
local PipelineBuild(binary="docker", os="linux", arch="amd64") = {
|
2019-01-20 22:51:59 +00:00
|
|
|
kind: "pipeline",
|
2019-01-21 00:05:01 +00:00
|
|
|
name: os + "-" + arch + "-" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
platform: {
|
|
|
|
os: os,
|
|
|
|
arch: arch,
|
|
|
|
},
|
|
|
|
steps: [
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "build-push",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "golang:1.11",
|
|
|
|
pull: "always",
|
|
|
|
environment: {
|
|
|
|
CGO_ENABLED: "0",
|
|
|
|
GO111MODULE: "on",
|
|
|
|
},
|
|
|
|
commands: [
|
2019-01-21 00:05:01 +00:00
|
|
|
"go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/" + os + "/" + arch + "/drone-" + binary + " ./cmd/drone-" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
],
|
|
|
|
when: {
|
|
|
|
event: [ "push", "pull_request" ],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "build-tag",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "golang:1.11",
|
|
|
|
pull: "always",
|
|
|
|
environment: {
|
|
|
|
CGO_ENABLED: "0",
|
|
|
|
GO111MODULE: "on",
|
|
|
|
},
|
|
|
|
commands: [
|
2019-01-21 00:05:01 +00:00
|
|
|
"go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/" + os + "/" + arch + "/drone-" + binary + " ./cmd/drone-" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
],
|
|
|
|
when: {
|
|
|
|
event: [ "tag" ],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "dryrun",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "plugins/docker:" + os + "-" + arch,
|
|
|
|
pull: "always",
|
|
|
|
settings: {
|
|
|
|
dry_run: true,
|
|
|
|
tags: os + "-" + arch,
|
2019-01-21 00:05:01 +00:00
|
|
|
dockerfile: "docker/" + binary + "/Dockerfile." + os + "." + arch,
|
|
|
|
repo: "plugins/" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
username: { "from_secret": "docker_username" },
|
|
|
|
password: { "from_secret": "docker_password" },
|
|
|
|
},
|
|
|
|
when: {
|
|
|
|
event: [ "pull_request" ],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "publish",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "plugins/docker:" + os + "-" + arch,
|
|
|
|
pull: "always",
|
|
|
|
settings: {
|
|
|
|
auto_tag: true,
|
|
|
|
auto_tag_suffix: os + "-" + arch,
|
2019-01-21 00:05:01 +00:00
|
|
|
dockerfile: "docker/" + binary + "/Dockerfile." + os + "." + arch,
|
|
|
|
repo: "plugins/" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
username: { "from_secret": "docker_username" },
|
|
|
|
password: { "from_secret": "docker_password" },
|
|
|
|
},
|
|
|
|
when: {
|
|
|
|
event: [ "push", "tag" ],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
depends_on: [
|
|
|
|
"testing",
|
|
|
|
],
|
|
|
|
trigger: {
|
|
|
|
branch: [ "master" ],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-01-21 00:05:01 +00:00
|
|
|
local PipelineNotifications(binary="docker") = {
|
2019-01-20 22:51:59 +00:00
|
|
|
kind: "pipeline",
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "notifications-" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
platform: {
|
|
|
|
os: "linux",
|
|
|
|
arch: "amd64",
|
|
|
|
},
|
|
|
|
steps: [
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "manifest",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "plugins/manifest:1",
|
|
|
|
pull: "always",
|
|
|
|
settings: {
|
|
|
|
username: { "from_secret": "docker_username" },
|
|
|
|
password: { "from_secret": "docker_password" },
|
2019-01-21 00:05:01 +00:00
|
|
|
spec: "docker/" + binary + "/manifest.tmpl",
|
2019-01-20 22:51:59 +00:00
|
|
|
ignore_missing: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-01-21 00:05:01 +00:00
|
|
|
name: "microbadger",
|
2019-01-20 22:51:59 +00:00
|
|
|
image: "plugins/webhook:1",
|
|
|
|
pull: "always",
|
|
|
|
settings: {
|
|
|
|
url: { "from_secret": "microbadger_docker" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
depends_on: [
|
2019-01-21 00:05:01 +00:00
|
|
|
"linux-amd64-" + binary,
|
|
|
|
"linux-arm64-" + binary,
|
|
|
|
"linux-arm-" + binary,
|
2019-01-20 22:51:59 +00:00
|
|
|
],
|
|
|
|
trigger: {
|
|
|
|
branch: [ "master" ],
|
|
|
|
event: [ "push", "tag" ],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
[
|
|
|
|
PipelineTesting,
|
2019-01-21 00:05:01 +00:00
|
|
|
PipelineBuild("docker", "linux", "amd64"),
|
|
|
|
PipelineBuild("docker", "linux", "arm64"),
|
|
|
|
PipelineBuild("docker", "linux", "arm"),
|
|
|
|
PipelineBuild("gcr", "linux", "amd64"),
|
|
|
|
PipelineBuild("gcr", "linux", "arm64"),
|
|
|
|
PipelineBuild("gcr", "linux", "arm"),
|
|
|
|
PipelineBuild("ecr", "linux", "amd64"),
|
|
|
|
PipelineBuild("ecr", "linux", "arm64"),
|
|
|
|
PipelineBuild("ecr", "linux", "arm"),
|
|
|
|
PipelineBuild("heroku", "linux", "amd64"),
|
|
|
|
PipelineBuild("heroku", "linux", "arm64"),
|
|
|
|
PipelineBuild("heroku", "linux", "arm"),
|
|
|
|
PipelineNotifications("docker"),
|
|
|
|
PipelineNotifications("gcr"),
|
|
|
|
PipelineNotifications("ecr"),
|
|
|
|
PipelineNotifications("heroku"),
|
2019-01-20 22:51:59 +00:00
|
|
|
]
|