Simplified .gitlab-ci.yml

This commit is contained in:
Héctor Molinero Fernández 2022-02-08 23:15:29 +01:00
parent c3184e7aee
commit d1e8f99a06

View File

@ -1,7 +1,6 @@
stages: stages:
- 'build:images' - 'build'
- 'push:images' - 'push'
- 'push:manifests'


variables: variables:
DOCKER_HOST: 'tcp://dockerd:2376' DOCKER_HOST: 'tcp://dockerd:2376'
@ -15,19 +14,17 @@ default:
- name: 'docker.io/docker:dind' - name: 'docker.io/docker:dind'
alias: 'dockerd' alias: 'dockerd'


.cmds: .anchors:
- &cmd_install_build_packages 'apk add --no-cache coreutils git m4 make zstd' - &cmd_install_packages 'apk add --no-cache coreutils git m4 make zstd'
- &cmd_install_push_packages 'apk add --no-cache coreutils git make zstd' - &cmd_docker_login_registry 'docker login -u "${CI_REGISTRY_USER:?}" -p "${CI_REGISTRY_PASSWORD:?}" "${CI_REGISTRY:?}"'
- &cmd_docker_login_registry 'docker login -u "${CI_REGISTRY_USER:?}" -p "${CI_REGISTRY_PASSWORD:?}" "${CI_REGISTRY:?}"' - &matrix_arch ['amd64', 'arm64v8', 'arm32v7']

.regexes:
- &regex_version '/^v[0-9]+$/' - &regex_version '/^v[0-9]+$/'


build:images:native: build:native:
stage: 'build:images' stage: 'build'
except: [*regex_version] except: [*regex_version]
before_script: before_script:
- *cmd_install_build_packages - *cmd_install_packages
script: script:
- 'make IMAGE_BUILD_OPTS="--pull" build-native-image save-native-image' - 'make IMAGE_BUILD_OPTS="--pull" build-native-image save-native-image'
artifacts: artifacts:
@ -35,11 +32,14 @@ build:images:native:
paths: paths:
- './dist/' - './dist/'


.build:images:cross: build:cross:
stage: 'build:images' stage: 'build'
only: [*regex_version] only: [*regex_version]
parallel:
matrix:
- ARCH: *matrix_arch
before_script: before_script:
- *cmd_install_build_packages - *cmd_install_packages
script: script:
- 'make binfmt-register' - 'make binfmt-register'
- 'make IMAGE_BUILD_OPTS="--pull" "build-${ARCH:?}-image" "save-${ARCH:?}-image"' - 'make IMAGE_BUILD_OPTS="--pull" "build-${ARCH:?}-image" "save-${ARCH:?}-image"'
@ -48,50 +48,27 @@ build:images:native:
paths: paths:
- './dist/' - './dist/'


build:images:amd64: push:cross:
extends: '.build:images:cross' stage: 'push'
variables: {ARCH: 'amd64'} needs: ['build:cross']

build:images:arm64v8:
extends: '.build:images:cross'
variables: {ARCH: 'arm64v8'}

build:images:arm32v7:
extends: '.build:images:cross'
variables: {ARCH: 'arm32v7'}

.push:images:cross:
stage: 'push:images'
only: [*regex_version] only: [*regex_version]
parallel:
matrix:
- ARCH: *matrix_arch
before_script: before_script:
- *cmd_install_push_packages - *cmd_install_packages
- *cmd_docker_login_registry - *cmd_docker_login_registry
script: script:
- 'make "load-${ARCH:?}-image" "push-${ARCH:?}-image"' - 'make "load-${ARCH:?}-image" "push-${ARCH:?}-image"'


push:images:amd64: push:manifest:
extends: '.push:images:cross' stage: 'push'
dependencies: ['build:images:amd64'] needs: ['push:cross']
variables: {ARCH: 'amd64'}

push:images:arm64v8:
extends: '.push:images:cross'
dependencies: ['build:images:arm64v8']
variables: {ARCH: 'arm64v8'}

push:images:arm32v7:
extends: '.push:images:cross'
dependencies: ['build:images:arm32v7']
variables: {ARCH: 'arm32v7'}

push:manifests:cross:
stage: 'push:manifests'
dependencies: ['push:images:amd64', 'push:images:arm64v8', 'push:images:arm32v7']
only: [*regex_version] only: [*regex_version]
variables: variables:
DOCKER_CLI_EXPERIMENTAL: 'enabled' DOCKER_CLI_EXPERIMENTAL: 'enabled'
before_script: before_script:
- *cmd_install_push_packages - *cmd_install_packages
- *cmd_docker_login_registry - *cmd_docker_login_registry
script: script:
- 'make push-cross-manifest' - 'make push-cross-manifest'