Skip to content

Commit ae0e00f

Browse files
committed
feat(ci): Build RPM bundles and improve CI pipeline
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
1 parent ed85337 commit ae0e00f

File tree

1 file changed

+92
-34
lines changed

1 file changed

+92
-34
lines changed

.gitlab-ci.yml

Lines changed: 92 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ variables:
1212
DOCKER_CLI_EXPERIMENTAL: enabled
1313
CMAKE_BUILD_OPTS: "--parallel 16"
1414
CMAKE_EXTRA_OPTS: "-DCMAKE_BUILD_TYPE=Release -DVILLAS_COMPILE_WARNING_AS_ERROR=ON"
15+
CACHIX_CACHE_NAME: villas
1516

1617
stages:
1718
- prepare
@@ -21,9 +22,41 @@ stages:
2122
- deploy
2223
- latest
2324

25+
# Anchors
26+
27+
.nix: &nix
28+
image: docker.nix-community.org/nixpkgs/cachix-flakes
29+
30+
parallel:
31+
matrix:
32+
- SYSTEM: [x86_64-linux, aarch64-linux]
33+
34+
before_script:
35+
- cachix use "$CACHIX_CACHE_NAME"
36+
37+
.nix_packaging: &nix_packaging
38+
<<: *nix
39+
40+
stage: packaging
41+
needs:
42+
- job: build:nix
43+
parallel:
44+
matrix:
45+
- SYSTEM: [x86_64-linux, aarch64-linux]
46+
47+
.nix_packaging_artifacts: &nix_packaging_artifacts
48+
<<: *nix_packaging
49+
50+
artifacts:
51+
when: on_success
52+
access: all
53+
expire_in: "1 year"
54+
paths:
55+
- artifacts/*
56+
2457
# Stage: prepare
2558

26-
# Build docker image which is used to build & test VILLASnode
59+
# Build Docker image which is used to build & test VILLASnode
2760
prepare:docker:
2861
stage: prepare
2962
before_script:
@@ -88,42 +121,16 @@ build:source:
88121
-DCMAKE_PREFIX_PATH=/usr/local
89122

90123
build:nix:
124+
<<: *nix
125+
91126
stage: build
92-
image: docker.nix-community.org/nixpkgs/cachix-flakes
93127
needs: []
94-
variables:
95-
CACHIX_CACHE_NAME: villas
96-
97-
parallel:
98-
matrix:
99-
- SYSTEM: [x86_64-linux, aarch64-linux]
100-
101-
artifacts:
102-
when: on_success
103-
access: all
104-
expire_in: "1 year"
105-
paths:
106-
- artifacts/*
107-
108-
before_script:
109-
- cachix use "$CACHIX_CACHE_NAME"
110-
111-
- | # Create directories
112-
mkdir -p artifacts /var/tmp/
113-
114-
- | # Login at Docker registry
115-
nix run nixpkgs#skopeo -- login \
116-
--username ${CI_REGISTRY_USER} \
117-
--password ${CI_REGISTRY_PASSWORD} \
118-
${CI_REGISTRY}
119128

120129
script:
121-
- cachix watch-exec $CACHIX_CACHE_NAME -- nix build --print-build-logs ".#villas-node-${SYSTEM}"
122-
- cachix watch-exec $CACHIX_CACHE_NAME -- nix bundle --print-build-logs --out-link bundle ".#villas-node-${SYSTEM}"
123-
- cachix watch-exec $CACHIX_CACHE_NAME -- nix build --print-build-logs --out-link docker ".#dockerImage-${SYSTEM}"
124-
125-
- cp -L bundle artifacts/villas-${SYSTEM}
126-
- nix run nixpkgs#skopeo -- --tmpdir=${TMPDIR} --insecure-policy copy "docker-archive:./docker" "docker://${DOCKER_IMAGE}:${DOCKER_TAG}-nix-${SYSTEM}"
130+
- cachix watch-exec $CACHIX_CACHE_NAME --
131+
nix build
132+
--print-build-logs
133+
".#villas-node-${SYSTEM}"
127134

128135
# Stage: test
129136

@@ -207,6 +214,7 @@ test:reuse:
207214

208215
pkg:docker:
209216
stage: packaging
217+
needs: []
210218
before_script:
211219
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
212220
script:
@@ -236,7 +244,57 @@ pkg:docker:
236244
ARCH: arm64
237245
TRIPLET: aarch64-linux-gnu
238246
TAG: pi5
239-
needs: []
247+
248+
pkg:nix:arx:
249+
<<: *nix_packaging_artifacts
250+
251+
script:
252+
- cachix watch-exec $CACHIX_CACHE_NAME --
253+
nix bundle
254+
--print-build-logs
255+
--out-link bundle-arx
256+
--bundler github:NixOS/bundlers#toArx
257+
".#villas-node-${SYSTEM}"
258+
259+
- mkdir -p artifacts
260+
- cp -L bundle-arx artifacts/villas-${SYSTEM}
261+
262+
pkg:nix:rpm:
263+
<<: *nix_packaging_artifacts
264+
265+
script:
266+
- cachix watch-exec $CACHIX_CACHE_NAME --
267+
nix bundle
268+
--print-build-logs
269+
--out-link bundle-rpm
270+
--bundler github:NixOS/bundlers#toRPM
271+
".#villas-node-${SYSTEM}"
272+
273+
- mkdir -p artifacts
274+
- cp -L bundle-rpm/*.rpm artifacts/villas-${SYSTEM}.rpm
275+
276+
pkg:nix:docker:
277+
<<: *nix_packaging
278+
279+
script:
280+
- mkdir -p /var/tmp/
281+
- cachix watch-exec $CACHIX_CACHE_NAME --
282+
nix bundle
283+
--print-build-logs
284+
--out-link bundle-docker
285+
--bundler github:NixOS/bundlers#toDockerImage
286+
".#dockerImage-${SYSTEM}"
287+
288+
- nix run nixpkgs#skopeo --
289+
login
290+
--username ${CI_REGISTRY_USER}
291+
--password ${CI_REGISTRY_PASSWORD}
292+
${CI_REGISTRY}
293+
294+
- nix run nixpkgs#skopeo --
295+
--tmpdir=${TMPDIR}
296+
--insecure-policy
297+
copy "docker-archive:./bundle-docker" "docker://${DOCKER_IMAGE}:${DOCKER_TAG}-nix-${SYSTEM}"
240298

241299
# Stage: deploy
242300

0 commit comments

Comments
 (0)