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

Get version from SSoT

parent 5f274c72
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ workflow: ...@@ -6,6 +6,7 @@ workflow:
- if: $CI_COMMIT_REF_PROTECTED == "true" - if: $CI_COMMIT_REF_PROTECTED == "true"
include: include:
- local: opentofu_versions.yaml
- local: tests/unit.gitlab-ci.yml - local: tests/unit.gitlab-ci.yml
rules: rules:
- if: $SKIP_TESTS == "true" - if: $SKIP_TESTS == "true"
...@@ -55,19 +56,14 @@ stages: ...@@ -55,19 +56,14 @@ stages:
.opentofu-versions: .opentofu-versions:
parallel: parallel:
matrix: matrix:
- OPENTOFU_VERSION: '1.7.1' - OPENTOFU_VERSION: !reference [.data, supported_versions]
- OPENTOFU_VERSION: '1.7.0'
- OPENTOFU_VERSION: '1.7.0-alpha1'
- OPENTOFU_VERSION: '1.6.2'
- OPENTOFU_VERSION: '1.6.1'
- OPENTOFU_VERSION: '1.6.0'
variables: variables:
# Pipeline configuration # Pipeline configuration
DOCKER_DIND_IMAGE: "docker:26.1.4-dind" DOCKER_DIND_IMAGE: "docker:26.1.4-dind"
# OpenTofu variables # OpenTofu variables
LATEST_OPENTOFU_VERSION: '1.7.1' LATEST_OPENTOFU_VERSION: !reference [.data, latest_version]
# OpenTofu image build variables: # OpenTofu image build variables:
PLATFORMS: linux/amd64,linux/arm64 PLATFORMS: linux/amd64,linux/arm64
...@@ -122,6 +118,16 @@ gitlab-opentofu-image:build: ...@@ -122,6 +118,16 @@ gitlab-opentofu-image:build:
- templates/**/* - templates/**/*
- tests/**/* - tests/**/*
check-versions:
stage: test
needs: []
image: alpine:latest
before_script:
- apk add coreutils yq patch git
script:
- ./.gitlab/scripts/update-opentofu-versions.sh
- git diff --exit-code
check-readme: check-readme:
stage: test stage: test
needs: [] needs: []
......
#!/usr/bin/env sh
echo "Updating template files ..."
templates="templates/apply.yml templates/custom-command.yml templates/destroy.yml templates/fmt.yml templates/full-pipeline.yml templates/job-templates.yml templates/plan.yml templates/test.yml templates/validate-plan-apply.yml templates/validate-plan-destroy.yml templates/validate-plan.yml templates/validate.yml"
for template_file in $templates; do
tmp_template_file1=$(mktemp)
tmp_template_file2=$(mktemp)
echo "Updating $template_file ... "
yq eval-all 'select(fileIndex == 0 and document_index == 0).spec.inputs.opentofu_version.default = select(fileIndex == 1).".data".latest_version | select(fileIndex == 0)' "$template_file" opentofu_versions.yaml > "$tmp_template_file1"
yq eval-all 'select(fileIndex == 0 and document_index == 0).spec.inputs.opentofu_version.options = (select(fileIndex == 1).".data".hack_templates_supported_versions | explode(.) | flatten) | select(fileIndex == 0)' "$tmp_template_file1" opentofu_versions.yaml > "$tmp_template_file2"
diff -Bw "$template_file" "$tmp_template_file2" | patch "$template_file" -
done
...@@ -12,7 +12,7 @@ docs: ...@@ -12,7 +12,7 @@ docs:
echo >> README.md echo >> README.md
echo 'The following OpenTofu versions are available with this component via the `opentofu_version` input:' >> README.md echo 'The following OpenTofu versions are available with this component via the `opentofu_version` input:' >> README.md
echo >> README.md echo >> README.md
yq -r '.spec.inputs.opentofu_version.options | filter((. | test("\$$.*")) == false) | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' templates/full-pipeline.yml >> README.md yq -r '.".data".supported_versions | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' opentofu_versions.yaml >> README.md
tail -n+2 readme1 >> README.md tail -n+2 readme1 >> README.md
rm -f readme0 readme1 readme_inputs.md rm -f readme0 readme1 readme_inputs.md
......
.data:
latest_version: '1.7.1'
supported_versions: &supported_versions
- '1.7.1'
- '1.7.0'
- '1.7.0-alpha1'
- '1.6.2'
- '1.6.1'
- '1.6.0'
hack_templates_supported_versions:
- *supported_versions
- '$OPENTOFU_VERSION'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment