Skip to content

Commit

Permalink
Store replaces version in file
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Nov 24, 2023
1 parent c54b427 commit ded5c1f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.sha }}
- name: Run make bundle (release)
if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }}
run: make bundle fix-csv-replaces REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} VERSION=${TAG_NAME/v/} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} CHANNELS=${{ github.event.inputs.channels }} DEFAULT_CHANNEL=stable
run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} VERSION=${TAG_NAME/v/} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} CHANNELS=${{ github.event.inputs.channels }} DEFAULT_CHANNEL=stable
- name: Git diff
run: git diff
- name: Verify manifests and bundle (main)
Expand Down
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ AUTHORINO_BRANCH = v$(AUTHORINO_VERSION)
AUTHORINO_IMAGE_TAG = v$(AUTHORINO_VERSION)
endif

AUTHORINO_IMAGE_FILE ?= authorino_image
DEFAULT_AUTHORINO_IMAGE ?= $(shell cat $(AUTHORINO_IMAGE_FILE) || echo $(DEFAULT_REGISTRY)/$(DEFAULT_ORG)/authorino:latest)
BUILD_CONFIG_FILE ?= build.yaml
DEFAULT_AUTHORINO_IMAGE ?= $(shell yq e -e '.config.authorinoImage' $(BUILD_CONFIG_FILE) || echo $(DEFAULT_REGISTRY)/$(DEFAULT_ORG)/authorino:latest)

all: build

Expand Down Expand Up @@ -243,6 +243,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
< config/manifests/bases/authorino-operator.clusterserviceversion.template.yaml \
> config/manifests/bases/authorino-operator.clusterserviceversion.yaml
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS) --package authorino-operator
($(YQ) e -e '.config.replaces' $(BUILD_CONFIG_FILE) && V="$(shell $(YQ) e -e '.config.replaces' $(BUILD_CONFIG_FILE))" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml) || echo "no replaces added"
$(OPERATOR_SDK) bundle validate ./bundle
# Roll back edit
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE}
Expand All @@ -255,22 +256,29 @@ bundle-build: ## Build the bundle image.
bundle-push: ## Push the bundle image.
$(MAKE) docker-push OPERATOR_IMAGE=$(BUNDLE_IMG)

.PHONY: fix-csv-replaces
fix-csv-replaces: $(YQ)
.PHONY: create-build-file
create-build-file: $(YQ)
$(YQ) -n '.config' > $(BUILD_CONFIG_FILE)

.PHONY: set-authorino-default-image
set-authorino-default-image: $(YQ)
@if [ "$(AUTHORINO_VERSION)" != "latest" ]; then\
V="$(DEFAULT_REGISTRY)/$(DEFAULT_ORG)/authorino:$(AUTHORINO_IMAGE_TAG)" $(YQ) eval '.config.authorinoImage = strenv(V)' -i $(BUILD_CONFIG_FILE); \
fi

.PHONY: set-replaces-directive
set-replaces-directive: $(YQ)
$(eval REPLACES_VERSION=$(shell curl -sSL -H "Accept: application/vnd.github+json" \
https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \
jq -r '.name'))
V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml
V="authorino-operator.$(REPLACES_VERSION)" $(YQ) e -i '.config.replaces = strenv(V)' $(BUILD_CONFIG_FILE)

.PHONY: prepare-release
prepare-release:
$(MAKE) create-build-file
$(MAKE) set-authorino-default-image
$(MAKE) set-replaces-directive
$(MAKE) manifests bundle VERSION=$(VERSION) AUTHORINO_VERSION=$(AUTHORINO_VERSION)
@if [ "$(AUTHORINO_VERSION)" = "latest" ]; then\
[ ! -e "$(AUTHORINO_IMAGE_FILE)" ] || rm $(AUTHORINO_IMAGE_FILE); \
else \
echo quay.io/kuadrant/authorino:$(AUTHORINO_IMAGE_TAG) > $(AUTHORINO_IMAGE_FILE); \
fi
$(MAKE) fix-csv-replaces

# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
# These images MUST exist in a registry and be pull-able.
Expand Down

0 comments on commit ded5c1f

Please sign in to comment.