diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ff19245af9252aaa90ddfbe4236465b703c5754..2bc6fe930fbff965f06daae6103dc4b025123bd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -105,10 +105,15 @@ gitlab-opentofu-image:deploy:with-opentofu-version: # We use a dash `-` here, instead of the `+`. # This may be problematic, because it indicates a semver prerelease. RELEASE_SEMVER: "${CI_COMMIT_TAG}-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_NAME:$RELEASE_SEMVER" + - crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE" + - echo "- $RELEASE_IMAGE" > image$CI_JOB_ID.txt + artifacts: + paths: + - 'image*.txt' rules: - if: $CI_COMMIT_TAG @@ -121,10 +126,15 @@ gitlab-opentofu-image:deploy:latest-with-opentofu-version: 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_NAME:$RELEASE_SEMVER" + - crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE" + - echo "- $RELEASE_IMAGE" > image$CI_JOB_ID.txt + artifacts: + paths: + - 'image*.txt' rules: - if: $CI_COMMIT_TAG @@ -136,10 +146,15 @@ gitlab-opentofu-image:deploy:latest: 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_NAME:$RELEASE_IMAGE_TAG" + - crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE" + - echo "- $RELEASE_IMAGE" > image$CI_JOB_ID.txt + artifacts: + paths: + - 'image*.txt' rules: - if: $CI_COMMIT_TAG parallel: @@ -151,18 +166,31 @@ gitlab-opentofu-image:deploy:latest: # If the pipeline is for a new tag with a semantic version, and all previous jobs succeed, # create the release. -create-release: +.create-release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest - rules: - - if: $CI_COMMIT_TAG =~ /\d+/ before_script: - apk add --update yq envsubst script: - echo "Creating release $CI_COMMIT_TAG" - AVAILABLE_OPENTOFU_VERSIONS=$(yq -r '.spec.inputs.opentofu_version.options | filter((. | test("\$.*")) == false) | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' templates/full-pipeline.yml) - export AVAILABLE_OPENTOFU_VERSIONS + - AVAILABLE_IMAGES=$(cat image*.txt) - cat .gitlab/release-template.md | envsubst > release-notes.md + +create-release:dry-run: + extends: .create-release + script: + - !reference [.create-release, script] + - cat release-notes.md + artifacts: + paths: + - release-notes.md + +create-release: + extends: .create-release + rules: + - if: $CI_COMMIT_TAG =~ /\d+/ release: tag_name: $CI_COMMIT_TAG description: './release-notes.md' diff --git a/.gitlab/release-template.md b/.gitlab/release-template.md index df8c42f767cb4a00f5bff419d6f68c830969bb1c..46b78675febce17905e1ca1844ad2eda10cb2818 100644 --- a/.gitlab/release-template.md +++ b/.gitlab/release-template.md @@ -24,3 +24,9 @@ See the [README.md](README.md) for more usage examples. This release is available with the following OpenTofu versions: $AVAILABLE_OPENTOFU_VERSIONS + +## Available GitLab OpenTofu images + +This release deployed the following `gitlab-opentofu` images: + +$AVAILABE_IMAGES