Skip to content

Commit e97611f

Browse files
wikkykclaude
andcommitted
feat: add release.sh to bump capmox version references
release.sh always updates clusterctl-settings.json (nextVersion) and sonar-project.properties (sonar.projectVersion); on a new major.minor it also appends a releaseSeries entry to metadata.yaml and bumps the capmox sentinel in test/e2e/config/proxmox-*.yaml. Pre-release suffixes are preserved in the clusterctl/sonar files and stripped for the metadata entry and the e2e sentinel (both track major.minor only). The CAPI contract for a new entry defaults to the contract of the latest existing entry and can be overridden via an optional second argument. While here, clean up metadata helper naming per the METADATA_FILE / E2E_METADATA_FILE convention: metadata_has_release and metadata_add_release now operate on the top-level metadata.yaml (the capmox release catalog). The previous e2e-facing variants are renamed to e2emetadata_*. Callers in bump-capi.sh and verify-versions.sh are updated. New helpers: clusterctl_get/set_version (JSON via yq), sonar_get/set_version (line-based), e2econfig_get/set_capmox (yq selects on InfrastructureProvider). Fixtures: add clusterctl-settings.json + sonar-project.properties, reorder metadata.yaml to chronological (newest last) to match the real file, and add an InfrastructureProvider section to the e2e config fixtures so the sentinel helpers and release.sh are testable. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 18199a9 commit e97611f

12 files changed

Lines changed: 407 additions & 18 deletions

hack/bump-capi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ gomod_add_replace "${NEW}" 'sigs.k8s.io/cluster-api'
3535

3636
# ---- test/e2e/data/shared/v1beta1/metadata.yaml ----
3737
# Add new releaseSeries entry as the first element if not already present.
38-
if ! metadata_has_release "${CAPI_MAJOR}" "${CAPI_MINOR}"; then
39-
metadata_add_release "${CAPI_MAJOR}" "${CAPI_MINOR}" "${CONTRACT}"
38+
if ! e2emetadata_has_release "${CAPI_MAJOR}" "${CAPI_MINOR}"; then
39+
e2emetadata_add_release "${CAPI_MAJOR}" "${CAPI_MINOR}" "${CONTRACT}"
4040
fi
4141

4242
# ---- test/e2e/config ----

hack/helpers.sh

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,50 @@ customgcl_set_version() {
272272
fi
273273
}
274274

275+
# ---- version extraction: release files ----
276+
277+
# clusterctl_get_version returns the capmox nextVersion from
278+
# clusterctl-settings.json (e.g. "v0.8.1"). Returns empty string if the
279+
# file does not exist.
280+
clusterctl_get_version() {
281+
local f="${REPO_ROOT}/clusterctl-settings.json"
282+
if [[ -f "${f}" ]]; then
283+
yq -oy '.config.nextVersion' "${f}"
284+
fi
285+
}
286+
287+
# clusterctl_set_version updates nextVersion in clusterctl-settings.json.
288+
# The input is the full v-prefixed version (e.g. "v0.8.2" or "v0.9.0-rc.0").
289+
clusterctl_set_version() {
290+
local new="$1" f="${REPO_ROOT}/clusterctl-settings.json" old
291+
if [[ -f "${f}" ]]; then
292+
old=$(clusterctl_get_version)
293+
CLUSTERCTL_NEXT="${new}" yq -i '.config.nextVersion = strenv(CLUSTERCTL_NEXT)' "${f}"
294+
if [[ -n "${old}" && "${old}" != "${new}" ]]; then echo "clusterctl-settings.json: Updated nextVersion ${old} to ${new}"; fi
295+
fi
296+
}
297+
298+
# sonar_get_version returns the sonar.projectVersion value from
299+
# sonar-project.properties (e.g. "0.8.1"). Returns empty string if the file
300+
# does not exist.
301+
sonar_get_version() {
302+
local f="${REPO_ROOT}/sonar-project.properties"
303+
if [[ -f "${f}" ]]; then
304+
awk -F= '/^sonar\.projectVersion=/{print $2; exit}' "${f}"
305+
fi
306+
}
307+
308+
# sonar_set_version updates sonar.projectVersion in sonar-project.properties.
309+
# The input is the bare version string without a v-prefix (e.g. "0.8.2").
310+
sonar_set_version() {
311+
local new="$1" f="${REPO_ROOT}/sonar-project.properties" old
312+
if [[ -f "${f}" ]]; then
313+
old=$(sonar_get_version)
314+
sedi "s/^(sonar\.projectVersion=).+/\1${new}/" "${f}"
315+
if [[ -n "${old}" && "${old}" != "${new}" ]]; then echo "sonar-project.properties: Updated sonar.projectVersion ${old} to ${new}"; fi
316+
fi
317+
}
318+
275319
# ---- version extraction: e2e config ----
276320

277321
# E2E config files contain KUBERNETES_VERSION defaults and CAPI provider
@@ -304,6 +348,28 @@ e2econfig_get_capi() {
304348
yq '.providers[] | select(.type == "CoreProvider") | .versions[0].name' "${E2E_CONFIG_DIR}/proxmox-ci.yaml"
305349
}
306350

351+
# e2econfig_get_capmox returns the capmox provider sentinel from the first
352+
# e2e config file (e.g. "v0.8.99"). This sentinel uses the current release
353+
# major.minor with a fixed .99 patch component to denote "the development
354+
# version of this series".
355+
e2econfig_get_capmox() {
356+
yq '.providers[] | select(.type == "InfrastructureProvider") | .versions[0].name' "${E2E_CONFIG_DIR}/proxmox-ci.yaml"
357+
}
358+
359+
# e2econfig_set_capmox updates the capmox provider sentinel in all e2e
360+
# config files. The input is the target sentinel string (e.g. "v0.9.99").
361+
e2econfig_set_capmox() {
362+
local new="$1" old
363+
old=$(e2econfig_get_capmox)
364+
if [[ -z "${old}" ]]; then return; fi
365+
for f in "${E2E_CONFIG_DIR}/proxmox-ci.yaml" "${E2E_CONFIG_DIR}/proxmox-dev.yaml"; do
366+
if [[ -f "${f}" ]]; then
367+
E2E_CAPMOX="${new}" yq -i '(.providers[] | select(.type == "InfrastructureProvider") | .versions[0].name) = strenv(E2E_CAPMOX)' "${f}"
368+
fi
369+
done
370+
if [[ "${old}" != "${new}" ]]; then echo "test/e2e/config: Updated capmox ${old} to ${new}"; fi
371+
}
372+
307373
# e2econfig_set_capi updates the cluster-api provider version in all e2e
308374
# config files, including both the provider name and download URL.
309375
e2econfig_set_capi() {
@@ -361,15 +427,34 @@ metadata_latest_contract() {
361427
}
362428

363429
# metadata_has_release returns 0 (true) when a releaseSeries entry with the
364-
# given major and minor version already exists in the e2e metadata file.
430+
# given major and minor version already exists in the top-level metadata.yaml
431+
# (the capmox release catalog).
365432
metadata_has_release() {
366433
local major="$1" minor="$2"
367-
yq -e '.releaseSeries[] | select(.major == '"${major}"' and .minor == '"${minor}"')' "${E2E_METADATA_FILE}" > /dev/null 2>&1
434+
yq -e '.releaseSeries[] | select(.major == '"${major}"' and .minor == '"${minor}"')' "${METADATA_FILE}" > /dev/null 2>&1
368435
}
369436

370-
# metadata_add_release prepends a new releaseSeries entry to the e2e metadata
371-
# file and prints a confirmation message.
437+
# metadata_add_release appends a new releaseSeries entry to the top-level
438+
# metadata.yaml (chronological order, newest last) and prints a confirmation
439+
# message.
372440
metadata_add_release() {
441+
local major="$1" minor="$2" contract="$3"
442+
yq -i '.releaseSeries += [{"major": '"${major}"', "minor": '"${minor}"', "contract": "'"${contract}"'"}]' "${METADATA_FILE}"
443+
echo "metadata.yaml: Added releaseSeries entry for v${major}.${minor} (${contract})"
444+
}
445+
446+
# e2emetadata_has_release returns 0 (true) when a releaseSeries entry with
447+
# the given major and minor version already exists in the e2e metadata file
448+
# (the CAPI release catalog consumed by e2e tests).
449+
e2emetadata_has_release() {
450+
local major="$1" minor="$2"
451+
yq -e '.releaseSeries[] | select(.major == '"${major}"' and .minor == '"${minor}"')' "${E2E_METADATA_FILE}" > /dev/null 2>&1
452+
}
453+
454+
# e2emetadata_add_release prepends a new releaseSeries entry to the e2e
455+
# metadata file (reverse-chronological order, newest first) and prints a
456+
# confirmation message.
457+
e2emetadata_add_release() {
373458
local major="$1" minor="$2" contract="$3"
374459
yq -i '.releaseSeries = [{"major": '"${major}"', "minor": '"${minor}"', "contract": "'"${contract}"'"}] + .releaseSeries' "${E2E_METADATA_FILE}"
375460
echo "test/e2e/data/shared/v1beta1/metadata.yaml: Added releaseSeries entry for v${major}.${minor} (${contract})"

hack/release.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# release.sh bumps capmox version references in preparation for a release.
3+
#
4+
# Updates:
5+
# - clusterctl-settings.json: .config.nextVersion (v-prefixed)
6+
# - sonar-project.properties: sonar.projectVersion (no v-prefix)
7+
#
8+
# For new major.minor versions (not yet listed in metadata.yaml) it also:
9+
# - appends a releaseSeries entry to metadata.yaml (CAPI contract defaults
10+
# to the contract of the most recent existing entry when not supplied)
11+
# - updates the capmox sentinel (name: vX.Y.99) in test/e2e/config/proxmox-*.yaml
12+
#
13+
# Pre-release suffixes (-rc.0, -beta.1, ...) are preserved in
14+
# clusterctl-settings.json and sonar-project.properties but stripped when
15+
# checking/adding the releaseSeries entry and updating the e2e sentinel
16+
# (both track major.minor only).
17+
#
18+
# Usage: ./hack/release.sh <version> [<capi-contract>]
19+
# Example: ./hack/release.sh 0.8.2
20+
# ./hack/release.sh 0.9.0 v1beta2
21+
# ./hack/release.sh 0.9.0-rc.0
22+
23+
set -euo pipefail
24+
25+
# shellcheck source=hack/helpers.sh
26+
source "$(dirname "$0")/helpers.sh"
27+
28+
if [[ $# -lt 1 || $# -gt 2 ]]; then
29+
echo "Usage: $0 <version> [<capi-contract>]"
30+
echo "Example: $0 0.8.2"
31+
echo "Example: $0 0.9.0 v1beta2"
32+
exit 1
33+
fi
34+
35+
NEW_FULL=$(ensure_v_prefix "$1")
36+
CONTRACT="${2:-}"
37+
38+
# Strip any pre-release suffix (-rc.0, -beta.1, ...) for major.minor lookups.
39+
NEW_CORE="${NEW_FULL%%-*}"
40+
validate_semver "${NEW_CORE}"
41+
42+
split_version "${NEW_CORE}"
43+
CORE_MAJOR="${MAJOR}"
44+
CORE_MINOR="${MINOR}"
45+
46+
# Always: clusterctl-settings.json (with v-prefix, suffix preserved).
47+
clusterctl_set_version "${NEW_FULL}"
48+
49+
# Always: sonar-project.properties (no v-prefix, suffix preserved).
50+
sonar_set_version "$(strip_v_prefix "${NEW_FULL}")"
51+
52+
# New major.minor: append to metadata.yaml + bump the e2e sentinel.
53+
if ! metadata_has_release "${CORE_MAJOR}" "${CORE_MINOR}"; then
54+
if [[ -z "${CONTRACT}" ]]; then
55+
CONTRACT=$(metadata_latest_contract)
56+
fi
57+
metadata_add_release "${CORE_MAJOR}" "${CORE_MINOR}" "${CONTRACT}"
58+
e2econfig_set_capmox "v${CORE_MAJOR}.${CORE_MINOR}.99"
59+
fi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "infrastructure-proxmox",
3+
"config": {
4+
"componentsFile": "infrastructure-components.yaml",
5+
"nextVersion": "v0.8.1"
6+
}
7+
}

hack/spec/fixtures/metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
22
kind: Metadata
33
releaseSeries:
4-
- major: 0
5-
minor: 8
6-
contract: v1beta2
74
- major: 0
85
minor: 7
96
contract: v1beta1
7+
- major: 0
8+
minor: 8
9+
contract: v1beta2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sonar.projectVersion=0.8.1
2+
sonar.projectKey=ionos-cloud_cluster-api-provider-proxmox
3+
sonar.organization=ionos-cloud

hack/spec/fixtures/test/e2e/config/proxmox-ci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ providers:
1212
- name: v1.10.4
1313
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.4/bootstrap-components.yaml
1414
type: url
15+
- name: proxmox
16+
type: InfrastructureProvider
17+
versions:
18+
- name: v0.8.99
19+
value: "${PWD}/config/default"
1520

1621
variables:
1722
KUBERNETES_VERSION: "${KUBERNETES_VERSION:-v1.32.3}"

hack/spec/fixtures/test/e2e/config/proxmox-dev.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ providers:
1212
- name: v1.10.4
1313
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.4/bootstrap-components.yaml
1414
type: url
15+
- name: proxmox
16+
type: InfrastructureProvider
17+
versions:
18+
- name: v0.8.99
19+
value: "${PWD}/config/default"
1520

1621
variables:
1722
KUBERNETES_VERSION: "${KUBERNETES_VERSION:-v1.32.3}"

hack/spec/helpers_file_versions_spec.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,73 @@ Describe 'helpers.sh — file version functions'
126126
End
127127
End
128128

129+
Describe 'e2econfig_get_capmox'
130+
It 'returns the capmox sentinel from e2e config'
131+
When call e2econfig_get_capmox
132+
The output should equal 'v0.8.99'
133+
End
134+
End
135+
136+
Describe 'e2econfig_set_capmox'
137+
It 'updates the capmox sentinel in e2e config files'
138+
When call e2econfig_set_capmox 'v0.9.99'
139+
The output should include 'Updated capmox v0.8.99 to v0.9.99'
140+
End
141+
142+
It 'writes the new sentinel to both files'
143+
e2econfig_set_capmox 'v0.9.99' >/dev/null
144+
When call e2econfig_get_capmox
145+
The output should equal 'v0.9.99'
146+
End
147+
148+
It 'updates both ci and dev files'
149+
e2econfig_set_capmox 'v0.9.99' >/dev/null
150+
_dev_sentinel() { yq '.providers[] | select(.type == "InfrastructureProvider") | .versions[0].name' "${E2E_CONFIG_DIR}/proxmox-dev.yaml"; }
151+
When call _dev_sentinel
152+
The output should equal 'v0.9.99'
153+
End
154+
End
155+
156+
Describe 'clusterctl_get_version'
157+
It 'returns the capmox nextVersion'
158+
When call clusterctl_get_version
159+
The output should equal 'v0.8.1'
160+
End
161+
End
162+
163+
Describe 'clusterctl_set_version'
164+
It 'updates nextVersion'
165+
When call clusterctl_set_version 'v0.8.2'
166+
The output should include 'Updated nextVersion v0.8.1 to v0.8.2'
167+
End
168+
169+
It 'writes the new value'
170+
clusterctl_set_version 'v0.8.2' >/dev/null
171+
When call clusterctl_get_version
172+
The output should equal 'v0.8.2'
173+
End
174+
End
175+
176+
Describe 'sonar_get_version'
177+
It 'returns the sonar.projectVersion'
178+
When call sonar_get_version
179+
The output should equal '0.8.1'
180+
End
181+
End
182+
183+
Describe 'sonar_set_version'
184+
It 'updates sonar.projectVersion'
185+
When call sonar_set_version '0.8.2'
186+
The output should include 'Updated sonar.projectVersion 0.8.1 to 0.8.2'
187+
End
188+
189+
It 'writes the new value'
190+
sonar_set_version '0.8.2' >/dev/null
191+
When call sonar_get_version
192+
The output should equal '0.8.2'
193+
End
194+
End
195+
129196
Describe 'e2econfig_set_capi'
130197
It 'updates the cluster-api version in e2e config files'
131198
When call e2econfig_set_capi 'v1.11.0'

hack/spec/helpers_metadata_spec.sh

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,66 @@ YAML
7373
End
7474

7575
Describe 'metadata_has_release'
76-
It 'returns success for an existing entry'
77-
When call metadata_has_release 1 10
76+
It 'returns success for an existing capmox entry'
77+
When call metadata_has_release 0 8
7878
The status should be success
7979
End
8080

81-
It 'returns failure for a missing entry'
82-
When call metadata_has_release 1 99
81+
It 'returns failure for a missing capmox entry'
82+
When call metadata_has_release 0 99
8383
The status should be failure
8484
End
8585
End
8686

8787
Describe 'metadata_add_release'
88-
It 'adds a new releaseSeries entry'
89-
When call metadata_add_release 1 11 'v1beta2'
88+
It 'adds a new capmox releaseSeries entry'
89+
When call metadata_add_release 0 9 'v1beta2'
90+
The output should include 'metadata.yaml: Added releaseSeries entry for v0.9'
91+
End
92+
93+
It 'makes the new entry discoverable'
94+
metadata_add_release 0 9 'v1beta2' >/dev/null
95+
When call metadata_has_release 0 9
96+
The status should be success
97+
End
98+
99+
It 'appends (chronological order, newest last)'
100+
metadata_add_release 0 9 'v1beta2' >/dev/null
101+
_last_minor() { yq '.releaseSeries[-1].minor' "${METADATA_FILE}"; }
102+
When call _last_minor
103+
The output should equal '9'
104+
End
105+
End
106+
107+
Describe 'e2emetadata_has_release'
108+
It 'returns success for an existing CAPI entry'
109+
When call e2emetadata_has_release 1 10
110+
The status should be success
111+
End
112+
113+
It 'returns failure for a missing CAPI entry'
114+
When call e2emetadata_has_release 1 99
115+
The status should be failure
116+
End
117+
End
118+
119+
Describe 'e2emetadata_add_release'
120+
It 'adds a new CAPI releaseSeries entry'
121+
When call e2emetadata_add_release 1 11 'v1beta2'
90122
The output should include 'Added releaseSeries entry for v1.11'
91123
End
92124

93125
It 'makes the new entry discoverable'
94-
metadata_add_release 1 11 'v1beta2' >/dev/null
95-
When call metadata_has_release 1 11
126+
e2emetadata_add_release 1 11 'v1beta2' >/dev/null
127+
When call e2emetadata_has_release 1 11
96128
The status should be success
97129
End
130+
131+
It 'prepends (reverse-chronological order, newest first)'
132+
e2emetadata_add_release 1 11 'v1beta2' >/dev/null
133+
_first_minor() { yq '.releaseSeries[0].minor' "${E2E_METADATA_FILE}"; }
134+
When call _first_minor
135+
The output should equal '11'
136+
End
98137
End
99138
End

0 commit comments

Comments
 (0)