From d19e12943d611e4bf3e606346ca1da0197c60e14 Mon Sep 17 00:00:00 2001 From: pjuarezd Date: Mon, 9 Dec 2024 10:57:26 -0800 Subject: [PATCH] Update release scripts * Update controller-gen 0.16.5 * Add `sed_inplace` method in bash script to make the sed syntax compatible in Linux and MacOS * Remove files that reference MCJob in release.sh --- Makefile | 2 +- release.sh | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 1524d478a98..ce947b28974 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ clean: @rm -rf dist/ regen-crd: - @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 + @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.5 @${GOPATH}/bin/controller-gen crd:maxDescLen=0,generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=$(KUSTOMIZE_CRDS) @sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/minio.min.io_tenants.yaml > $(HELM_TEMPLATES)/minio.min.io_tenants.yaml @sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/sts.min.io_policybindings.yaml > $(HELM_TEMPLATES)/sts.min.io_policybindings.yaml diff --git a/release.sh b/release.sh index 0436b378496..ce63f2c889d 100755 --- a/release.sh +++ b/release.sh @@ -15,6 +15,14 @@ while [[ "$#" -gt 0 ]]; do shift done +sed_inplace() { + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i "" -E "$@" + else + sed -i -r "$@" + fi +} + get_latest_release() { curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api grep '"tag_name":' | # Get tag line @@ -27,14 +35,12 @@ MC_RELEASE=$(get_latest_release minio/mc) MINIO_CURRENT_RELEASE=$(sed -nr 's/.*(minio\/minio\:)([v]?.*)"/\2/p' pkg/apis/minio.min.io/v2/constants.go) KES_CURRENT_RELEASE=$(sed -nr 's/.*(minio\/kes\:)([v]?.*)"/\2/p' pkg/apis/minio.min.io/v2/constants.go) +MC_CURRENT_RELEASE=$(sed -nr 's/.*(minio\/mc\:)([v]?.*)"/\2/p' pkg/apis/minio.min.io/v2/constants.go) files=( "README.md" - "pkg/apis/job.min.io/v1alpha1/types.go" "docs/tenant_crd.adoc" "docs/policybinding_crd.adoc" - "docs/job_crd.adoc" - "docs/minio-job.md" "docs/templates/asciidoctor/gv_list.tpl" "examples/kustomization/base/tenant.yaml" "examples/kustomization/tenant-certmanager-kes/tenant.yaml" @@ -55,7 +61,6 @@ CURRENT_RELEASE="${CURRENT_RELEASE:1}" echo "Upgrade: $CURRENT_RELEASE => $RELEASE" echo "MinIO: $MINIO_RELEASE => $MINIO_RELEASE" echo "KES: $KES_CURRENT_RELEASE => $KES_RELEASE" -echo "MC: $MC_CURRENT_RELEASE => $MC_RELEASE" if [ -z "$MINIO_RELEASE" ]; then echo "\$MINIO_RELEASE is empty" @@ -63,28 +68,26 @@ if [ -z "$MINIO_RELEASE" ]; then fi for file in "${files[@]}"; do - sed -i -e "s/${KES_CURRENT_RELEASE}/${KES_RELEASE}/g" "$file" - sed -i -e "s/${MC_CURRENT_RELEASE}/${MC_RELEASE}/g" "$file" - sed -i -e "s/${CURRENT_RELEASE}/${RELEASE}/g" "$file" - sed -i -e "s/${MINIO_CURRENT_RELEASE}/${MINIO_RELEASE}/g" "$file" + sed_inplace "s/${KES_CURRENT_RELEASE}/${KES_RELEASE}/g" "$file" + sed_inplace "s/${CURRENT_RELEASE}/${RELEASE}/g" "$file" + sed_inplace "s/${MINIO_CURRENT_RELEASE}/${MINIO_RELEASE}/g" "$file" done annotations_files=( - "pkg/apis/job.min.io/v1alpha1/types.go" "pkg/apis/minio.min.io/v2/types.go" "pkg/apis/sts.min.io/v1beta1/types.go" ) for file in "${annotations_files[@]}"; do - sed -i -e "s~operator.min.io/version=.*~operator.min.io/version=v${RELEASE}~g" "$file" + sed_inplace "s~operator.min.io/version=.*~operator.min.io/version=v${RELEASE}~g" "$file" done # Update annotation in kustomization yaml -sed -i -e "s~operator.min.io/version: .*~operator.min.io/version: v${RELEASE}~g" "resources/kustomization.yaml" +sed_inplace "s~operator.min.io/version: .*~operator.min.io/version: v${RELEASE}~g" "resources/kustomization.yaml" if [ "${RELEASE_SIDECAR}" = "true" ]; then - sed -i -e 's~quay.io/minio/operator-sidecar:.*\"~quay.io/minio/operator-sidecar:v'$RELEASE'\"~g' "pkg/resources/statefulsets/minio-sidecar.go" + sed_inplace 's~quay.io/minio/operator-sidecar:.*\"~quay.io/minio/operator-sidecar:v'$RELEASE'\"~g' "pkg/resources/statefulsets/minio-sidecar.go" fi # Add all the generated files to git