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

Merge branch 'main' into 'main'

feat: add renovate shared config

See merge request components/opentofu!129
parents d655ee86 fe37570d
No related branches found
No related tags found
No related merge requests found
...@@ -280,6 +280,54 @@ However, we cannot use the alternative `+` which would indicate build metadata ...@@ -280,6 +280,54 @@ However, we cannot use the alternative `+` which would indicate build metadata
as we'd like. as we'd like.
See https://github.com/distribution/distribution/issues/1201* See https://github.com/distribution/distribution/issues/1201*
### Using with Renovate
To keep the component versions up to date you could use [Renovate](https://docs.renovatebot.com/).
Renovate users who use the component input `opentofu_version` should include the following `extends`
so that the OpenTofu version is raised to a maximum of the version suitable for the component:
```json
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>components/opentofu"],
...
}
```
(You may need to adjust the path to the `components/opentofu` to match your mirror.)
Fore more details refer to the [Renovate documentation](https://docs.renovatebot.com/config-presets/).
Some more example configurations for your `renovate.json`:
- Package Rule to update all CI-Components
```json
{
"matchFileNames": [
".gitlab-ci.yaml",
".gitlab-ci.yml",
"templates/**/*.yaml",
"templates/**/*.yml"
],
"groupName": "Pipeline",
"semanticCommitType": "ci",
"automerge": true
},
```
- Package rule to pin only `major.minor` versions:
```json
{
"matchManagers": ["gitlabci"],
"extractVersion": "^(?<version>\\d+\\.\\d+)"
},
```
- Package rule to target a specific component:
```json
{
"matchPackageNames": ["components/opentofu"],
"matchManagers": ["gitlabci"]
},
```
## Usage on self-managed ## Usage on self-managed
GitLab CI/CD components are not yet distributed and available on self-managed GitLab instances. GitLab CI/CD components are not yet distributed and available on self-managed GitLab instances.
......
...@@ -16,7 +16,26 @@ for relative_template_file in $templates; do ...@@ -16,7 +16,26 @@ for relative_template_file in $templates; do
tmp_template_file1=$(mktemp) tmp_template_file1=$(mktemp)
tmp_template_file2=$(mktemp) tmp_template_file2=$(mktemp)
echo "Updating $template_file ... " 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" "$project_dir/opentofu_versions.yaml" > "$tmp_template_file1" yq eval-all '
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" "$project_dir/opentofu_versions.yaml" > "$tmp_template_file2" select(fileIndex == 0 and document_index == 0).spec.inputs.opentofu_version.default
= select(fileIndex == 1).".data".latest_version
| select(fileIndex == 0)
' "$template_file" "$project_dir/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" "$project_dir/opentofu_versions.yaml" > "$tmp_template_file2"
diff -Bw "$template_file" "$tmp_template_file2" | patch "$template_file" - diff -Bw "$template_file" "$tmp_template_file2" | patch "$template_file" -
done done
renovate_config="default.json"
echo "Updating Renovate config $renovate_config ... "
yq eval-all -p yaml -I4 -o json -i '
select(fileIndex == 0 and documentIndex == 0).packageRules[0].allowedVersions
= "<="
+ select(fileIndex == 1 and documentIndex == 0).".data".latest_version
| select(fileIndex == 0)
' "$renovate_config" "$project_dir/opentofu_versions.yaml"
...@@ -297,6 +297,54 @@ However, we cannot use the alternative `+` which would indicate build metadata ...@@ -297,6 +297,54 @@ However, we cannot use the alternative `+` which would indicate build metadata
as we'd like. as we'd like.
See https://github.com/distribution/distribution/issues/1201* See https://github.com/distribution/distribution/issues/1201*
### Using with Renovate
To keep the component versions up to date you could use [Renovate](https://docs.renovatebot.com/).
Renovate users who use the component input `opentofu_version` should include the following `extends`
so that the OpenTofu version is raised to a maximum of the version suitable for the component:
```json
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>components/opentofu"],
...
}
```
(You may need to adjust the path to the `components/opentofu` to match your mirror.)
Fore more details refer to the [Renovate documentation](https://docs.renovatebot.com/config-presets/).
Some more example configurations for your `renovate.json`:
- Package Rule to update all CI-Components
```json
{
"matchFileNames": [
".gitlab-ci.yaml",
".gitlab-ci.yml",
"templates/**/*.yaml",
"templates/**/*.yml"
],
"groupName": "Pipeline",
"semanticCommitType": "ci",
"automerge": true
},
```
- Package rule to pin only `major.minor` versions:
```json
{
"matchManagers": ["gitlabci"],
"extractVersion": "^(?<version>\\d+\\.\\d+)"
},
```
- Package rule to target a specific component:
```json
{
"matchPackageNames": ["components/opentofu"],
"matchManagers": ["gitlabci"]
},
```
## Usage on self-managed ## Usage on self-managed
GitLab CI/CD components are not yet distributed and available on self-managed GitLab instances. GitLab CI/CD components are not yet distributed and available on self-managed GitLab instances.
......
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Renovate configuration for OpenTofu versioning with CI/CD Components",
"packageRules": [
{
"matchDepNames": [
"opentofu/opentofu"
],
"matchFileNames": [
".gitlab-ci.yml",
".gitlab-ci.yaml",
"templates/**/*.yml",
"templates/**/*.yaml"
],
"allowedVersions": "<=1.8.2"
}
],
"customManagers": [
{
"customType": "regex",
"fileMatch": [
"\\.gitlab-ci\\.ya?ml",
"templates/.*\\.ya?ml"
],
"matchStrings": [
"opentofu_version:\\s*['\"](?<currentValue>[^'\"]+)['\"]"
],
"datasourceTemplate": "github-releases",
"depNameTemplate": "opentofu/opentofu",
"versioningTemplate": "semver",
"extractVersionTemplate": "^v(?<version>.*)$"
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment