Skip to content
Snippets Groups Projects
Commit 7f58e408 authored by mptr's avatar mptr Committed by Timo Furrer
Browse files

ci: refactor image publishing

parent 71b898eb
No related branches found
No related tags found
No related merge requests found
...@@ -175,77 +175,45 @@ shellcheck: ...@@ -175,77 +175,45 @@ shellcheck:
# - if: $CI_COMMIT_TAG # - if: $CI_COMMIT_TAG
# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
gitlab-opentofu-image:deploy:with-opentofu-version: gitlab-opentofu-image:deploy:
extends: .opentofu-versions
stage: deploy stage: deploy
image: image:
name: gcr.io/go-containerregistry/crane:debug name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""] entrypoint: [""]
variables: before_script:
RELEASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/gitlab-opentofu" - crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
# OCI image tags are not compatible with semver, specifically the build metadata part # OCI image tags are not compatible with semver, specifically the build metadata part
# indicated with a `+` sign, see https://github.com/distribution/distribution/issues/1201 # indicated with a `+` sign, see https://github.com/distribution/distribution/issues/1201
# We use a dash `-` here, instead of the `+`. # We use a dash `-` here, instead of the `+`.
# This may be problematic, because it indicates a semver prerelease. # This may be problematic, because it indicates a semver prerelease.
RELEASE_SEMVER: "${CI_COMMIT_TAG}-opentofu${OPENTOFU_VERSION}" - export RELEASE_IMAGE_NAME="$CI_REGISTRY_IMAGE/gitlab-opentofu"
RELEASE_IMAGE: "$RELEASE_IMAGE_NAME:$RELEASE_SEMVER" - export RELEASE_IMAGE="${RELEASE_IMAGE_NAME}:${RELEASE_VERSION}${RELEASE_OPENTOFU_VERSION:+-opentofu$RELEASE_OPENTOFU_VERSION}"
before_script: - echo "Deploying $GITLAB_OPENTOFU_IMAGE_NAME as $RELEASE_IMAGE"
- crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE" - crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE"
- 'echo "- \`$RELEASE_IMAGE\` (digest: \`$(crane digest $RELEASE_IMAGE)\`)" > image$CI_JOB_ID.md' - 'echo "- \`$RELEASE_IMAGE\` (digest: \`$(crane digest $RELEASE_IMAGE)\`)" > image$CI_JOB_ID.md'
artifacts: artifacts:
paths: paths:
- 'image*.md' - 'image*.md'
rules:
- if: $CI_COMMIT_TAG
gitlab-opentofu-image:deploy:latest-with-opentofu-version:
extends: .opentofu-versions
stage: deploy
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
variables:
RELEASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/gitlab-opentofu"
RELEASE_SEMVER: "latest-opentofu${OPENTOFU_VERSION}"
RELEASE_IMAGE: "$RELEASE_IMAGE_NAME:$RELEASE_SEMVER"
before_script:
- crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE"
- 'echo "- \`$RELEASE_IMAGE\` (digest: \`$(crane digest $RELEASE_IMAGE)\`)" > image$CI_JOB_ID.md'
artifacts:
paths:
- 'image*.md'
rules:
- if: $CI_COMMIT_TAG
gitlab-opentofu-image:deploy:latest:
stage: deploy
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
variables:
OPENTOFU_VERSION: $LATEST_OPENTOFU_VERSION
RELEASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/gitlab-opentofu"
RELEASE_IMAGE: "$RELEASE_IMAGE_NAME:$RELEASE_IMAGE_TAG"
before_script:
- crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE"
- 'echo "- \`$RELEASE_IMAGE\` (digest: \`$(crane digest $RELEASE_IMAGE)\`)" > image$CI_JOB_ID.md'
artifacts:
paths:
- 'image*.md'
rules:
- if: $CI_COMMIT_TAG
parallel: parallel:
# OPENTOFU_VERSION: opentofu version to release in the job (from gitlab-opentofu-image:build)
# RELEASE_VERSION: Tag base for the release image
# RELEASE_OPENTOFU_VERSION: opentofu version to contained in the release tag
matrix: matrix:
- RELEASE_IMAGE_TAG: ${CI_COMMIT_TAG} - # :{commit-tag}-opentofu{opentofu-version}
- RELEASE_IMAGE_TAG: ${CI_COMMIT_TAG}-opentofulatest OPENTOFU_VERSION: !reference [.data, supported_versions]
- RELEASE_IMAGE_TAG: latest-opentofulatest RELEASE_VERSION: $CI_COMMIT_TAG
- RELEASE_IMAGE_TAG: latest RELEASE_OPENTOFU_VERSION: $OPENTOFU_VERSION
- # :latest-opentofu{opentofu-version}
OPENTOFU_VERSION: !reference [.data, supported_versions]
RELEASE_VERSION: latest
RELEASE_OPENTOFU_VERSION: $OPENTOFU_VERSION
- # :{commit-tag|latest}{-opentofulatest|}
OPENTOFU_VERSION: $LATEST_OPENTOFU_VERSION
RELEASE_VERSION: ["${CI_COMMIT_TAG}", latest]
RELEASE_OPENTOFU_VERSION: ["", latest]
rules:
- if: $CI_COMMIT_TAG
# If the pipeline is for a new tag with a semantic version, and all previous jobs succeed, # If the pipeline is for a new tag with a semantic version, and all previous jobs succeed,
# create the release. # create the release.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment