build binaries

This commit is contained in:
Robert Kaussow 2020-09-20 22:52:34 +02:00
parent 7563aa52ed
commit 2fa29cf5d3
Signed by: xoxys
GPG Key ID: 65362AE74AF98B61
2 changed files with 39 additions and 9 deletions

View File

@ -9,6 +9,7 @@ local PipelineTest = {
{
name: 'staticcheck',
image: 'golang:1.14',
pull: 'always',
commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...',
],
@ -22,6 +23,7 @@ local PipelineTest = {
{
name: 'lint',
image: 'golang:1.14',
pull: 'always',
commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...',
],
@ -35,6 +37,7 @@ local PipelineTest = {
{
name: 'vet',
image: 'golang:1.14',
pull: 'always',
commands: [
'go vet ./...',
],
@ -48,6 +51,7 @@ local PipelineTest = {
{
name: 'test',
image: 'golang:1.14',
pull: 'always',
commands: [
'go test -cover ./...',
],
@ -81,10 +85,13 @@ local PipelineBuildBinaries = {
steps: [
{
name: 'build',
image: 'techknowlogick/xgo:latest',
image: 'techknowlogick/xgo:go-1.14.x',
pull: 'always',
commands: [
'[ -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',
],
},
@ -131,6 +138,7 @@ local PipelineBuildContainer(arch='amd64') = {
{
name: 'build',
image: 'golang:1.14',
pull: 'always',
commands: [
'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',
image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: {
dry_run: true,
dockerfile: 'docker/Dockerfile.' + arch,
@ -153,6 +162,7 @@ local PipelineBuildContainer(arch='amd64') = {
{
name: 'publish-dockerhub',
image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: {
auto_tag: true,
auto_tag_suffix: arch,
@ -169,6 +179,7 @@ local PipelineBuildContainer(arch='amd64') = {
{
name: 'publish-quay',
image: 'plugins/docker:18-linux-' + arch,
pull: 'always',
settings: {
auto_tag: true,
auto_tag_suffix: arch,
@ -185,7 +196,7 @@ local PipelineBuildContainer(arch='amd64') = {
},
],
depends_on: [
'build-binaries',
'test',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],

View File

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