Skip to content

Commit

Permalink
patch operator manifests before the release
Browse files Browse the repository at this point in the history
Ensure that operator manifests are pointing to the right tag/version
before pushing a new tag.

Signed-off-by: Feruzjon Muyassarov <[email protected]>
  • Loading branch information
fmuyassarov authored and klihub committed Jan 17, 2024
1 parent 0b8598b commit c65f374
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 52 deletions.
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/new-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ future releases.
- [ ] Sync/tidy up dependencies.
- [ ] Run `go mod tidy`.
- [ ] Run `git commit -m 'go.mod,go.sum: update dependencies.' go.{mod,sum}`, if necessary.
- [ ] Update deployment files
- [ ] run `hack/release-helper.sh`
- [ ] commit changes, submit as a PR to GitHub
- [ ] wait for the PR to be merged
- [ ] Run `git tag -a -m "NRI plugins $VERSION" $VERSION`.
- Publishing
- [ ] Push the tag with `git push $VERSION`.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/package-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

- name: Package Helm charts
run: |
find "$CHARTS_DIR" -name values.yaml | xargs -I '{}' \
sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" -i '{}'
helm package --version "$GITHUB_REF_NAME" --app-version "$GITHUB_REF_NAME" "$CHARTS_DIR"/*
find . -name '*.tgz' -print | while read SRC_FILE; do
DEST_FILE=$(echo $SRC_FILE | sed 's/v/helm-chart-v/g')
Expand Down
33 changes: 21 additions & 12 deletions deployment/operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endif
OPERATOR_SDK_VERSION ?= v1.32.0

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):$(IMAGE_VERSION)
IMAGE ?= $(IMAGE_TAG_BASE):$(IMAGE_VERSION)

# (Default) operator image dockerfile and bundle image dockerfile.
DOCKERFILE ?= Dockerfile
Expand Down Expand Up @@ -94,31 +94,37 @@ endif
endif

.PHONY: bundle
bundle: copy-crds kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
bundle: copy-crds kustomize operator-sdk kustomizations ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE)
find config/manifests/bases -name nri-plugins-operator.clusterserviceversion.yaml | xargs -I '{}' \
sed -e "s|containerImage:.*|containerImage: $(IMAGE)|" -i '{}';
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(MAKE) bundle-validate
$(MAKE) cleanup-crds

.PHONY: bundle-validate
bundle-validate:
$(OPERATOR_SDK) bundle validate ./bundle \
--select-optional name=operatorhub \
--select-optional suite=operatorframework \
--select-optional name=good-practices \
--select-optional suite=operatorframework; \
$(MAKE) cleanup-crds;
--select-optional suite=operatorframework

.PHONY:
docker-build:
docker build -f $(DOCKERFILE) -t ${IMG} .
docker build -f $(DOCKERFILE) -t ${IMAGE} .

.PHONY: docker-push
docker-push:
docker push ${IMG}
docker push ${IMAGE}

.PHONY: docker-save
docker-save: docker-build
@img_name="${IMG}"; \
@img_name="${IMAGE}"; \
img_name="$${img_name##*/}"; \
img_name="$${img_name%:*}"; \
img_info=`docker images --filter=reference=${IMG} --format '{{.ID}} {{.Repository}}:{{.Tag}} (created {{.CreatedSince}}, {{.CreatedAt}})' | head -n 1`; \
img_info=`docker images --filter=reference=${IMAGE} --format '{{.ID}} {{.Repository}}:{{.Tag}} (created {{.CreatedSince}}, {{.CreatedAt}})' | head -n 1`; \
img_id=`awk '{print $$1}' <<< "$${img_info}"`; \
img_tag=`awk '{print $$2}' <<< "$${img_info}"`; \
img_tar=`realpath "$(IMAGE_PATH)/$${img_name}-image-$${img_id}.tar"`; \
Expand Down Expand Up @@ -161,7 +167,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMAGE} -f Dockerfile.cross .
- docker buildx rm project-v3-builder
rm Dockerfile.cross

Expand All @@ -177,7 +183,7 @@ uninstall: copy-crds kustomize ## Uninstall CRDs from the K8s cluster specified

.PHONY: deploy
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE}
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
Expand Down Expand Up @@ -237,7 +243,10 @@ cleanup-crds: ## Clean up temporarily copied CRDs and CRs.
rm -f $(SAMPLE_DEST_DIR)/noderesourcetopology.yaml

.PHONY: kustomizations
kustomizations: config/manager/kustomization.yaml
kustomizations: config/manager/kustomization.yaml config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml

config/manager/kustomization.yaml: config/manager/kustomization.yaml.in
@cp $< $@

config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml: config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml.in
@cp $< $@
36 changes: 0 additions & 36 deletions hack/release-helper.sh

This file was deleted.

0 comments on commit c65f374

Please sign in to comment.