diff --git a/.github/workflows/sync-chart.yml b/.github/workflows/sync-chart.yml index f7a34d58..8f08e746 100644 --- a/.github/workflows/sync-chart.yml +++ b/.github/workflows/sync-chart.yml @@ -117,6 +117,14 @@ jobs: regex: false exclude: .github/** + - name: Update REPLACES to current version + run: | + current_replaces=$(grep -E '^REPLACES' Makefile | awk -F'=' '{ print $2 }' | xargs) + current_version=$(grep -E '^VERSION' Makefile | awk '{ print $3 }') + echo "Current REPLACES: $current_replaces" + echo "Will set REPLACES to: nginx-ingress-operator.v$current_version" + sed -i "s|^REPLACES ?= .*|REPLACES ?= nginx-ingress-operator.v$current_version|" Makefile + - name: Find and Replace Operator version uses: jacobtomlinson/gha-find-replace@f1069b438f125e5395d84d1c6fd3b559a7880cb5 # v3.0.5 with: diff --git a/Makefile b/Makefile index 2b8150c8..2495cda8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) VERSION ?= 3.3.1 +# REPLACES defines the operator version that this version replaces for upgrades (OLM path). +# Set to empty to disable (e.g make bundle REPLACES=) +REPLACES ?= nginx-ingress-operator.v3.2.3 + # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") # To re-generate a bundle for other specific channels without changing the standard setup, you can: @@ -211,6 +215,14 @@ bundle: kustomize operator-sdk ## Generate bundle manifests and metadata, then v cd config/default && $(KUSTOMIZE) edit set image kube-rbac-proxy=$(KRP_IMAGE_BASE):$(KRP_IMAGE_VERSION) if [ -n "$(IMAGE_PULL_SECRET_NAME)" ]; then cd config/default && $(KUSTOMIZE) edit add patch --kind Deployment --group apps --version v1 --name controller-manager --patch '${image_pull_secrets_patch}'; fi $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) + @if [ -n "$(REPLACES)" ]; then \ + echo "Adding replaces: $(REPLACES) to ClusterServiceVersion"; \ + sed -i.bak '/^ provider:/{h;s/.*/ replaces: $(REPLACES)/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak; \ + fi + @echo "Adding skips: [] to ClusterServiceVersion"; \ + sed -i.bak '/^ version:/{h;s/.*/ skips: []/;p;x;}' bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml && \ + rm -f bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml.bak @printf "%s\n" '' 'LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSION)"' 'LABEL com.redhat.delivery.operator.bundle=true' 'LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile @printf "%s\n" '' ' # OpenShift annotations.' ' com.redhat.openshift.versions: $(OPENSHIFT_VERSION)' >> bundle/metadata/annotations.yaml $(OPERATOR_SDK) bundle validate ./bundle