From 6e9722364d5421530f0df0bcacccf3f126ccf3e8 Mon Sep 17 00:00:00 2001 From: Kieran Matheson Date: Tue, 25 Feb 2025 10:00:08 +0000 Subject: [PATCH] fix: fix image building and release process in ci --- .gitlab-ci.yml | 36 +++++++++++++++++++++++++++--------- .pre-commit-config.yaml | 2 +- .releaserc.yaml | 9 ++++----- README.md | 4 ++-- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0f4d09..f2dcd07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,7 @@ include: inputs: tag: $CI_COMMIT_SHA -build-and-push-docker-image: - stage: .pre +.build-config: image: docker:24.0.2 services: - name: docker:24.0.2-dind @@ -15,13 +14,24 @@ build-and-push-docker-image: DOCKER_TLS_VERIFY: "true" DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" HEALTHCHECK_TCP_PORT: "2376" - script: + before_script: - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - - echo "CI_REGISTRY_IMAGE - $CI_REGISTRY_IMAGE" - - echo "CI_COMMIT_SHA - $CI_COMMIT_SHA" - - echo "Building and pushing image." - - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -f templates/Dockerfile . - - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + +.build-and-publish: + extends: .build-config + script: + - echo "Building Docker image..." + - docker build -t $CI_REGISTRY_IMAGE:$TAG -f templates/Dockerfile . + - echo "Pushing Image $CI_REGISTRY_IMAGE:$TAG" + - docker push $CI_REGISTRY_IMAGE:$TAG + +build-and-publish-image-sha: + extends: .build-and-publish + stage: build + variables: + TAG: "$CI_COMMIT_SHA" + rules: + - if: $CI_MERGE_REQUEST_DIFF_BASE_SHA lint: extends: .pre-commit @@ -45,4 +55,12 @@ semantic-release: rules: - if: $CI_COMMIT_TAG when: never - - if: $CI_COMMIT_REF_PROTECTED == "true" \ No newline at end of file + - if: $CI_COMMIT_REF_PROTECTED == "true" + +build-and-publish-image-version: + extends: .build-and-publish + stage: deploy + variables: + TAG: "$CI_COMMIT_TAG" + rules: + - if: $CI_COMMIT_TAG diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c81071..79eb6e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ default_install_hook_types: - pre-commit repos: - repo: https://gitlab.gpu.arm.com/pre-commit/hooks - rev: v2.9.1 + rev: v2.10.0 hooks: - id: check-added-large-files - id: check-filename-case-conflict diff --git a/.releaserc.yaml b/.releaserc.yaml index dfb6ad5..50c4dc3 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -1,11 +1,10 @@ -branches: - - main - - alpha - - beta - - stable +extends: + - "@semantic-release/config-release-channels" plugins: - "@semantic-release/commit-analyzer" - "@semantic-release/release-notes-generator" - "@semantic-release/changelog" + - path: "@semantic-release/exec" + prepareCmd: "npx prettier -w CHANGELOG.md" - "@semantic-release/gitlab" diff --git a/README.md b/README.md index 1d2d3ec..3656cd8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Include the following in `.gitlab-ci.yml`: ```yaml include: - - component: gitlab.arm.com/ci/component/pre-commit@" + - component: gitlab.arm.com/ci/component/pre-commit/pre-commit@" pre-commit: extends: .pre-commit @@ -30,7 +30,7 @@ The image can be overridden with the [image][image] keyword in the `.gitlab-ci.y ```yaml include: - - component: "gitlab.arm.com/ci/component/pre-commit@" + - component: "gitlab.arm.com/ci/component/pre-commit/pre-commit@" inputs: image: registry.gitlab.arm.com/ci/component/pre-commit -- GitLab