-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
238 lines (224 loc) · 5.8 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
include:
- local: ci/gitlab_templates/RULES.yml
variables:
ROS_BRIDGE_VERSION: "2.0"
TARGET_DEVICES: AXC F 3152 #,EPC 1522,EPC 1502
DOCKER_IMAGE_PATH: ${CI_PROJECT_DIR}/generated
APP_PATH: ${CI_PROJECT_DIR}/app/images
APP_NAME: plcnext-ros-bridge
BUILDER_PREFIX: "ghcr.io/ipa-rwu/"
BUILDER_SUFFIX: ":latest"
CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=RELEASE"
DEFAULT_ROS_DISTROS: noetic foxy galactic rolling humble
DEP_REPO_NAME: gRPC-client-deps
DEP_REPO_URL: https://github.com/PLCnext/${DEP_REPO_NAME}.git
DOCKER_BUILDKIT: 1
DOCKER_TLS_CERTDIR: ""
FOLDER: ${CI_JOB_NAME}/
NAME: ${CI_JOB_NAME}
PREFIX: "${CI_PIPELINE_ID}:"
ROS_VERSIONS: ros1 ros2
ROSINSTALL_CI_JOB_TOKEN: "true"
STABLE_BRANCH: devel
SUFFIX: ""
TARGET_LATEST: ${NAME}:latest
TARGET_RELEASE: ${NAME}:${CI_COMMIT_TAG//\//-}
.common:
tags: &kaniko_runner
- shared-runner-kubernetes
create_release_tag_script:
- |
if [ "$CI_COMMIT_REF_NAME" = "main" ] || [ "$CI_COMMIT_REF_NAME" = "master" ]; then
TARGET=$TARGET_LATEST
fi
if [[ $(expr match "$CI_COMMIT_REF_NAME" ".*$STABLE_BRANCH") != 0 ]]; then
TARGET=$TARGET_LATEST
fi
if [ $CI_COMMIT_TAG ]; then
convert_tag=${CI_COMMIT_TAG//\//-}
distro_prefix=${ROS_DISTRO}-
remove_distro_tag=${convert_tag#"$distro_prefix"}
TARGET_RELEASE=${NAME}:${remove_distro_tag}
TARGET=$TARGET_RELEASE
fi
.build:
stage: build
tags: *kaniko_runner
image:
name: gcr.io/kaniko-project/executor:v1.9.0-debug
entrypoint: [""]
script:
- /kaniko/executor
--context "${CI_PROJECT_DIR}/${FOLDER}"
--build-arg SUFFIX
--build-arg PREFIX
--build-arg DEP_REPO_NAME
--build-arg DEP_REPO_URL
--build-arg BUILDER_PREFIX
--build-arg BUILDER_SUFFIX
--build-arg ROS_DISTRO
--build-arg ROSINSTALL_CI_JOB_TOKEN
--build-arg CI_JOB_TOKEN
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg CMAKE_ARGS
--dockerfile "${CI_PROJECT_DIR}/${FOLDER}Dockerfile"
--no-push
--destination "${TARGET}"
--tarPath ${PREFIX//:/-}${NAME}${SUFFIX}.tar
variables:
NAME: ${CI_JOB_NAME}_${ROS_DISTRO}
artifacts:
name: ${NAME}
paths:
- ${PREFIX//:/-}${NAME}${SUFFIX}.tar
expire_in: 10 minutes
build_${APP_NAME}_ros1:
extends:
- .build
- .on_ros1
before_script:
- TARGET=${PREFIX}${NAME}${SUFFIX}
- !reference [.common, create_release_tag_script]
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
FOLDER: ""
parallel:
matrix:
- ROS_DISTRO:
- noetic
build_${APP_NAME}_ros2:
extends:
- .build
- .on_ros2
before_script:
- TARGET=${PREFIX}${NAME}${SUFFIX}
- !reference [.common, create_release_tag_script]
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
FOLDER: ""
parallel:
matrix:
- ROS_DISTRO:
- foxy
#- galactic
- humble
- rolling
.publish:
stage: publish
tags: *kaniko_runner
image: alpine:latest
script:
- TARGET=${NAME}:${CI_COMMIT_REF_NAME//\//-}
- !reference [.common, create_release_tag_script]
- mkdir ${DOCKER_IMAGE_PATH}
- mv ${PREFIX//:/-}${NAME}${SUFFIX}.tar ${DOCKER_IMAGE_PATH}/${TARGET//:/-}.tar
needs:
- build
artifacts:
name: ${NAME}
paths:
- ${DOCKER_IMAGE_PATH}/*.tar
expire_in: 10 minutes
publish_${APP_NAME}_ros1:
extends:
- .publish
- .on_ros1_merge_tag
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
needs:
- build_${APP_NAME}_ros1
parallel:
matrix:
- ROS_DISTRO:
- noetic
publish_${APP_NAME}_ros2:
extends:
- .publish
- .on_ros2_merge_tag
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
needs:
- build_${APP_NAME}_ros2
parallel:
matrix:
- ROS_DISTRO:
- foxy
# - galactic
- humble
- rolling
.deploy_app:
stage: deploy_app
tags: *kaniko_runner
image:
name: debian:bookworm
before_script:
- apt-get update
- apt-get install --yes squashfs-tools rpm
- TARGET=${NAME}:${CI_COMMIT_REF_NAME//\//-}
- !reference [.common, create_release_tag_script]
script:
- tar -tf ${DOCKER_IMAGE_PATH}/${TARGET//:/-}.tar --wildcards 'sha256*' >> ./image.id
- sed -i 's/[^:]*:\(.*\)/\1/' image.id
- mkdir $APP_PATH
- cp ${DOCKER_IMAGE_PATH}/${TARGET//:/-}.tar $APP_PATH/$APP_NAME.tar
- sed -i "s/§§IMAGE_ID§§/$(<image.id)/g" ./app/compose.yml
- sed -i "s/§§IMAGE_ID§§/$(<image.id)/g" ./app/initscript.sh
- sed -i "s/§§TARGETS§§/${TARGET_DEVICES}/g" ./app/app_info.json
- sed -i "s/§§ROS_BRIDGE_VERSION§§/${ROS_BRIDGE_VERSION}/g" ./app/app_info.json
- sed -i "s/§§ROS_DISTRO§§/${ROS_DISTRO}/g" ./app/app_info.json
- chmod +x app/initscript.sh
- mksquashfs app $APP_NAME.app -force-uid 1001 -force-gid 1002
needs:
- build
artifacts:
name: "${CI_PROJECT_PATH_SLUG}-${APP_NAME}-${CI_COMMIT_SHORT_SHA}"
paths:
- ${CI_PROJECT_DIR}/*.app
when: on_success
expire_in: 1 day
deploy_app:${APP_NAME}:ros1:
extends:
- .deploy_app
- .on_ros1_merge_tag
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
needs:
- publish_${APP_NAME}_ros1
parallel:
matrix:
- ROS_DISTRO:
- noetic
deploy_app:${APP_NAME}:ros2:
extends:
- .deploy_app
- .on_ros2_merge_tag
variables:
NAME: ${APP_NAME}_${ROS_DISTRO}
needs:
- publish_${APP_NAME}_ros2
parallel:
matrix:
- ROS_DISTRO:
- foxy
# - galactic
- humble
- rolling
doxygen-job:
stage: doc
tags: *kaniko_runner
image: ubuntu:latest
before_script:
- apt-get update -qq
- apt-get install -y -qq doxygen graphviz
script:
- doxygen Doxyfile
- mv doc/html/ public/
artifacts:
paths:
- public
when: always
stages:
- build
- publish
- deploy_app
- doc