Skip to content
Snippets Groups Projects
Commit 9b69280a authored by Timo Furrer's avatar Timo Furrer
Browse files

Change default for `version` input to match component version

This change set is a workaround for
https://gitlab.com/gitlab-org/gitlab/-/issues/438275.
It implements an additional release step that "hard codes" the component
version to release in the component templates. This is ugly, but hides
complexity from the component user.

This change set maybe a breaking change to component users that rely on
the default being `latest`. For example, a config like:

    include:
      - component: $CI_SERVER_FQDN/components/opentofu/full-pipeline@~latest
        inputs:
          opentofu_version: <OPENTOFU_VERSION>

would break, because the component `version` value is no longer
`latest`, but no refers to the actual version from of `~latest`.
Since, using `~latest` is "discouraged" anyways, we'll still introduce
this breaking change. Users of `~latest` should just specify `version:
latest` in their `inputs`.

Changelog: changed
parent 7dfe099b
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,6 @@ together with an OpenTofu version.
include:
- component: $CI_SERVER_FQDN/components/opentofu/full-pipeline@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [validate, test, build, deploy, cleanup]
......@@ -43,10 +39,6 @@ stages: [validate, test, build, deploy, cleanup]
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [validate, build, deploy]
......@@ -55,10 +47,6 @@ stages: [validate, build, deploy]
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
trigger_in_child_pipeline: true
```
......@@ -70,10 +58,6 @@ A concrete example may look like this:
include:
- component: $CI_SERVER_FQDN/components/opentofu/full-pipeline@0.10.0
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: 0.10.0 # component version
opentofu_version: 1.6.1
stages: [validate, test, build, deploy, cleanup]
......@@ -100,10 +84,6 @@ Or import all jobs as hidden templates ready to be extended:
include:
- component: $CI_SERVER_FQDN/components/opentofu/job-templates@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [...]
......@@ -188,10 +168,6 @@ The following snippet will auto-encrypt your state with a passphrase coming from
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
auto_encryption: true
auto_encryption_passphrase: $PASSPHRASE
......@@ -220,10 +196,6 @@ An example setup may look like this:
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
enable_id_tokens: true
......@@ -298,10 +270,6 @@ and compose your own pipeline, for example, to just run the `fmt` job you can do
include:
- component: $CI_SERVER_FQDN/components/opentofu/fmt@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION>
opentofu_version: 1.6.1
root_dir: tofu/
```
......@@ -315,10 +283,6 @@ you want to extend the jobs:
include:
- component: $CI_SERVER_FQDN/components/opentofu/job-templates@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION>
opentofu_version: 1.6.1
plan:
......
......@@ -19,10 +19,6 @@ You can use the OpenTofu CI/CD component from the CI/CD catalog using:
include:
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/full-pipeline@$CI_COMMIT_TAG
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: $CI_COMMIT_TAG # component version
opentofu_version: $LATEST_OPENTOFU_VERSION
stages: [validate, test, build, deploy, cleanup]
......
......@@ -26,6 +26,13 @@ echo "${version}" | "${script_dir}/check-semantic-version.sh"
echo "Starting release process for ${version} ..."
echo "Updating default value for version input to match ${version} ..."
"${script_dir}/update-self-version.sh" "${version}"
git commit templates/*.yml -m "Update version input default for ${version} release"
git push origin main
echo "Determing last stable version ..."
last_stable_version_sha="$(git tag | grep -E '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$' | sort --version-sort --reverse | head -n1 | xargs git rev-list -n1)"
echo "Using commit '${last_stable_version_sha}' to start the changelog from ..."
......
#!/usr/bin/env sh
set -e
script_dir="$(dirname "$0")"
project_dir="$script_dir/../.."
VERSION="$1"
if [ -z "$VERSION" ]; then
echo "Error: version must be passed as first argument" >&2
exit 1
fi
echo "Updating template files ..."
templates="templates/*.yml"
templates_exclude="templates/delete-state.yml templates/module-release.yml templates/__internal_id_tokens_base_job.yml"
for relative_template_file in $templates; do
if echo "$templates_exclude" | grep -q "$relative_template_file"; then continue; fi
template_file="$project_dir/$relative_template_file"
tmp_template_file=$(mktemp)
echo "Updating $template_file ... "
yq eval-all '
select(document_index == 0).spec.inputs.version.default
= "'"$VERSION"'"
' "$template_file" > "$tmp_template_file"
diff -Bw "$template_file" "$tmp_template_file" | patch "$template_file" -
done
......@@ -31,10 +31,6 @@ together with an OpenTofu version.
include:
- component: $CI_SERVER_FQDN/components/opentofu/full-pipeline@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [validate, test, build, deploy, cleanup]
......@@ -45,10 +41,6 @@ stages: [validate, test, build, deploy, cleanup]
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [validate, build, deploy]
......@@ -57,10 +49,6 @@ stages: [validate, build, deploy]
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
trigger_in_child_pipeline: true
```
......@@ -72,10 +60,6 @@ A concrete example may look like this:
include:
- component: $CI_SERVER_FQDN/components/opentofu/full-pipeline@0.10.0
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: 0.10.0 # component version
opentofu_version: 1.6.1
stages: [validate, test, build, deploy, cleanup]
......@@ -102,10 +86,6 @@ Or import all jobs as hidden templates ready to be extended:
include:
- component: $CI_SERVER_FQDN/components/opentofu/job-templates@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
stages: [...]
......@@ -190,10 +170,6 @@ The following snippet will auto-encrypt your state with a passphrase coming from
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
auto_encryption: true
auto_encryption_passphrase: $PASSPHRASE
......@@ -222,10 +198,6 @@ An example setup may look like this:
include:
- component: $CI_SERVER_FQDN/components/opentofu/validate-plan-apply@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION> # component version
opentofu_version: <OPENTOFU_VERSION>
enable_id_tokens: true
......@@ -300,10 +272,6 @@ and compose your own pipeline, for example, to just run the `fmt` job you can do
include:
- component: $CI_SERVER_FQDN/components/opentofu/fmt@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION>
opentofu_version: 1.6.1
root_dir: tofu/
```
......@@ -317,10 +285,6 @@ you want to extend the jobs:
include:
- component: $CI_SERVER_FQDN/components/opentofu/job-templates@<VERSION>
inputs:
# The version must currently be specified explicitly as an input,
# to find the correctly associated images. # This can be removed
# once https://gitlab.com/gitlab-org/gitlab/-/issues/438275 is solved.
version: <VERSION>
opentofu_version: 1.6.1
plan:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment