Loading .gitlab-ci.yml +17 −6 Original line number Diff line number Diff line Loading @@ -2,10 +2,20 @@ variables: VERSION: value: 2.20.0 description: Pre-Commit version PYTHON_VERSION: value: "3.11" description: Python version in the image TARGET_PLATFORMS: value: linux/amd64,linux/arm64 description: Comma separated list of platforms to build images for workflow: rules: - if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]/ variables: DO_RELEASE: "true" - when: always include: component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/pre-commit@$CI_COMMIT_SHA Loading @@ -21,7 +31,8 @@ Build: --output=type=image,name=$CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID,push=true --opt platform=$TARGET_PLATFORMS --opt label:commit=$CI_COMMIT_SHA ${VERSION:+--opt build-arg:VERSION=$VERSION} --opt build-arg:PYTHON_VERSION="$PYTHON_VERSION" --opt build-arg:VERSION="$VERSION" Tag Commit: stage: deploy Loading @@ -34,10 +45,10 @@ Tag Release: stage: deploy image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 rules: - if: $CI_COMMIT_TAG =~ /^v[0-9]/ - if: $DO_RELEASE script: - docker-reg $CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID retag $CI_REGISTRY_IMAGE:${VERSION}-py311 retag "$CI_REGISTRY_IMAGE:${VERSION}-py${PYTHON_VERSION}" - docker-reg $CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID retag $CI_REGISTRY_IMAGE:latest Loading @@ -57,8 +68,8 @@ Create Release: stage: deploy image: registry.gitlab.com/gitlab-org/release-cli:latest rules: - if: $CI_COMMIT_TAG =~ /^v[0-9]/ script: echo "Creating release $CI_COMMIT_TAG" - if: $DO_RELEASE script: echo "Creating release ${CI_COMMIT_TAG}" release: tag_name: $CI_COMMIT_TAG description: "Release ${CI_COMMIT_TAG#v} of components repository $CI_PROJECT_PATH" description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH" Dockerfile +2 −1 Original line number Diff line number Diff line # syntax = docker/dockerfile:1.0-experimental FROM python:3.11-slim ARG PYTHON_VERSION=3.11 FROM python:${PYTHON_VERSION}-slim ARG VERSION RUN pip install pre-commit${VERSION+==$VERSION} Loading Loading
.gitlab-ci.yml +17 −6 Original line number Diff line number Diff line Loading @@ -2,10 +2,20 @@ variables: VERSION: value: 2.20.0 description: Pre-Commit version PYTHON_VERSION: value: "3.11" description: Python version in the image TARGET_PLATFORMS: value: linux/amd64,linux/arm64 description: Comma separated list of platforms to build images for workflow: rules: - if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]/ variables: DO_RELEASE: "true" - when: always include: component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/pre-commit@$CI_COMMIT_SHA Loading @@ -21,7 +31,8 @@ Build: --output=type=image,name=$CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID,push=true --opt platform=$TARGET_PLATFORMS --opt label:commit=$CI_COMMIT_SHA ${VERSION:+--opt build-arg:VERSION=$VERSION} --opt build-arg:PYTHON_VERSION="$PYTHON_VERSION" --opt build-arg:VERSION="$VERSION" Tag Commit: stage: deploy Loading @@ -34,10 +45,10 @@ Tag Release: stage: deploy image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 rules: - if: $CI_COMMIT_TAG =~ /^v[0-9]/ - if: $DO_RELEASE script: - docker-reg $CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID retag $CI_REGISTRY_IMAGE:${VERSION}-py311 retag "$CI_REGISTRY_IMAGE:${VERSION}-py${PYTHON_VERSION}" - docker-reg $CI_REGISTRY_IMAGE/build:pipeline-$CI_PIPELINE_IID retag $CI_REGISTRY_IMAGE:latest Loading @@ -57,8 +68,8 @@ Create Release: stage: deploy image: registry.gitlab.com/gitlab-org/release-cli:latest rules: - if: $CI_COMMIT_TAG =~ /^v[0-9]/ script: echo "Creating release $CI_COMMIT_TAG" - if: $DO_RELEASE script: echo "Creating release ${CI_COMMIT_TAG}" release: tag_name: $CI_COMMIT_TAG description: "Release ${CI_COMMIT_TAG#v} of components repository $CI_PROJECT_PATH" description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH"
Dockerfile +2 −1 Original line number Diff line number Diff line # syntax = docker/dockerfile:1.0-experimental FROM python:3.11-slim ARG PYTHON_VERSION=3.11 FROM python:${PYTHON_VERSION}-slim ARG VERSION RUN pip install pre-commit${VERSION+==$VERSION} Loading