Skip to content

Commit

Permalink
Add container-publish for GitLab CI/CD.
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Jan 31, 2024
1 parent b146c28 commit 1ddc054
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .gitlab/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,54 @@ release-publish:
script:
- echo "Running the release job."
stage: release
container-publish:
image: docker:latest
needs:
- release-publish
parallel:
matrix:
- PYTHON_VERSION:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker context create builder
- docker buildx create builder --name container --driver docker-container --use
- docker buildx inspect --bootstrap --builder container
- |
docker buildx build . \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-from type=registry,ref=${CI_REGISTRY_IMAGE}:build-cache-dev-py${PYTHON_VERSION} \
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}:build-cache-dev-py${PYTHON_VERSION},mode=max \
--file .devcontainer/Dockerfile \
--provenance false \
--push \
--tag ${CI_REGISTRY_IMAGE}:dev-py${PYTHON_VERSION} \
--tag ${CI_REGISTRY_IMAGE}:dev-py${PYTHON_VERSION}-${CI_COMMIT_TAG} \
--target dev
- |
docker buildx build . \
--build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--cache-from type=registry,ref=${CI_REGISTRY_IMAGE}:build-cache-dev-py${PYTHON_VERSION} \
--file .devcontainer/Dockerfile \
--provenance false \
--push \
--tag ${CI_REGISTRY_IMAGE}:prod-py${PYTHON_VERSION} \
--tag ${CI_REGISTRY_IMAGE}:prod-py${PYTHON_VERSION}-${CI_COMMIT_TAG} \
--target prod
services:
- docker:dind
stage: release
variables:
DOCKER_TLS_CERTDIR: /certs
PYTHON_VERSION: ${PYTHON_VERSION}
SOURCE_DATE_EPOCH: 0
package-publish:
needs:
- release-publish
Expand Down

0 comments on commit 1ddc054

Please sign in to comment.