Skip to content

Commit e9b87b5

Browse files
authored
chore: make the generation of the metadata.yaml additive (#50)
It seems like the metadata.yaml of release X needs to contain the metadata of release X-1..0 🤷
1 parent 59e00f4 commit e9b87b5

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

.github/workflows/release-please.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
with:
5151
go-version-file: ./go.mod
5252

53+
- name: Download last metadata
54+
run: gh release download -p metadata.yaml
55+
continue-on-error: true
5356
- run: task build
5457

5558
- name: Log in to Container Registry

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ansible/.venv
1212

1313
## e2e test suite output
1414
_artifacts/
15+
metadata.yaml
1516

1617
## From kubebuilder
1718

taskfile.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ vars:
3636
kustomize:
3737
url: sigs.k8s.io/kustomize/kustomize/v5
3838
version: 5.7.1
39-
jq:
40-
url: github.com/itchyny/gojq/cmd/gojq
41-
version: 0.12.17
39+
# not the good yq, but the good one has no "just run" option
40+
yq:
41+
url: github.com/mikefarah/yq/v4
42+
version: 4.49.2
4243
controllerGenCmd: 'go run {{ (index .tools "controller-gen").url }}@v{{ (index .tools "controller-gen").version }}'
4344
conversionGenCmd: 'go run {{ (index .tools "conversion-gen").url }}@v{{ (index .tools "conversion-gen").version }}'
4445
golangciLintCmd: 'go run {{ (index .tools "golangci-lint").url }}@v{{ (index .tools "golangci-lint").version }}'
4546
gofumptCmd: 'go run {{ (index .tools "gofumpt").url }}@v{{ (index .tools "gofumpt").version }}'
4647
golinesCmd: 'go run {{ (index .tools "golines").url }}@v{{ (index .tools "golines").version }}'
4748
kustomizeCmd: 'go run {{ (index .tools "kustomize").url }}@v{{ (index .tools "kustomize").version }}'
48-
jqCmd: 'go run {{ (index .tools "jq").url }}@v{{ (index .tools "jq").version }}'
49+
yqCmd: 'go run {{ (index .tools "yq").url }}@v{{ (index .tools "yq").version }}'
4950
buildDir: build
5051
artifactsDir: _artifacts
5152
# TODO: until https://github.com/go-task/task/issues/178 is done
@@ -68,21 +69,18 @@ tasks:
6869
declare -a supportedVersions
6970
mapfile -t supportedVersions <<< "$(sed -n -r 's#^\s+cluster.x-k8s.io/(v\S+): \S+#\1#gp' {{ .buildDir }}/crds/controlplane.* | sort -u)"
7071
declare -a currentVersion
71-
mapfile -t currentVersion <<< "$({{ .jqCmd }} -r '.["."] | split(".") | "\(.[0])\n\(.[1])"' .github/release-please/manifest.json)"
72-
(
73-
cat <<EOF
72+
mapfile -t currentVersion <<< "$({{ .yqCmd }} -r '.["."] | split(".") | "\(.[0])\n\(.[1])"' .github/release-please/manifest.json)"
73+
if ! [[ -f metadata.yaml ]]; then
74+
cat <<EOF | cut -c 5- > metadata.yaml
7475
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
7576
kind: Metadata
76-
releaseSeries:
77+
releaseSeries: []
7778
EOF
78-
for version in "${supportedVersions[@]}"; do
79-
cat <<EOF
80-
- major: ${currentVersion[0]}
81-
minor: ${currentVersion[1]}
82-
contract: ${version}
83-
EOF
84-
done
85-
) | cut -c 5- > {{ .buildDir }}/metadata.yaml
79+
fi
80+
for version in "${supportedVersions[@]}"; do
81+
MAJOR="${currentVersion[0]}" MINOR="${currentVersion[1]}" VERSION="$version" {{ .yqCmd }} -i '.releaseSeries = (.releaseSeries + [{"major":env(MAJOR),"minor":env(MINOR),"contract":strenv(VERSION)}] | unique | sort_by(.major, .minor) | reverse)' metadata.yaml
82+
done
83+
mv metadata.yaml {{ .buildDir }}/metadata.yaml
8684
generates:
8785
- "{{ .buildDir }}/control-plane-components.yaml"
8886
- "{{ .buildDir }}/metadata.yaml"
@@ -179,7 +177,7 @@ tasks:
179177
arch: '{{ .arch | default ARCH }}'
180178
oldDigests:
181179
sh: >-
182-
(buildah manifest inspect {{ .IMAGE }} 2> /dev/null || echo '{}') | {{ .jqCmd }} -r '.manifests // [] | map(select(.platform.architecture == "{{ .arch }}")) | map(.digest)[]' 2>/dev/null || true
180+
(buildah manifest inspect {{ .IMAGE }} 2> /dev/null || echo '{}') | {{ .yqCmd }} -r '.manifests // [] | map(select(.platform.architecture == "{{ .arch }}")) | map(.digest)[]' 2>/dev/null || true
183181
sources:
184182
- Containerfile
185183
- .containerignore

0 commit comments

Comments
 (0)