Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit fef64f2

Browse files
authored
ci: refactor build tools and ci setup (#90)
1 parent 770a1cd commit fef64f2

File tree

19 files changed

+198
-196
lines changed

19 files changed

+198
-196
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!dist/

.drone.jsonnet

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
local PipelineTest = {
22
kind: 'pipeline',
3-
image_pull_secrets: ['docker_config'],
43
name: 'test',
54
platform: {
65
os: 'linux',
76
arch: 'amd64',
87
},
98
steps: [
109
{
11-
name: 'staticcheck',
10+
name: 'deps',
1211
image: 'golang:1.18',
1312
commands: [
14-
'go run honnef.co/go/tools/cmd/staticcheck ./...',
13+
'make deps',
1514
],
1615
volumes: [
1716
{
18-
name: 'gopath',
17+
name: 'godeps',
1918
path: '/go',
2019
},
2120
],
@@ -24,24 +23,11 @@ local PipelineTest = {
2423
name: 'lint',
2524
image: 'golang:1.18',
2625
commands: [
27-
'go run golang.org/x/lint/golint -set_exit_status ./...',
26+
'make lint',
2827
],
2928
volumes: [
3029
{
31-
name: 'gopath',
32-
path: '/go',
33-
},
34-
],
35-
},
36-
{
37-
name: 'vet',
38-
image: 'golang:1.18',
39-
commands: [
40-
'go vet ./...',
41-
],
42-
volumes: [
43-
{
44-
name: 'gopath',
30+
name: 'godeps',
4531
path: '/go',
4632
},
4733
],
@@ -50,19 +36,19 @@ local PipelineTest = {
5036
name: 'test',
5137
image: 'golang:1.18',
5238
commands: [
53-
'go test -cover ./...',
39+
'make test',
5440
],
5541
volumes: [
5642
{
57-
name: 'gopath',
43+
name: 'godeps',
5844
path: '/go',
5945
},
6046
],
6147
},
6248
],
6349
volumes: [
6450
{
65-
name: 'gopath',
51+
name: 'godeps',
6652
temp: {},
6753
},
6854
],
@@ -74,7 +60,6 @@ local PipelineTest = {
7460

7561
local PipelineBuildBinaries = {
7662
kind: 'pipeline',
77-
image_pull_secrets: ['docker_config'],
7863
name: 'build-binaries',
7964
platform: {
8065
os: 'linux',
@@ -85,34 +70,14 @@ local PipelineBuildBinaries = {
8570
name: 'build',
8671
image: 'techknowlogick/xgo:go-1.18.x',
8772
commands: [
88-
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
89-
'mkdir -p release/',
90-
"cd cmd/drone-docker-buildx && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-docker-buildx .",
91-
'mv /build/* /drone/src/release/',
92-
'ls -l /drone/src/release/',
73+
'make release',
9374
],
9475
},
9576
{
9677
name: 'executable',
9778
image: 'alpine',
9879
commands: [
99-
'$(find release/ -executable -type f | grep drone-docker-buildx-linux-amd64) --help',
100-
],
101-
},
102-
{
103-
name: 'compress',
104-
image: 'alpine',
105-
commands: [
106-
'apk add upx',
107-
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
108-
'ls -lh release/',
109-
],
110-
},
111-
{
112-
name: 'checksum',
113-
image: 'alpine',
114-
commands: [
115-
'cd release/ && sha256sum * > sha256sum.txt',
80+
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
11681
],
11782
},
11883
{
@@ -139,7 +104,7 @@ local PipelineBuildBinaries = {
139104
api_key: {
140105
from_secret: 'github_token',
141106
},
142-
files: ['release/*'],
107+
files: ['dist/*'],
143108
title: '${DRONE_TAG}',
144109
note: 'CHANGELOG.md',
145110
},
@@ -160,7 +125,6 @@ local PipelineBuildBinaries = {
160125

161126
local PipelineBuildContainer(arch='amd64') = {
162127
kind: 'pipeline',
163-
image_pull_secrets: ['docker_config'],
164128
name: 'build-container-' + arch,
165129
platform: {
166130
os: 'linux',
@@ -171,20 +135,16 @@ local PipelineBuildContainer(arch='amd64') = {
171135
name: 'build',
172136
image: 'golang:1.18',
173137
commands: [
174-
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
175-
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-docker-buildx ./cmd/drone-docker-buildx',
138+
'make build',
176139
],
177140
},
178141
{
179142
name: 'dryrun',
180-
image: 'plugins/docker:19',
143+
image: 'thegeeklab/drone-docker:19',
181144
settings: {
182-
config: { from_secret: 'docker_config' },
183145
dry_run: true,
184146
dockerfile: 'docker/Dockerfile.' + arch,
185147
repo: 'thegeeklab/${DRONE_REPO_NAME}',
186-
username: { from_secret: 'docker_username' },
187-
password: { from_secret: 'docker_password' },
188148
},
189149
depends_on: ['build'],
190150
when: {
@@ -193,9 +153,8 @@ local PipelineBuildContainer(arch='amd64') = {
193153
},
194154
{
195155
name: 'publish-dockerhub',
196-
image: 'plugins/docker:19',
156+
image: 'thegeeklab/drone-docker:19',
197157
settings: {
198-
config: { from_secret: 'docker_config' },
199158
auto_tag: true,
200159
auto_tag_suffix: arch,
201160
dockerfile: 'docker/Dockerfile.' + arch,
@@ -210,9 +169,8 @@ local PipelineBuildContainer(arch='amd64') = {
210169
},
211170
{
212171
name: 'publish-quay',
213-
image: 'plugins/docker:19',
172+
image: 'thegeeklab/drone-docker:19',
214173
settings: {
215-
config: { from_secret: 'docker_config' },
216174
auto_tag: true,
217175
auto_tag_suffix: arch,
218176
dockerfile: 'docker/Dockerfile.' + arch,
@@ -291,7 +249,6 @@ local PipelineDocs = {
291249

292250
local PipelineNotifications = {
293251
kind: 'pipeline',
294-
image_pull_secrets: ['docker_config'],
295252
name: 'notifications',
296253
platform: {
297254
os: 'linux',

0 commit comments

Comments
 (0)