Skip to content

Commit bf9c3bc

Browse files
Merge pull request #2 from Ompragash/CI-12181
[CI-12181] Support for windows and macOS
2 parents 293fdfc + 701c33a commit bf9c3bc

File tree

6 files changed

+280
-23
lines changed

6 files changed

+280
-23
lines changed

.drone.yml

Lines changed: 233 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,244 @@
11
kind: pipeline
22
type: vm
33
name: default
4+
platform:
5+
os: linux
6+
arch: amd64
7+
pool:
8+
use: ubuntu
9+
10+
steps:
11+
- name: build
12+
image: golang:1.19
13+
commands:
14+
- go test ./...
15+
- sh scripts/build.sh
16+
trigger:
17+
ref:
18+
- refs/heads/main
19+
- refs/tags/**
20+
- refs/pull/**
21+
22+
---
23+
kind: pipeline
24+
type: vm
25+
name: linux-amd64
26+
platform:
27+
os: linux
28+
arch: amd64
29+
pool:
30+
use: ubuntu
31+
32+
steps:
33+
- name: environment
34+
image: golang:1.22
35+
pull: always
36+
environment:
37+
CGO_ENABLED: "0"
38+
commands:
39+
- go version
40+
- go env
41+
- name: build
42+
image: golang:1.22
43+
environment:
44+
CGO_ENABLED: "0"
45+
commands:
46+
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/amd64/plugin .
47+
- name: docker
48+
image: plugins/docker
49+
settings:
50+
dockerfile: docker/Dockerfile
51+
repo: plugins/artifact-metadata-publisher
52+
username:
53+
from_secret: docker_username
54+
password:
55+
from_secret: docker_password
56+
auto_tag: true
57+
auto_tag_suffix: linux-amd64
58+
depends_on:
59+
- default
60+
trigger:
61+
ref:
62+
- refs/heads/main
63+
- refs/tags/**
64+
- refs/pull/**
65+
66+
---
67+
kind: pipeline
68+
type: vm
69+
name: linux-arm64
70+
platform:
71+
os: linux
72+
arch: arm64
73+
pool:
74+
use: ubuntu_arm64
475

76+
steps:
77+
- name: environment
78+
image: golang:1.22
79+
pull: always
80+
environment:
81+
CGO_ENABLED: "0"
82+
commands:
83+
- go version
84+
- go env
85+
- name: build
86+
image: golang:1.22
87+
environment:
88+
CGO_ENABLED: "0"
89+
commands:
90+
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/arm64/plugin .
91+
- name: docker
92+
image: plugins/docker
93+
settings:
94+
dockerfile: docker/Dockerfile.linux.arm64
95+
repo: plugins/artifact-metadata-publisher
96+
username:
97+
from_secret: docker_username
98+
password:
99+
from_secret: docker_password
100+
auto_tag: true
101+
auto_tag_suffix: linux-arm64
102+
depends_on:
103+
- default
104+
trigger:
105+
ref:
106+
- refs/heads/main
107+
- refs/tags/**
108+
- refs/pull/**
109+
110+
---
111+
kind: pipeline
112+
type: vm
113+
name: windows-ltsc2022
114+
platform:
115+
os: windows
116+
arch: amd64
117+
pool:
118+
use: windows-2022
119+
120+
steps:
121+
- name: environment
122+
image: golang:1.22
123+
pull: always
124+
environment:
125+
CGO_ENABLED: "0"
126+
commands:
127+
- go version
128+
- go env
129+
- name: build
130+
image: golang:1.22
131+
environment:
132+
CGO_ENABLED: "0"
133+
commands:
134+
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/plugin.exe .
135+
- name: docker
136+
image: plugins/docker
137+
settings:
138+
dockerfile: docker/Dockerfile.windows
139+
repo: plugins/artifact-metadata-publisher
140+
username:
141+
from_secret: docker_username
142+
password:
143+
from_secret: docker_password
144+
auto_tag: true
145+
auto_tag_suffix: windows-ltsc2022-amd64
146+
daemon_off: true
147+
purge: false
148+
when:
149+
ref:
150+
- refs/heads/main
151+
- refs/tags/**
152+
depends_on:
153+
- default
154+
trigger:
155+
ref:
156+
- refs/heads/main
157+
- refs/tags/**
158+
- refs/pull/**
159+
160+
---
161+
kind: pipeline
162+
type: vm
163+
name: manifest
5164
platform:
6165
os: linux
7166
arch: amd64
8167
pool:
9168
use: ubuntu
10169

11170
steps:
12-
- name: build
13-
image: golang:1.19
14-
commands:
15-
- go test ./...
16-
- sh scripts/build.sh
17-
18-
- name: publish
19-
image: plugins/docker
20-
pull: if-not-exists
21-
settings:
22-
repo: plugins/artifact-metadata-publisher
23-
auto_tag: true
24-
dockerfile: Dockerfile
25-
username:
26-
from_secret: docker_username
27-
password:
28-
from_secret: docker_password
29-
when:
30-
event:
31-
exclude:
32-
- pull_request
171+
- name: manifest
172+
image: plugins/manifest
173+
settings:
174+
auto_tag: "true"
175+
username:
176+
from_secret: docker_username
177+
password:
178+
from_secret: docker_password
179+
spec: docker/manifest.tmpl
180+
ignore_missing: true
181+
depends_on:
182+
- linux-amd64
183+
- linux-arm64
184+
- windows-ltsc2022
185+
trigger:
186+
ref:
187+
- refs/heads/main
188+
- refs/tags/**
189+
190+
---
191+
kind: pipeline
192+
name: binaries
193+
type: vm
194+
195+
pool:
196+
use: ubuntu
197+
198+
steps:
199+
- name: build
200+
pull: always
201+
image: golang:1.22
202+
commands:
203+
- GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -a -tags netgo -o release/artifact-metadata-publisher-linux-amd64
204+
- GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -a -tags netgo -o release/artifact-metadata-publisher-linux-arm64
205+
- GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -a -tags netgo -o release/artifact-metadata-publisher-darwin-amd64
206+
- GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -a -tags netgo -o release/artifact-metadata-publisher-darwin-arm64
207+
- GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -a -tags netgo -o release/artifact-metadata-publisher-windows-amd64
208+
209+
environment:
210+
CGO_ENABLED: 0
211+
GO111MODULE: on
212+
213+
- name: zstd-compress
214+
commands:
215+
- sudo apt-get update -y
216+
- sudo apt-get install -y zstd
217+
- zstd release/artifact-metadata-publisher-linux-amd64
218+
- zstd release/artifact-metadata-publisher-linux-arm64
219+
- zstd release/artifact-metadata-publisher-darwin-arm64
220+
- zstd release/artifact-metadata-publisher-darwin-amd64
221+
- zstd release/artifact-metadata-publisher-windows-amd64
222+
223+
- name: release
224+
image: plugins/github-release
225+
settings:
226+
files:
227+
- release/artifact-metadata-publisher-linux-amd64.zst
228+
- release/artifact-metadata-publisher-linux-arm64.zst
229+
- release/artifact-metadata-publisher-darwin-arm64.zst
230+
- release/artifact-metadata-publisher-darwin-amd64.zst
231+
- release/artifact-metadata-publisher-windows-amd64.zst
232+
api_key:
233+
from_secret: github_token
234+
when:
235+
event:
236+
- tag
237+
depends_on:
238+
- linux-amd64
239+
- linux-arm64
240+
- windows-ltsc2022
241+
trigger:
242+
ref:
243+
- refs/heads/main
244+
- refs/tags/**

Dockerfile renamed to docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ ENV GODEBUG netdns=go
66
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
77

88
ADD release/linux/amd64/plugin /bin/
9-
ENTRYPOINT ["/bin/plugin"]
9+
ENTRYPOINT ["/bin/plugin"]

docker/Dockerfile.linux.arm64

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM alpine:3.15 as alpine
2+
RUN apk add -U --no-cache ca-certificates
3+
4+
FROM alpine:3.15
5+
ENV GODEBUG netdns=go
6+
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
7+
8+
ADD release/linux/arm64/plugin /bin/
9+
ENTRYPOINT ["/bin/plugin"]

docker/Dockerfile.windows

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM plugins/base:windows-ltsc2022-amd64
2+
USER ContainerAdministrator
3+
ENV GODEBUG=netdns=go
4+
5+
ADD release/windows/amd64/plugin.exe C:/
6+
7+
ENTRYPOINT ["C:\\plugin.exe"]

docker/manifest.tmpl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
image: plugins/artifact-metadata-publisher:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
2+
{{#if build.tags}}
3+
tags:
4+
{{#each build.tags}}
5+
- {{this}}
6+
{{/each}}
7+
{{/if}}
8+
manifests:
9+
-
10+
image: plugins/artifact-metadata-publisher:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
11+
platform:
12+
architecture: amd64
13+
os: linux
14+
-
15+
image: plugins/artifact-metadata-publisher:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
16+
platform:
17+
variant: v8
18+
architecture: arm64
19+
os: linux
20+
-
21+
image: plugins/artifact-metadata-publisher:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-amd64
22+
platform:
23+
architecture: amd64
24+
os: windows
25+
version: ltsc2022

scripts/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ set -e
1010
set -x
1111

1212
# linux
13-
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/plugin .
13+
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/plugin .
14+
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/plugin .
15+
16+
# windows
17+
GOOS=windows go build -o release/windows/amd64/plugin.exe .

0 commit comments

Comments
 (0)