-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
310 lines (291 loc) · 14.7 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
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
stages:
- build
- release-prepare
- release
- deploy
variables:
RUST_TOOLCHAIN: "1.82.0"
DOCKER_HOST: "tcp://docker:2375"
## BUILD
.build-cross-base-script:
script:
- apt-get update
- apt-get install -y curl build-essential ca-certificates iptables libdevmapper1.02.1
# - curl -fL https://getcli.jfrog.io | sh
# - ./jfrog config add rt-server-1 --artifactory-url=https://psono.jfrog.io/psono --user=gitlab --password=$artifactory_credentials --overwrite
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.28-1_amd64.deb" -o containerd.deb && echo "3fcc3e44e6d507c346ae05bbaef8f4bb04dfa8da9f04af658537f7e373c91340 containerd.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.12.1-1~ubuntu.22.04~jammy_amd64.deb" -o docker-buildx-plugin.deb && echo "3fb7cd11fd9bf7c31d81c1afa96c023519d9e6e17422192aa4d0aa2767ed0776 docker-buildx-plugin.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_25.0.3-1~ubuntu.22.04~jammy_amd64.deb" -o docker-ce-cli.deb && echo "624abe860a3d9dd190c278263b3ae115d54ce1135774a79f84026a6ec6ebafd1 docker-ce-cli.deb" | sha256sum -c -
- curl -fSL "https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_25.0.3-1~ubuntu.22.04~jammy_amd64.deb" -o docker-ce.deb && echo "63c7703814558a829ab3cc37c8018c050c9dad56f99c261090500f6c87821fd1 docker-ce.deb" | sha256sum -c -
- dpkg -i ./containerd.deb ./docker-ce.deb ./docker-ce-cli.deb ./docker-buildx-plugin.deb
- docker info
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- source /root/.cargo/env
- rustup --version
- rustup toolchain install "${RUST_TOOLCHAIN}"
- rustup default "${RUST_TOOLCHAIN}"
# gitlab ci build uses docker images from jfrog and not dockerhub
# - mv Cross_Gitlab.toml Cross.toml
- cargo --version
- cargo install cross
- cross --version
# - cross test --release --target "${BUILD_ENV}"
- cross build --release --target "${BUILD_ENV}"
.build-cross-base:
stage: build
image: psono-docker.jfrog.io/ubuntu:24.04
services:
- name: docker:25-dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
CROSS_REMOTE: 1
except:
- schedules
only:
- branches@psono/psono-ci
- tags@psono/psono-ci
.build-cross-linux:
extends: .build-cross-base
artifacts:
name: "${BUILD_ENV}_${CI_COMMIT_REF_NAME}"
paths:
- ./target/${BUILD_ENV}/release/psonoci
expire_in: 1 week
script:
- !reference [.build-cross-base-script, script]
- ls -la "target/${BUILD_ENV}/release/psonoci"
# - ./jfrog rt u --target-props="CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME;CI_COMMIT_SHA=$CI_COMMIT_SHA;CI_COMMIT_URL=$CI_PROJECT_URL/commit/$CI_COMMIT_SHA;CI_PROJECT_ID=$CI_PROJECT_ID;CI_PROJECT_NAME=$CI_PROJECT_NAME;CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE;CI_PROJECT_URL=$CI_PROJECT_URL;CI_PIPELINE_ID=$CI_PIPELINE_ID;CI_PIPELINE_URL=$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID;CI_JOB_ID=$CI_JOB_ID;CI_JOB_URL=$CI_PROJECT_URL/-/jobs/$CI_JOB_ID;CI_JOB_NAME=$CI_JOB_NAME;CI_JOB_STAGE=$CI_JOB_STAGE;CI_RUNNER_ID=$CI_RUNNER_ID;GITLAB_USER_ID=$GITLAB_USER_ID;CI_SERVER_VERSION=$CI_SERVER_VERSION" "target/${BUILD_ENV}/release/psonoci" "psono/ci/${CI_COMMIT_REF_NAME}/${BUILD_ENV}/psonoci"
# - ./jfrog rt sp "psono/ci/${CI_COMMIT_REF_NAME}/${BUILD_ENV}/psonoci" "CI_COMMIT_TAG=$CI_COMMIT_TAG" || true
.build-cross-windows:
extends: .build-cross-base
artifacts:
name: "${BUILD_ENV}_${CI_COMMIT_REF_NAME}"
paths:
- ./target/${BUILD_ENV}/release/psonoci.exe
expire_in: 1 week
script:
- !reference [.build-cross-base-script, script]
- ls -la "target/${BUILD_ENV}/release/psonoci.exe"
# - ./jfrog rt u --target-props="CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME;CI_COMMIT_SHA=$CI_COMMIT_SHA;CI_COMMIT_URL=$CI_PROJECT_URL/commit/$CI_COMMIT_SHA;CI_PROJECT_ID=$CI_PROJECT_ID;CI_PROJECT_NAME=$CI_PROJECT_NAME;CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE;CI_PROJECT_URL=$CI_PROJECT_URL;CI_PIPELINE_ID=$CI_PIPELINE_ID;CI_PIPELINE_URL=$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID;CI_JOB_ID=$CI_JOB_ID;CI_JOB_URL=$CI_PROJECT_URL/-/jobs/$CI_JOB_ID;CI_JOB_NAME=$CI_JOB_NAME;CI_JOB_STAGE=$CI_JOB_STAGE;CI_RUNNER_ID=$CI_RUNNER_ID;GITLAB_USER_ID=$GITLAB_USER_ID;CI_SERVER_VERSION=$CI_SERVER_VERSION" "target/${BUILD_ENV}/release/psonoci.exe" "psono/ci/${CI_COMMIT_REF_NAME}/${BUILD_ENV}/psonoci.exe"
# - ./jfrog rt sp "psono/ci/${CI_COMMIT_REF_NAME}/${BUILD_ENV}/psonoci.exe" "CI_COMMIT_TAG=$CI_COMMIT_TAG" || true
# Build job for x86_64-unknown-linux-musl
build-x86_64-unknown-linux-musl:
extends: .build-cross-linux
variables:
BUILD_ENV: x86_64-unknown-linux-musl
# Build job for armv7-unknown-linux-gnueabihf
build-armv7-unknown-linux-gnueabihf:
extends: .build-cross-linux
variables:
BUILD_ENV: armv7-unknown-linux-gnueabihf
# Build job for aarch64-unknown-linux-musl
build-aarch64-unknown-linux-musl:
extends: .build-cross-linux
variables:
BUILD_ENV: aarch64-unknown-linux-musl
# Build job for build-x86_64-pc-windows-gnu
build-x86_64-pc-windows-gnu:
extends: .build-cross-windows
variables:
BUILD_ENV: x86_64-pc-windows-gnu
build-x86_64-pc-windows-msvc:
stage: build
script:
- .\var\build_windows.ps1
artifacts:
name: "psonoci_x86_64-pc-windows-msvc_$CI_COMMIT_REF_NAME"
paths:
- ./target/x86_64-pc-windows-msvc/release/psonoci.exe
expire_in: 1 week
variables:
BUILD_ENV: x86_64-pc-windows-msvc
tags:
- windows
except:
- schedules
only:
- branches@psono/psono-ci
- tags@psono/psono-ci
.build-macos:
stage: build
tags:
- macos
script:
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- . "$HOME/.cargo/env"
- rustup --version
- rustup toolchain install "${RUST_TOOLCHAIN}"
- rustup default "${RUST_TOOLCHAIN}"
- rustup target add "${BUILD_ENV}"
- cargo --version
- cargo build --release --target "${BUILD_ENV}"
artifacts:
name: "${BUILD_ENV}_${CI_COMMIT_REF_NAME}"
paths:
- ./target/${BUILD_ENV}/release/psonoci
expire_in: 1 week
except:
- schedules
only:
- branches@psono/psono-ci
- tags@psono/psono-ci
# Build job for x86_64-apple-darwin
build-x86_64-apple-darwin:
extends: .build-macos
variables:
BUILD_ENV: x86_64-apple-darwin
# Build job for aarch64-apple-darwin
build-aarch64-apple-darwin:
extends: .build-macos
variables:
BUILD_ENV: aarch64-apple-darwin
# release-artifacts:
# except:
# - schedules
# stage: release
# image: psono-docker.jfrog.io/ubuntu:22.04
# script:
# - apt-get update
# - apt-get install -y curl
# - curl -fL https://getcli.jfrog.io | sh
# - ./jfrog config add rt-server-1 --artifactory-url=https://psono.jfrog.io/psono --user=gitlab --password=$artifactory_credentials --overwrite
# - ./jfrog rt cp --flat "psono/ci/${CI_COMMIT_REF_NAME}/x86_64-unknown-linux-musl/psonoci" psono/ci/latest/x86_64-unknown-linux-musl/
# - ./jfrog rt cp --flat "psono/ci/${CI_COMMIT_REF_NAME}/armv7-unknown-linux-musleabihf/psonoci" psono/ci/latest/armv7-unknown-linux-musleabihf/
# - ./jfrog rt cp --flat "psono/ci/${CI_COMMIT_REF_NAME}/aarch64-unknown-linux-musl/psonoci" psono/ci/latest/aarch64-unknown-linux-musl/
# # - ./jfrog rt cp --flat "psono/ci/${CI_COMMIT_REF_NAME}/x86_64-pc-windows-gnu/psonoci" psono/ci/latest/x86_64-pc-windows-gnu/
# only:
# - /^v[0-9]*\.[0-9]*\.[0-9]*$/
collect-artifacts:
image: psono-docker.jfrog.io/ubuntu:24.04
stage: release-prepare
script:
- bash var/upload_artifacts.sh
dependencies:
- build-x86_64-unknown-linux-musl
- build-armv7-unknown-linux-gnueabihf
- build-aarch64-unknown-linux-musl
- build-x86_64-pc-windows-gnu
- build-x86_64-pc-windows-msvc
- build-x86_64-apple-darwin
- build-aarch64-apple-darwin
artifacts:
name: "psonoci_collected_${CI_COMMIT_REF_NAME}"
paths:
- collected_artifacts/*.zip
- collected_artifacts/*.tar.gz
- collected_artifacts/*.sig
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
- gitlab-release-test-tag
- gitlab-release-test-tag2
gitlab-release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
script:
- echo "Creating GitLab release with zip and tar.gz files..."
dependencies:
- collect-artifacts
release:
name: "psonoci $CI_COMMIT_TAG"
tag_name: "$CI_COMMIT_TAG"
description: "psonoci release of version $CI_COMMIT_TAG"
assets:
links:
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-unknown-linux-musl.tar.gz"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-unknown-linux-musl.tar.gz"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-unknown-linux-musl.tar.gz.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-unknown-linux-musl.tar.gz.sig"
- name: "psonoci-${CI_COMMIT_TAG}-armv7-unknown-linux-gnueabihf.tar.gz"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-armv7-unknown-linux-gnueabihf.tar.gz"
- name: "psonoci-${CI_COMMIT_TAG}-armv7-unknown-linux-gnueabihf.tar.gz.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-armv7-unknown-linux-gnueabihf.tar.gz.sig"
- name: "psonoci-${CI_COMMIT_TAG}-aarch64-unknown-linux-musl.tar.gz"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-aarch64-unknown-linux-musl.tar.gz"
- name: "psonoci-${CI_COMMIT_TAG}-aarch64-unknown-linux-musl.tar.gz.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-aarch64-unknown-linux-musl.tar.gz.sig"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-gnu.zip"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-gnu.zip"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-gnu.zip.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-gnu.zip.sig"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-msvc.zip"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-msvc.zip"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-msvc.zip.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-pc-windows-msvc.zip.sig"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-apple-darwin.tar.gz"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-apple-darwin.tar.gz"
- name: "psonoci-${CI_COMMIT_TAG}-x86_64-apple-darwin.tar.gz.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-x86_64-apple-darwin.tar.gz.sig"
- name: "psonoci-${CI_COMMIT_TAG}-aarch64-apple-darwin.tar.gz"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-aarch64-apple-darwin.tar.gz"
- name: "psonoci-${CI_COMMIT_TAG}-aarch64-apple-darwin.tar.gz.sig"
url: "https://get.psono.com/${CI_PROJECT_PATH}/${CI_COMMIT_TAG}/psonoci-${CI_COMMIT_TAG}-aarch64-apple-darwin.tar.gz.sig"
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
- gitlab-release-test-tag
- gitlab-release-test-tag2
# deploy-artifacts:
# except:
# - schedules
# stage: deploy
# image: psono-docker.jfrog.io/ubuntu:24.04
# script:
# - sh ./var/login_gcp.sh
# - curl https://psono.jfrog.io/psono/psono/ci/master/x86_64-unknown-linux-musl/psonoci --output psonoci-x86_64-unknown-linux-musl
# - gsutil cp psonoci-x86_64-unknown-linux-musl gs://get.psono.com/$CI_PROJECT_PATH/x86_64-linux/psonoci
# - curl https://psono.jfrog.io/psono/psono/ci/master/armv7-unknown-linux-musleabihf/psonoci --output psonoci-armv7-unknown-linux-musleabihf
# - gsutil cp psonoci-armv7-unknown-linux-musleabihf gs://get.psono.com/$CI_PROJECT_PATH/armv7-linux/psonoci
# - curl https://psono.jfrog.io/psono/psono/ci/master/aarch64-unknown-linux-musl/psonoci --output psonoci-aarch64-unknown-linux-musl
# - gsutil cp psonoci-aarch64-unknown-linux-musl gs://get.psono.com/$CI_PROJECT_PATH/aarch64-linux/psonoci
# # - curl https://psono.jfrog.io/psono/psono/ci/master/x86_64-pc-windows-gnu/psonoci.exe --output psonoci-x86_64-pc-windows-gnu.exe
# # - gsutil cp psonoci-x86_64-pc-windows-gnu.exe gs://get.psono.com/$CI_PROJECT_PATH/x86_64-pc-windows-gnu/psonoci.exe
# only:
# - /^v[0-9]*\.[0-9]*\.[0-9]*$/
deploy-latest:
except:
- schedules
stage: deploy
image: psono-docker.jfrog.io/ubuntu:24.04
script:
- sh ./var/login_gcp.sh
# Linux x86_64
- gsutil cp ./target/x86_64-unknown-linux-musl/release/psonoci gs://get.psono.com/$CI_PROJECT_PATH/x86_64-linux/psonoci
# Linux armv7
- gsutil cp ./target/armv7-unknown-linux-gnueabihf/release/psonoci gs://get.psono.com/$CI_PROJECT_PATH/armv7-linux/psonoci
# Linux aarch64
- gsutil cp ./target/aarch64-unknown-linux-musl/release/psonoci gs://get.psono.com/$CI_PROJECT_PATH/aarch64-linux/psonoci
# # Windows x86_64 GNU
# - gsutil cp ./target/x86_64-pc-windows-gnu/release/psonoci.exe gs://get.psono.com/$CI_PROJECT_PATH/x86_64-windows-gnu/psonoci.exe
# Windows x86_64 MSVC
- gsutil cp ./target/x86_64-pc-windows-msvc/release/psonoci.exe gs://get.psono.com/$CI_PROJECT_PATH/x86_64-windows/psonoci.exe
# macOS x86_64
- gsutil cp ./target/x86_64-apple-darwin/release/psonoci gs://get.psono.com/$CI_PROJECT_PATH/x86_64-macos/psonoci
# macOS aarch64
- gsutil cp ./target/aarch64-apple-darwin/release/psonoci gs://get.psono.com/$CI_PROJECT_PATH/aarch64-macos/psonoci
dependencies:
- build-x86_64-unknown-linux-musl
- build-armv7-unknown-linux-gnueabihf
- build-aarch64-unknown-linux-musl
- build-x86_64-pc-windows-gnu
- build-x86_64-pc-windows-msvc
- build-x86_64-apple-darwin
- build-aarch64-apple-darwin
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
# deploy-changelog:
# except:
# - schedules
# stage: deploy
# image: psono-docker.jfrog.io/ubuntu:20.04
# script:
# - sh ./var/login_gcp.sh
# - 'curl -H "PRIVATE-TOKEN: $GITLAB_PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/repository/tags" --output changelog.json'
# - gsutil cp changelog.json gs://static.psono.com/gitlab.com/$CI_PROJECT_PATH/changelog.json
# environment:
# name: static.psono.com
# url: https://static.psono.com/gitlab.com/psono/psono-client/changelog.json
# only:
# - /^v[0-9]*\.[0-9]*\.[0-9]*$/