Skip to content

Commit

Permalink
build: Add CAREN release to cluster class artifacts (#979)
Browse files Browse the repository at this point in the history
This attaches the updated cluster class artifacts containing the
CAREN release version to the release artifacts on release.
  • Loading branch information
jimmidyson authored Nov 26, 2024
1 parent e03cea0 commit 0b01878
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ test/e2e/config/caren-envsubst.yaml
/release-metadata.yaml
hack/tools/fetch-images/fetch-images
caren-images.txt
hack/examples/release/*-cluster-class.yaml
6 changes: 5 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ release:
- glob: release-metadata.yaml
name_template: metadata.yaml
- glob: runtime-extensions-components.yaml
- glob: ./charts/{{ .ProjectName }}/defaultclusterclasses/*.yaml
- glob: ./hack/examples/release/*-cluster-class.yaml
- glob: caren-images.txt

before:
Expand Down Expand Up @@ -58,6 +58,10 @@ before:
sh -ec 'if [ {{ .IsSnapshot }} == false ] ; then
make --no-print-directory CAREN_VERSION=v{{ trimprefix .Version "v" }} list-images >caren-images.txt
fi'
- |
sh -ec 'if [ {{ .IsSnapshot }} == false ] ; then
make --no-print-directory CAREN_VERSION=v{{ trimprefix .Version "v" }} add-version-to-clusterclasses
fi'
builds:
- id: cluster-api-runtime-extensions-nutanix
Expand Down
21 changes: 21 additions & 0 deletions hack/examples/release/add-version-to-clusterclasses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Copyright 2024 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail
IFS=$'\n\t'

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_DIR

trap 'find "${SCRIPT_DIR}" -name kustomization.yaml -delete' EXIT

export CAREN_RELEASE_VERSION="${1}"

for CC_TEMPLATE in "${SCRIPT_DIR}"/../../../charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/*.yaml; do
export CC_TEMPLATE
envsubst -no-empty -no-unset -i "${SCRIPT_DIR}/kustomization.yaml.tmpl" -o "${SCRIPT_DIR}/kustomization.yaml"

kustomize build "${SCRIPT_DIR}" --load-restrictor LoadRestrictionsNone >"${SCRIPT_DIR}/$(basename "${CC_TEMPLATE}")"
done
14 changes: 14 additions & 0 deletions hack/examples/release/kustomization.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

sortOptions:
order: fifo

commonAnnotations:
caren.nutanix.com/version: "${CAREN_RELEASE_VERSION}"

resources:
- "${CC_TEMPLATE}"
4 changes: 4 additions & 0 deletions make/goreleaser.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ release-snapshot: go-generate ; $(info $(M) building snapshot release $*)
.PHONY: list-releases
list-releases: ## List releases from GitHub
gh release list --json tagName | gojq -r .[].tagName

.PHONY: add-version-to-clusterclasses
add-version-to-clusterclasses:
./hack/examples/release/add-version-to-clusterclasses.sh $(CAREN_VERSION)

0 comments on commit 0b01878

Please sign in to comment.