-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
58 lines (55 loc) · 1.72 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
stages:
- prepare
- build
- publish
prepare:
image: ${LINBIT_DOCKER_REGISTRY}/build-helpers:latest
stage: prepare
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_TAG
variables:
# git describe needs full history access
GIT_DEPTH: 0
# git describe does not need the submodule
GIT_SUBMODULE_STRATEGY: none
script:
- SEMVER="$(semver-from-git.py)"
- echo "SEMVER=${SEMVER}" >> .ci-build.env
- echo "TAG=v${SEMVER/+/-}" >> .ci-build.env
- echo "IMAGE=${LINBIT_DOCKER_REGISTRY}/drbd-shutdown-guard:v${SEMVER/+/-}" >> .ci-build.env
artifacts:
reports:
dotenv: .ci-build.env
build:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_DEPTH: 1
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_TAG
tags:
- multiarch
script:
# Use NOCACHE=true for release builds
- if [ -n "${CI_COMMIT_TAG}" ]; then NOCACHE=true ; else NOCACHE=false ; fi
- ln -snf $DOCKER_AUTH_CONFIG_FILE $HOME/.docker/config.json
- docker buildx build --pull --push --platform ${PUBLISH_PLATFORMS} -t ${IMAGE} --build-arg=VERSION=${SEMVER} --no-cache="${NOCACHE}" .
publish:
stage: publish
rules:
- if: $CI_COMMIT_TAG
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
script:
- mkdir -p $HOME/.docker
- ln -snf $DOCKER_PUBLISH_AUTH_CONFIG_FILE $HOME/.docker/config.json
- for PLATFORM in $(echo $PUBLISH_PLATFORMS | tr ',' '\n') ; do
- ARCH=${PLATFORM#*/}
- crane copy --platform $PLATFORM $IMAGE $PUBLISH_REGISTRY/$ARCH/drbd-shutdown-guard:$TAG
- crane tag $PUBLISH_REGISTRY/$ARCH/drbd-shutdown-guard:$TAG latest
- done