build binaries

This commit is contained in:
Robert Kaussow 2020-09-20 22:52:34 +02:00
parent 7563aa52ed
commit 2fa29cf5d3
No known key found for this signature in database
GPG Key ID: 65362AE74AF98B61
2 changed files with 39 additions and 9 deletions

View File

@ -9,6 +9,7 @@ local PipelineTest = {
{ {
name: 'staticcheck', name: 'staticcheck',
image: 'golang:1.14', image: 'golang:1.14',
pull: 'always',
commands: [ commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...', 'go run honnef.co/go/tools/cmd/staticcheck ./...',
], ],
@ -22,6 +23,7 @@ local PipelineTest = {
{ {
name: 'lint', name: 'lint',
image: 'golang:1.14', image: 'golang:1.14',
pull: 'always',
commands: [ commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...', 'go run golang.org/x/lint/golint -set_exit_status ./...',
], ],
@ -35,6 +37,7 @@ local PipelineTest = {
{ {
name: 'vet', name: 'vet',
image: 'golang:1.14', image: 'golang:1.14',
pull: 'always',
commands: [ commands: [
'go vet ./...', 'go vet ./...',
], ],
@ -48,6 +51,7 @@ local PipelineTest = {
{ {
name: 'test', name: 'test',
image: 'golang:1.14', image: 'golang:1.14',
pull: 'always',
commands: [ commands: [
'go test -cover ./...', 'go test -cover ./...',
], ],
@ -81,10 +85,13 @@ local PipelineBuildBinaries = {
steps: [ steps: [
{ {
name: 'build', name: 'build',
image: 'techknowlogick/xgo:latest', image: 'techknowlogick/xgo:go-1.14.x',
pull: 'always',
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
"xgo -ldflags \"-s -w -X main.Version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out /drone/src/release/drone-github-comment ./cmd/drone-github-comment", 'mkdir -p release/',
"xgo -ldflags \"-s -w -X main.Version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' ./cmd/drone-github-comment",
'mv /build/* /drone/src/release/',
'tree', 'tree',
], ],
}, },
@ -131,6 +138,7 @@ local PipelineBuildContainer(arch='amd64') = {
{ {
name: 'build', name: 'build',
image: 'golang:1.14', image: 'golang:1.14',
pull: 'always',
commands: [ commands: [
'go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/' + arch + 'drone-github-comment ./cmd/drone-github-comment', 'go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/' + arch + 'drone-github-comment ./cmd/drone-github-comment',
], ],
@ -138,6 +146,7 @@ local PipelineBuildContainer(arch='amd64') = {
{ {
name: 'dryrun', name: 'dryrun',
image: 'plugins/docker:18-linux-' + arch, image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: { settings: {
dry_run: true, dry_run: true,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
@ -153,6 +162,7 @@ local PipelineBuildContainer(arch='amd64') = {
{ {
name: 'publish-dockerhub', name: 'publish-dockerhub',
image: 'plugins/docker:18-linux-' + arch, image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
@ -169,6 +179,7 @@ local PipelineBuildContainer(arch='amd64') = {
{ {
name: 'publish-quay', name: 'publish-quay',
image: 'plugins/docker:18-linux-' + arch, image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
@ -185,7 +196,7 @@ local PipelineBuildContainer(arch='amd64') = {
}, },
], ],
depends_on: [ depends_on: [
'build-binaries', 'test',
], ],
trigger: { trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],

View File

@ -8,6 +8,7 @@ platform:
steps: steps:
- name: staticcheck - name: staticcheck
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go run honnef.co/go/tools/cmd/staticcheck ./... - go run honnef.co/go/tools/cmd/staticcheck ./...
@ -16,6 +17,7 @@ steps:
path: /go path: /go
- name: lint - name: lint
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go run golang.org/x/lint/golint -set_exit_status ./... - go run golang.org/x/lint/golint -set_exit_status ./...
@ -24,6 +26,7 @@ steps:
path: /go path: /go
- name: vet - name: vet
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go vet ./... - go vet ./...
@ -32,6 +35,7 @@ steps:
path: /go path: /go
- name: test - name: test
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go test -cover ./... - go test -cover ./...
@ -59,10 +63,13 @@ platform:
steps: steps:
- name: build - name: build
image: techknowlogick/xgo:latest pull: always
image: techknowlogick/xgo:go-1.14.x
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- xgo -ldflags "-s -w -X main.Version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out /drone/src/release/drone-github-comment ./cmd/drone-github-comment - mkdir -p release/
- xgo -ldflags "-s -w -X main.Version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' ./cmd/drone-github-comment
- mv /build/* /drone/src/release/
- tree - tree
- name: executable - name: executable
@ -101,11 +108,13 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/amd64drone-github-comment ./cmd/drone-github-comment - go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/amd64drone-github-comment ./cmd/drone-github-comment
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
@ -122,6 +131,7 @@ steps:
- build - build
- name: publish-dockerhub - name: publish-dockerhub
pull: always
image: plugins/docker:18-linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
auto_tag: true auto_tag: true
@ -140,6 +150,7 @@ steps:
- dryrun - dryrun
- name: publish-quay - name: publish-quay
pull: always
image: plugins/docker:18-linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
auto_tag: true auto_tag: true
@ -165,7 +176,7 @@ trigger:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- build-binaries - test
--- ---
kind: pipeline kind: pipeline
@ -177,11 +188,13 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/arm64drone-github-comment ./cmd/drone-github-comment - go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/arm64drone-github-comment ./cmd/drone-github-comment
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-arm64 image: plugins/docker:18-linux-arm64
settings: settings:
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
@ -198,6 +211,7 @@ steps:
- build - build
- name: publish-dockerhub - name: publish-dockerhub
pull: always
image: plugins/docker:18-linux-arm64 image: plugins/docker:18-linux-arm64
settings: settings:
auto_tag: true auto_tag: true
@ -216,6 +230,7 @@ steps:
- dryrun - dryrun
- name: publish-quay - name: publish-quay
pull: always
image: plugins/docker:18-linux-arm64 image: plugins/docker:18-linux-arm64
settings: settings:
auto_tag: true auto_tag: true
@ -241,7 +256,7 @@ trigger:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- build-binaries - test
--- ---
kind: pipeline kind: pipeline
@ -253,11 +268,13 @@ platform:
steps: steps:
- name: build - name: build
pull: always
image: golang:1.14 image: golang:1.14
commands: commands:
- go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/armdrone-github-comment ./cmd/drone-github-comment - go build -v -ldflags "-X main.version=${DRONE_TAG:-latest}" -a -tags netgo -o release/armdrone-github-comment ./cmd/drone-github-comment
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:18-linux-arm image: plugins/docker:18-linux-arm
settings: settings:
dockerfile: docker/Dockerfile.arm dockerfile: docker/Dockerfile.arm
@ -274,6 +291,7 @@ steps:
- build - build
- name: publish-dockerhub - name: publish-dockerhub
pull: always
image: plugins/docker:18-linux-arm image: plugins/docker:18-linux-arm
settings: settings:
auto_tag: true auto_tag: true
@ -292,6 +310,7 @@ steps:
- dryrun - dryrun
- name: publish-quay - name: publish-quay
pull: always
image: plugins/docker:18-linux-arm image: plugins/docker:18-linux-arm
settings: settings:
auto_tag: true auto_tag: true
@ -317,7 +336,7 @@ trigger:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- build-binaries - test
--- ---
kind: pipeline kind: pipeline
@ -415,6 +434,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 359b44f4a22939e189ecd48556204f22a49fd1983d14bde32a942e5f123195db hmac: a350a628573852e696deeb7ac9b68f4e4dd913c8276e4a50dd66ccfdd1c87531
... ...