Skip to content

Commit fe96a56

Browse files
update openshift release
1 parent 3d3416b commit fe96a56

3 files changed

Lines changed: 28 additions & 119 deletions

File tree

.github/workflows/operatorhub.yaml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- uses: dawidd6/action-download-artifact@1f8785ff7a5130826f848e7f72725c85d241860f
5454
with:
5555
name: olm
56-
workflow: main.yaml
56+
workflow: release.yaml
5757
github_token: ${{ secrets.VM_BOT_GH_TOKEN }}
5858
run_id: ${{ github.event.workflow_run.id }}
5959
path: bundle
@@ -71,45 +71,42 @@ jobs:
7171
run: |
7272
if [ ! -d bundle ]; then
7373
echo "No bundle directory found"
74-
exit 1;
74+
exit 1
7575
fi
76-
CATALOGS_DIR=__operatorhub-repo/catalogs
77-
NEW_VERSION=$(ls bundle | head -1)
78-
CATALOG_FILE=${CATALOGS_DIR}/latest/victoriametrics-operator/catalog.yaml
79-
mkdir -p ${CATALOGS_DIR}/latest/victoriametrics-operator
8076
81-
# Save existing catalog as PREV_CATALOG before overwriting
82-
if [ -f "${CATALOG_FILE}" ]; then
83-
cp "${CATALOG_FILE}" /tmp/vm-prev-catalog.yaml
84-
PREV_CATALOG=/tmp/vm-prev-catalog.yaml
85-
fi
77+
export OPERATOR_NAME="victoriametrics-operator"
78+
export OPERATOR_DIR=__operatorhub-repo/operators/${OPERATOR_NAME}
79+
mkdir -p ${OPERATOR_DIR}
8680
87-
PREVIOUS_VERSION=$(yq 'select(.schema == "olm.channel") | .entries[0].name' \
88-
${PREV_CATALOG} 2>/dev/null || true)
81+
NEW_VERSION=$(ls bundle | head -1)
82+
export OLD_VERSION=$(find ${OPERATOR_DIR}/* ! -path "*/catalog-templates" -maxdepth 0 -type d -exec basename {} \; | sort -V -r | head -1)
83+
export OLD_ENTRY="${OPERATOR_NAME}.v${OLD_VERSION}"
8984
90-
opm render bundle/${NEW_VERSION} --output=yaml > /tmp/vm-bundle-rendered.yaml
91-
yq 'select(.schema == "olm.package")' "${PREV_CATALOG}" > /tmp/vm-catalog-header.yaml
92-
echo "---" >> /tmp/vm-catalog-header.yaml
93-
yq '.entries[] | select(.schema == "olm.channel")' \
94-
bundle/${NEW_VERSION}/catalog-templates/latest.yaml >> /tmp/vm-catalog-header.yaml
85+
if [ ! -z $OLD_VERSION ]; then
86+
export MANIFEST_PATH=bundle/${NEW_VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml
87+
yq -i '.spec.replaces = "victoriametrics-operator.v" + strenv(OLD_VERSION)' $MANIFEST_PATH
88+
fi
9589
96-
# Include previous bundles from PREV_CATALOG (excludes current version to avoid duplicates)
97-
yq "select(.schema == \"olm.bundle\" and .name != \"victoriametrics-operator.v${NEW_VERSION}\")" \
98-
"${PREV_CATALOG}" > /tmp/vm-prev-bundles.yaml
99-
yq eval-all '.' /tmp/vm-catalog-header.yaml /tmp/vm-bundle-rendered.yaml /tmp/vm-prev-bundles.yaml > ${CATALOG_FILE}
90+
mv bundle/${NEW_VERSION} ${OPERATOR_DIR}/
91+
if [ -f ${OPERATOR_DIR}/Makefile ]; then
92+
opm render ${OPERATOR_DIR}/${NEW_VERSION} --output=yaml \
93+
| yq 'select(.schema == "olm.bundle")' > /tmp/new-bundle.yaml
10094
101-
if [ -n "${PREVIOUS_VERSION}" ]; then
102-
yq -i '(select(.schema == "olm.channel") | .entries[0]).replaces = strenv(PREVIOUS_VERSION)' ${CATALOG_FILE}
95+
for TEMPLATE in ${OPERATOR_DIR}/catalog-templates/*.yaml; do
96+
PREV_HEAD=$(yq '.entries[] | select(.schema == "olm.channel") | .entries[-1].name' "${TEMPLATE}")
97+
NEW_VERSION="${NEW_VERSION}" PREV_HEAD="${PREV_HEAD}" \
98+
yq -i '(.entries[] | select(.schema == "olm.channel") | .entries) += [{"name": "victoriametrics-operator.v" + strenv(NEW_VERSION), "replaces": strenv(PREV_HEAD)}]' "${TEMPLATE}"
99+
yq -i '.entries += [load("/tmp/new-bundle.yaml")]' "${TEMPLATE}"
100+
done
103101
fi
104-
opm validate ${CATALOGS_DIR}/latest/victoriametrics-operator
105102
106-
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
103+
echo "VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
107104
108105
- name: Create Pull Request
109106
if: ${{ steps.update.outputs.VERSION != '' }}
110107
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
111108
with:
112-
add-paths: catalogs
109+
add-paths: operators/victoriametrics-operator
113110
commit-message: 'victoriametrics-operator: ${{ steps.update.outputs.VERSION }}'
114111
signoff: true
115112
committer: "Github Actions <${{ steps.import-gpg.outputs.email }}>"

Makefile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
274274
$(KUSTOMIZE) build config/base-with-webhook > dist/install-with-webhook.yaml
275275
$(KUSTOMIZE) build config/crd/overlay > dist/crd.yaml
276276

277-
olm: operator-sdk opm yq docs
277+
olm: operator-sdk yq docs
278278
$(eval DIGEST = $(shell $(CONTAINER_TOOL) buildx imagetools inspect $(REGISTRY)/$(ORG)/$(REPO):$(TAG)-ubi --format "{{print .Manifest.Digest}}"))
279-
rm -rf bundle* catalog
279+
rm -rf bundle*
280280
$(OPERATOR_SDK) generate kustomize manifests -q
281281
cd config/manifests && \
282282
$(KUSTOMIZE) edit set image manager=$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)
@@ -286,27 +286,10 @@ olm: operator-sdk opm yq docs
286286
$(OPERATOR_SDK) bundle validate ./bundle/$(VERSION)
287287
$(YQ) -i '.metadata.annotations.containerImage = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | .spec.install.spec.deployments[0].spec.template.containers[0].image = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | .spec.install.spec.deployments[0].spec.template.spec.containers[0].image = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"' \
288288
bundle/$(VERSION)/manifests/victoriametrics-operator.clusterserviceversion.yaml
289-
$(YQ) -i '.annotations."com.redhat.openshift.versions" = "v4.12-v4.21"' \
289+
$(YQ) -i '.annotations."com.redhat.openshift.versions" = "v4.12-v4.22"' \
290290
bundle/$(VERSION)/metadata/annotations.yaml
291-
mkdir -p bundle/$(VERSION)/catalog-templates catalog/latest
292-
$(YQ) '.entries[] | select(.schema == "olm.channel") | .entries[] | select(.name != "victoriametrics-operator.v$(VERSION)") | .name' config/manifests/catalog-templates/latest.yaml > /tmp/vm-prev-names.txt
293-
$(YQ) '.entries[] | select(.schema == "olm.channel") | .entries[] | select(.name != "victoriametrics-operator.v$(VERSION)") | .replaces | select(.)' config/manifests/catalog-templates/latest.yaml > /tmp/vm-prev-replaces.txt
294-
PREV_HEAD=$$(grep -Fxvf /tmp/vm-prev-replaces.txt /tmp/vm-prev-names.txt | head -1); \
295-
test -n "$$PREV_HEAD" || { echo "Error: could not determine previous channel head from catalog template"; exit 1; }; \
296-
PREV_HEAD="$$PREV_HEAD" $(YQ) -i '(.entries[] | select(.schema == "olm.channel")).entries = [{"name": "victoriametrics-operator.v$(VERSION)", "replaces": strenv(PREV_HEAD)}] + (.entries[] | select(.schema == "olm.channel") | .entries | map(select(.name != "victoriametrics-operator.v$(VERSION)")))' \
297-
config/manifests/catalog-templates/latest.yaml; \
298-
PREV_HEAD="$$PREV_HEAD" $(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}] | .spec.replaces = strenv(PREV_HEAD)' \
291+
$(YQ) -i '.spec.relatedImages = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}]' \
299292
bundle/$(VERSION)/manifests/victoriametrics-operator.clusterserviceversion.yaml
300-
cp config/manifests/catalog-templates/latest.yaml bundle/$(VERSION)/catalog-templates/latest.yaml
301-
{ $(YQ) '.entries[] | select(.schema == "olm.package")' \
302-
bundle/$(VERSION)/catalog-templates/latest.yaml; \
303-
echo "---"; \
304-
$(YQ) '(.entries[] | select(.schema == "olm.channel")) | .entries = [.entries[0]]' \
305-
bundle/$(VERSION)/catalog-templates/latest.yaml; \
306-
$(OPM) render bundle/$(VERSION) --output=yaml | \
307-
$(YQ) '(select(.schema == "olm.bundle") | .image) = "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)" | (select(.schema == "olm.bundle") | .relatedImages) = [{"name": "victoriametrics-operator", "image": "$(REGISTRY)/$(ORG)/$(REPO)@$(DIGEST)"}]'; \
308-
} > catalog/latest/catalog.yaml
309-
$(OPM) validate catalog/latest
310293

311294
##@ Deployment
312295

config/manifests/catalog-templates/latest.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)