forked from signalfx/signalfx-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
229 lines (218 loc) · 6.11 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
default:
image: 'docker.repo.splunkdev.net/ci-cd/ci-container:python-3.9'
stages:
- update-stage-cache
- win-bundle-build
- win-bundle-sign
- win-msi-build
- win-msi-sign
- release
- github-release
.sign-release-cache:
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: "sign-release-pip-cache"
paths:
- .cache/pip
before_script:
- pip3 install -r scripts/signing/requirements.txt
update-stage-cache:
stage: update-stage-cache
needs: []
only:
- schedules
variables:
PULL_CACHE: "yes"
retry: 2
before_script:
- docker login -u $CIRCLECI_QUAY_USERNAME -p $CIRCLECI_QUAY_PASSWORD quay.io
script:
- make stage-cache
win-bundle-build:
stage: win-bundle-build
needs: []
tags:
- windows
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
variables:
GOPATH: "C:\\Go"
GOOS: "windows"
GO111MODULE: "on"
before_script:
- choco upgrade -y golang --version 1.14.2
- choco upgrade -y git --version 2.33.0.2
- refreshenv
script:
- $env:PATH = "${env:GOPATH}\bin;C:\Program Files\Git\bin;${env:PATH}"
- .\scripts\windows\make.ps1 bundle
artifacts:
paths:
- build/SignalFxAgent-*.zip
win-bundle-sign:
extends:
- .sign-release-cache
stage: win-bundle-sign
dependencies:
- win-bundle-build
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
retry: 2
script:
- scripts/signing/sign_win_agent.py $( ls build/SignalFxAgent-*.zip )
artifacts:
paths:
- build/signed/SignalFxAgent-*.zip
win-msi-build:
stage: win-msi-build
dependencies:
- win-bundle-sign
tags:
- windows
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
before_script:
- choco upgrade -y wixtoolset --version 3.11.2
- refreshenv
script:
- $env:PATH = "C:\Program Files (x86)\WiX Toolset v3.11\bin;${env:PATH}"
- .\scripts\windows\make.ps1 build_msi -zipfile $( Resolve-Path .\build\signed\SignalFxAgent-*.zip )
artifacts:
paths:
- build/SignalFxAgent-*.msi
win-msi-sign:
extends:
- .sign-release-cache
stage: win-msi-sign
dependencies:
- win-msi-build
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
retry: 2
script:
- scripts/signing/sign_win_agent.py $( ls build/SignalFxAgent-*.msi )
artifacts:
paths:
- build/signed/SignalFxAgent-*.msi
win-choco-release:
stage: release
dependencies:
- win-msi-sign
tags:
- windows
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
before_script:
- choco upgrade -y checksum --version 0.2.0
- refreshenv
script:
- .\scripts\windows\make.ps1 build_choco -msifile $( Resolve-Path .\build\signed\SignalFxAgent-*.msi )
- choco push -k $env:CHOCO_TOKEN $( Resolve-Path .\build\signalfx-agent.*.nupkg )
artifacts:
paths:
- build/signalfx-agent.*.nupkg
win-docker-release:
stage: release
dependencies:
- win-bundle-sign
tags:
- windows
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
retry: 2
before_script:
- docker login -u $env:CIRCLECI_QUAY_USERNAME -p $env:CIRCLECI_QUAY_PASSWORD quay.io
- Expand-Archive -Path build\signed\SignalFxAgent-*.zip -DestinationPath tmp
- mkdir dist
- mv tmp\SignalFxAgent\bin\signalfx-agent.exe dist\signalfx-agent.exe
- rm -recurse -force tmp
script:
- |
$ErrorActionPreference = 'Stop'
$IMAGE_NAME = "quay.io/signalfx/signalfx-agent"
$IMAGE_TAG = $env:CI_COMMIT_TAG.TrimStart("v") + "-windows"
echo "Building and pushing ${IMAGE_NAME}:${IMAGE_TAG}"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -f Dockerfile.windows .
docker push ${IMAGE_NAME}:${IMAGE_TAG}
after_script:
- docker image prune --all --force
linux-release:
extends:
- .sign-release-cache
stage: release
needs: []
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
script:
- docker login -u $CIRCLECI_QUAY_USERNAME -p $CIRCLECI_QUAY_PASSWORD quay.io
- mkdir -p dist
- |
set -exo pipefail
STAGE="release"
AGENT_IMAGE_NAME="quay.io/signalfx/signalfx-agent"
AGENT_VERSION="${CI_COMMIT_TAG#v}"
IMAGE="${AGENT_IMAGE_NAME}:${AGENT_VERSION}"
./scripts/docker-cache-from # pre-pull stage cache images
./scripts/release --stage $STAGE --component docker --component deb --component rpm --component bundle
digest=$( docker inspect --format='{{.RepoDigests}}' $IMAGE | sed "s|\[.*@\(sha256:.*\)\]|\1|" )
if [[ ! "$digest" =~ ^sha256:[A-Fa-f0-9]{64}$ ]]; then
echo "Failed to get repo digest for $IMAGE!"
exit 1
fi
echo -n "$digest" > dist/digest.txt
docker save -o dist/image.tar $IMAGE
mv signalfx-agent-*.tar.gz dist/
mv packaging/deb/output/signalfx-agent_*.deb dist/
mv packaging/rpm/output/x86_64/signalfx-agent-*.rpm dist/
artifacts:
paths:
- dist
github-release:
stage: github-release
dependencies:
- win-bundle-sign
- win-msi-sign
- linux-release
only:
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- schedules
before_script:
# install gh cli
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
- apt update
- apt install -y gh
script:
- mkdir -p dist/assets/
- mv dist/signalfx-agent-*.tar.gz dist/assets/
- mv build/signed/SignalFxAgent-*.zip dist/assets/
- mv build/signed/SignalFxAgent-*.msi dist/assets/
- ./scripts/create-github-release.sh "$CI_COMMIT_TAG" "$( cat dist/digest.txt )" ./dist/assets
artifacts:
when: always
paths:
- dist/assets