Add a reliable version and integrate libsonnet definition
This commit is contained in:
parent
3516e4fd61
commit
b5e1a12f60
6 changed files with 495 additions and 220 deletions
177
.drone.jsonnet
177
.drone.jsonnet
|
|
@ -1,169 +1,14 @@
|
|||
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" ],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineBuild(os="linux", arch="amd64") = {
|
||||
kind: "pipeline",
|
||||
name: os + "-" + arch,
|
||||
platform: {
|
||||
os: os,
|
||||
arch: arch,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "build-push",
|
||||
image: "golang:1.11",
|
||||
pull: "always",
|
||||
environment: {
|
||||
CGO_ENABLED: "0",
|
||||
GO111MODULE: "on",
|
||||
},
|
||||
commands: [
|
||||
"go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-hugo ./cmd/drone-hugo",
|
||||
],
|
||||
when: {
|
||||
event: [ "push", "pull_request" ],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "build-tag",
|
||||
image: "golang:1.11",
|
||||
pull: "always",
|
||||
environment: {
|
||||
CGO_ENABLED: "0",
|
||||
GO111MODULE: "on",
|
||||
},
|
||||
commands: [
|
||||
"go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-hugo ./cmd/drone-hugo",
|
||||
],
|
||||
when: {
|
||||
event: [ "tag" ],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "executable",
|
||||
image: "golang:1.11",
|
||||
pull: "always",
|
||||
commands: [
|
||||
"./release/" + os + "/" + arch + "/drone-hugo --help",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "dryrun",
|
||||
image: "plugins/docker:" + os + "-" + arch,
|
||||
pull: "always",
|
||||
settings: {
|
||||
dry_run: true,
|
||||
tags: os + "-" + arch,
|
||||
dockerfile: "docker/Dockerfile." + os + "." + arch,
|
||||
repo: "plugins/hugo",
|
||||
username: { "from_secret": "docker_username" },
|
||||
password: { "from_secret": "docker_password" },
|
||||
},
|
||||
when: {
|
||||
event: [ "pull_request" ],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "publish",
|
||||
image: "plugins/docker:" + os + "-" + arch,
|
||||
pull: "always",
|
||||
settings: {
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: os + "-" + arch,
|
||||
dockerfile: "docker/Dockerfile." + os + "." + arch,
|
||||
repo: "plugins/hugo",
|
||||
username: { "from_secret": "docker_username" },
|
||||
password: { "from_secret": "docker_password" },
|
||||
},
|
||||
when: {
|
||||
event: [ "push", "tag" ],
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
"testing",
|
||||
],
|
||||
trigger: {
|
||||
branch: [ "master" ],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineNotifications = {
|
||||
kind: "pipeline",
|
||||
name: "notifications",
|
||||
platform: {
|
||||
os: "linux",
|
||||
arch: "amd64",
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "manifest",
|
||||
image: "plugins/manifest:1",
|
||||
pull: "always",
|
||||
settings: {
|
||||
username: { "from_secret": "docker_username" },
|
||||
password: { "from_secret": "docker_password" },
|
||||
spec: "docker/manifest.tmpl",
|
||||
ignore_missing: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "microbadger",
|
||||
image: "plugins/webhook:1",
|
||||
pull: "always",
|
||||
settings: {
|
||||
url: { "from_secret": "microbadger_url" },
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
"linux-amd64",
|
||||
"linux-arm64",
|
||||
"linux-arm",
|
||||
],
|
||||
trigger: {
|
||||
branch: [ "master" ],
|
||||
event: [ "push", "tag" ],
|
||||
},
|
||||
};
|
||||
local pipeline = import 'pipeline.libsonnet';
|
||||
local name = 'drone-hugo';
|
||||
|
||||
[
|
||||
PipelineTesting,
|
||||
PipelineBuild("linux", "amd64"),
|
||||
PipelineBuild("linux", "arm64"),
|
||||
PipelineBuild("linux", "arm"),
|
||||
PipelineNotifications,
|
||||
pipeline.test('linux', 'amd64'),
|
||||
pipeline.build(name, 'linux', 'amd64'),
|
||||
pipeline.build(name, 'linux', 'arm64'),
|
||||
pipeline.build(name, 'linux', 'arm'),
|
||||
pipeline.notifications(depends_on=[
|
||||
'linux-amd64',
|
||||
'linux-arm64',
|
||||
'linux-arm',
|
||||
]),
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue