-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
337 lines (324 loc) · 10.5 KB
/
.gitlab-ci.yml
File metadata and controls
337 lines (324 loc) · 10.5 KB
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
stages:
- quality
- build
- publish
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.build_release_rules: &build_release_rules
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == "release"'
default:
interruptible: true
before_script:
- |
if [ -n "${CI_COMMIT_TAG:-}" ]; then
export WBEAM_VERSION="${CI_COMMIT_TAG#v}"
export WBEAM_VERSION="${WBEAM_VERSION#V}"
elif [ "${CI_COMMIT_BRANCH:-}" = "release" ]; then
export WBEAM_VERSION="0.1.2.${CI_PIPELINE_IID}.${CI_COMMIT_SHORT_SHA}"
else
export WBEAM_VERSION="0.0.0.${CI_DEFAULT_BRANCH}.${CI_PIPELINE_IID}.${CI_COMMIT_SHORT_SHA}"
fi
- chmod +x scripts/ci/*.sh
quality_gates:
stage: quality
image: alpine:3.21
script:
- apk add --no-cache bash ripgrep
- ./scripts/ci/check-repo-layout.sh
- ./scripts/ci/check-boundaries.sh
- ./scripts/ci/validate-e2e-matrix.sh
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
sonar_scan_push_master:
stage: quality
image: sonarsource/sonar-scanner-cli:latest
before_script: []
variables:
GIT_DEPTH: "0"
script:
- ': "${SONAR_HOST_URL:=http://192.168.100.208:9000}"'
- ': "${SONAR_TOKEN:?Set SONAR_TOKEN in GitLab CI/CD variables}"'
- sonar-scanner
-Dsonar.projectBaseDir="${CI_PROJECT_DIR}"
-Dsonar.host.url="${SONAR_HOST_URL}"
-Dsonar.token="${SONAR_TOKEN}"
-Dsonar.projectKey="wbeam"
-Dsonar.projectName="WBeam"
-Dsonar.qualitygate.wait=false
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
build_deb:
stage: build
image: rust:bookworm
script:
- apt-get update
- >
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
ca-certificates
curl
git
jq
pkg-config
build-essential
libssl-dev
libdbus-1-dev
libgstreamer1.0-dev
libgstreamer-plugins-base1.0-dev
libx11-dev
libxrandr-dev
libxfixes-dev
libxext-dev
libxrender-dev
nodejs
npm
libwebkit2gtk-4.1-dev
libgtk-3-dev
libsoup-3.0-dev
libayatana-appindicator3-dev
dpkg-dev
- ./scripts/ci/build_deb.sh
artifacts:
paths:
- dist/*.deb
- dist/VERSION.txt
expire_in: 14 days
rules: *build_release_rules
build_rpm:
stage: build
image: fedora:41
script:
- dnf -y install ca-certificates curl git jq rust cargo gcc gcc-c++ make pkgconf-pkg-config
- dnf -y install openssl-devel dbus-devel gstreamer1-devel gstreamer1-plugins-base-devel nodejs webkit2gtk4.1-devel gtk3-devel libsoup3-devel libayatana-appindicator-gtk3-devel
- dnf -y install libX11-devel libXrandr-devel libXfixes-devel libXext-devel libXrender-devel
- dnf -y install rpm-build tar gzip findutils
- ./scripts/ci/build_rpm.sh
artifacts:
paths:
- dist/*.rpm
- dist/VERSION.txt
expire_in: 14 days
rules: *build_release_rules
build_aarch64_tar:
stage: build
image: rust:bookworm
script:
- apt-get update
- >
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
ca-certificates
curl
git
jq
pkg-config
build-essential
gcc-aarch64-linux-gnu
libc6-dev-arm64-cross
libssl-dev
libdbus-1-dev
libx11-dev
libxrandr-dev
libxfixes-dev
libxext-dev
libxrender-dev
file
tar
gzip
- ./scripts/ci/build_aarch64_tar.sh
artifacts:
paths:
- dist/*aarch64*.tar.gz
- dist/VERSION.txt
expire_in: 14 days
allow_failure: true
rules: *build_release_rules
build_apk_release:
stage: build
image: eclipse-temurin:17-jdk-jammy
variables:
ANDROID_SDK_ROOT: "/opt/android-sdk"
ANDROID_HOME: "/opt/android-sdk"
GRADLE_USER_HOME: "${CI_PROJECT_DIR}/.gradle-user"
script:
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends curl unzip ca-certificates
- mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools"
- curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o /tmp/cmdline-tools.zip
- unzip -q /tmp/cmdline-tools.zip -d /tmp
- rm -rf "${ANDROID_SDK_ROOT}/cmdline-tools/latest"
- mv /tmp/cmdline-tools "${ANDROID_SDK_ROOT}/cmdline-tools/latest"
- |
set +o pipefail
yes | "${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --sdk_root="${ANDROID_SDK_ROOT}" --licenses >/dev/null
set -o pipefail
- '"${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --sdk_root="${ANDROID_SDK_ROOT}" "platform-tools" "platforms;android-35" "build-tools;35.0.0"'
- ./scripts/ci/build_apk_release.sh
artifacts:
paths:
- dist/*.apk
- dist/VERSION.txt
expire_in: 14 days
rules: *build_release_rules
build_windows_server:
stage: build
tags:
- windows
- zerotier
- build
before_script:
- |
$ErrorActionPreference = "Stop"
if ($env:CI_COMMIT_TAG) {
$tag = $env:CI_COMMIT_TAG
if ($tag.StartsWith("v") -or $tag.StartsWith("V")) {
$tag = $tag.Substring(1)
}
$env:WBEAM_VERSION = $tag
} elseif ($env:CI_COMMIT_BRANCH -eq "release") {
$env:WBEAM_VERSION = "0.1.2.$($env:CI_PIPELINE_IID).$($env:CI_COMMIT_SHORT_SHA)"
} else {
$env:WBEAM_VERSION = "0.0.0.$($env:CI_DEFAULT_BRANCH).$($env:CI_PIPELINE_IID).$($env:CI_COMMIT_SHORT_SHA)"
}
cmd /c "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=x64 -arch=x64 && set" |
ForEach-Object {
if ($_ -match "^(.*?)=(.*)$") {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process")
}
}
$cargoBase = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
$rustupBase = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
if (Test-Path "$cargoBase\bin\cargo.exe") {
$env:Path = "$cargoBase\bin;$env:Path"
}
if (Test-Path $rustupBase) {
$env:RUSTUP_HOME = $rustupBase
}
if (Test-Path $cargoBase) {
$env:CARGO_HOME = $cargoBase
}
rustup default stable | Out-Null
cargo --version
script:
- |
Set-Location "$env:CI_PROJECT_DIR\host\rust"
cargo build --release -p wbeamd-server
New-Item -ItemType Directory -Path "$env:CI_PROJECT_DIR\dist" -Force | Out-Null
Copy-Item `
"$env:CI_PROJECT_DIR\host\rust\target\release\wbeamd-server.exe" `
"$env:CI_PROJECT_DIR\dist\wbeamd-server-$env:WBEAM_VERSION-windows-x86_64.exe" `
-Force
@(
"WBEAM_VERSION=$env:WBEAM_VERSION"
"CI_PIPELINE_ID=$env:CI_PIPELINE_ID"
"CI_COMMIT_SHA=$env:CI_COMMIT_SHA"
"CI_COMMIT_REF_NAME=$env:CI_COMMIT_REF_NAME"
) | Set-Content -Path "$env:CI_PROJECT_DIR\dist\VERSION.txt" -Encoding ascii
artifacts:
paths:
- dist/*windows*.exe
- dist/VERSION.txt
expire_in: 14 days
rules: *build_release_rules
build_windows_server:
stage: build
tags:
- windows
- zerotier
- build
before_script:
- |
$ErrorActionPreference = "Stop"
if ($env:CI_COMMIT_TAG) {
$tag = $env:CI_COMMIT_TAG
if ($tag.StartsWith("v") -or $tag.StartsWith("V")) {
$tag = $tag.Substring(1)
}
$env:WBEAM_VERSION = $tag
} elseif ($env:CI_COMMIT_BRANCH -eq "release") {
$env:WBEAM_VERSION = "0.1.2.$($env:CI_PIPELINE_IID).$($env:CI_COMMIT_SHORT_SHA)"
} else {
$env:WBEAM_VERSION = "0.0.0.$($env:CI_DEFAULT_BRANCH).$($env:CI_PIPELINE_IID).$($env:CI_COMMIT_SHORT_SHA)"
}
cmd /c "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=x64 -arch=x64 && set" |
ForEach-Object {
if ($_ -match "^(.*?)=(.*)$") {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process")
}
}
$cargoBase = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
$rustupBase = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
if (Test-Path "$cargoBase\bin\cargo.exe") {
$env:Path = "$cargoBase\bin;$env:Path"
}
if (Test-Path $rustupBase) {
$env:RUSTUP_HOME = $rustupBase
}
if (Test-Path $cargoBase) {
$env:CARGO_HOME = $cargoBase
}
rustup default stable | Out-Null
cargo --version
script:
- |
Set-Location "$env:CI_PROJECT_DIR\host\rust"
cargo build --release -p wbeamd-server
New-Item -ItemType Directory -Path "$env:CI_PROJECT_DIR\dist" -Force | Out-Null
Copy-Item `
"$env:CI_PROJECT_DIR\host\rust\target\release\wbeamd-server.exe" `
"$env:CI_PROJECT_DIR\dist\wbeamd-server-$env:WBEAM_VERSION-windows-x86_64.exe" `
-Force
@(
"WBEAM_VERSION=$env:WBEAM_VERSION"
"CI_PIPELINE_ID=$env:CI_PIPELINE_ID"
"CI_COMMIT_SHA=$env:CI_COMMIT_SHA"
"CI_COMMIT_REF_NAME=$env:CI_COMMIT_REF_NAME"
) | Set-Content -Path "$env:CI_PROJECT_DIR\dist\VERSION.txt" -Encoding ascii
artifacts:
paths:
- dist/*windows*.exe
- dist/VERSION.txt
expire_in: 14 days
rules: *build_release_rules
publish_github_release:
stage: publish
image: alpine:3.21
variables:
GIT_STRATEGY: fetch
script:
- apk add --no-cache bash curl jq
- ./scripts/ci/publish_github_release.sh
rules: *build_release_rules
ff_release_to_master:
stage: publish
image: alpine:3.21
variables:
GIT_STRATEGY: fetch
needs:
- publish_github_release
script:
- apk add --no-cache git
- git config user.name "wbeam-ci"
- git config user.email "ci@wbeam.local"
- |
if [ -n "${CI_SERVER_TLS_CA_FILE:-}" ] && [ -f "${CI_SERVER_TLS_CA_FILE}" ]; then
git config --global http.sslCAInfo "${CI_SERVER_TLS_CA_FILE}"
fi
- |
PUSH_TOKEN="${GITLAB_PUSH_TOKEN:-${GITLAB_TOKEN:-}}"
if [ -n "${PUSH_TOKEN}" ]; then
git remote set-url origin "https://oauth2:${PUSH_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
fi
- git fetch origin master release
- git checkout -B master origin/master
- git merge --ff-only origin/release
- |
if ! git push origin master; then
echo "[ff_release_to_master] Push rejected (likely protected branch / missing rights)."
echo "[ff_release_to_master] Set CI variable GITLAB_PUSH_TOKEN (or GITLAB_TOKEN) with push rights to enable auto-ff."
fi
allow_failure: true
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "release"'