From 2fa29cf5d33b7929335c9aaae1ee26f4157992ac Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 20 Sep 2020 22:52:34 +0200 Subject: [PATCH] build binaries --- .drone.jsonnet | 17 ++++++++++++++--- .drone.yml | 31 +++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 3e8b261..a4a683a 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -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/**'], diff --git a/.drone.yml b/.drone.yml index ae4e59a..8865642 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 ...