Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release process/workflow #1150

Open
wants to merge 5 commits into
base: release-process-enhancement
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/release-changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release Operator

on:
pull_request:
types:
- opened
branches:
- 'release-v[0-9]+.[0-9]+'

jobs:
build:
name: Release canidate
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22.x
uses: actions/setup-go@v4
with:
go-version: 1.22.x
id: go
- name: Checkout code at git ref
uses: actions/checkout@v4
- name: Check bundles and manifests
run: make verify-prepare-release
84 changes: 15 additions & 69 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,88 +1,34 @@
name: Release Operator

on:
workflow_dispatch:
inputs:
gitRef:
description: Commit SHA, tag or branch name
required: true
kuadrantOperatorVersion:
description: Kuadrant Operator version
default: 0.0.0
type: string
authorinoOperatorVersion:
description: Authorino Operator bundle version
default: 0.0.0
type: string
limitadorOperatorVersion:
description: Limitador Operator bundle version
default: 0.0.0
type: string
dnsOperatorVersion:
description: DNS Operator bundle version
default: 0.0.0
type: string
wasmShimVersion:
description: WASM Shim version
default: 0.0.0
type: string
consolePluginImageURL:
description: ConsolePlugin image URL
default: "quay.io/kuadrant/console-plugin:latest"
type: string
prerelease:
description: Is the release a pre-release?
required: false
type: boolean
pull_request:
types:
- closed
branches:
- 'release-v[0-9]+.[0-9]+'

jobs:
build:
if_merged:
if: github.event.pull_request.merged == true
name: Release operator
runs-on: ubuntu-latest
steps:
# TODO: not sure if the `Install gettext-base`is still required
- name: Install gettext-base
run: |
sudo apt-get update
sudo apt-get install -y gettext-base
- name: Set up Go 1.21.x
uses: actions/setup-go@v4
with:
go-version: 1.21.x
id: go
- name: Checkout code at git ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.gitRef }}
token: ${{ secrets.KUADRANT_DEV_PAT }}
- name: Create release branch
if: ${{ !startsWith(inputs.gitRef, 'release-v') }}
- name: Set envoironment variables
run: |
git checkout -b release-v${{ inputs.kuadrantOperatorVersion }}
- name: Prepare release
run: |
make prepare-release \
VERSION=${{ inputs.kuadrantOperatorVersion }} \
AUTHORINO_OPERATOR_VERSION=${{ inputs.authorinoOperatorVersion }} \
LIMITADOR_OPERATOR_VERSION=${{ inputs.limitadorOperatorVersion }} \
DNS_OPERATOR_VERSION=${{ inputs.dnsOperatorVersion }} \
WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }} \
RELATED_IMAGE_CONSOLEPLUGIN=${{ inputs.consolePluginImageURL }}
- name: Commit and push
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Prepared release v${{ inputs.kuadrantOperatorVersion }}"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
branch: release-v${{ inputs.kuadrantOperatorVersion }}
create_branch: true
tagging_message: v${{ inputs.kuadrantOperatorVersion }}
commit_options: '--signoff'
bash ./hack/release/load_envvar.sh
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: v${{ inputs.kuadrantOperatorVersion }}
tag_name: v${{ inputs.kuadrantOperatorVersion }}
body: "**This release enables installations of Authorino Operator v${{ inputs.authorinoOperatorVersion }}, Limitador Operator v${{ inputs.limitadorOperatorVersion }}, DNS Operator v${{ inputs.dnsOperatorVersion }}, WASM Shim v${{ inputs.wasmShimVersion }} and ConsolePlugin ${{ inputs.consolePluginImageURL }}**"
name: v${{ kuadrantOperatorVersion }}
tag_name: v${{ kuadrantOperatorVersion }}
body: "${{ releaseBody }}"
generate_release_notes: true
target_commitish: release-v${{ github.event.inputs.kuadrantOperatorVersion }}
prerelease: ${{ github.event.inputs.prerelease }}
target_commitish: release-v${{ kuadrantOperatorVersion }}
prerelease: ${{ prerelease }}
36 changes: 3 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ else
GOBIN=$(shell go env GOBIN)
endif

RELEASE_FILE = $(PROJECT_PATH)/make/release.mk

# Kuadrant Namespace
KUADRANT_NAMESPACE ?= kuadrant-system
OPERATOR_NAMESPACE ?= $(KUADRANT_NAMESPACE)
Expand Down Expand Up @@ -447,37 +445,9 @@ bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)

.PHONY: prepare-release
prepare-release: ## Prepare the manifests for OLM and Helm Chart for a release.
echo -e "#Release default values\\n\
AUTHORINO_OPERATOR_VERSION=$(AUTHORINO_OPERATOR_VERSION)\\n\
AUTHORINO_OPERATOR_BUNDLE_IMG=$(AUTHORINO_OPERATOR_BUNDLE_IMG)\\n\
LIMITADOR_OPERATOR_VERSION=$(LIMITADOR_OPERATOR_VERSION)\\n\
LIMITADOR_OPERATOR_BUNDLE_IMG=$(LIMITADOR_OPERATOR_BUNDLE_IMG)\\n\
DNS_OPERATOR_VERSION=$(DNS_OPERATOR_VERSION)\\n\
DNS_OPERATOR_BUNDLE_IMG=$(DNS_OPERATOR_BUNDLE_IMG)\\n\
WASM_SHIM_VERSION=$(WASM_SHIM_VERSION)\\n\
RELATED_IMAGE_WASMSHIM=$(RELATED_IMAGE_WASMSHIM)\\n\
RELATED_IMAGE_CONSOLEPLUGIN=$(RELATED_IMAGE_CONSOLEPLUGIN)\\n\
IMG=$(IMG)\\n\
BUNDLE_VERSION=$(BUNDLE_VERSION)\\n\
BUNDLE_IMG=$(BUNDLE_IMG)\\n\
CATALOG_IMG=$(CATALOG_IMG)\\n\
CHANNELS=$(CHANNELS)\\n\
BUNDLE_CHANNELS=--channels=$(CHANNELS)\\n\
VERSION=$(VERSION)" > $(RELEASE_FILE)
$(MAKE) bundle VERSION=$(VERSION) \
AUTHORINO_OPERATOR_VERSION=$(AUTHORINO_OPERATOR_VERSION) \
LIMITADOR_OPERATOR_VERSION=$(LIMITADOR_OPERATOR_VERSION) \
DNS_OPERATOR_VERSION=$(DNS_OPERATOR_VERSION) \
WASM_SHIM_VERSION=$(WASM_SHIM_VERSION) \
RELATED_IMAGE_CONSOLEPLUGIN=$(RELATED_IMAGE_CONSOLEPLUGIN) \
$(MAKE) helm-build VERSION=$(VERSION) \
AUTHORINO_OPERATOR_VERSION=$(AUTHORINO_OPERATOR_VERSION) \
LIMITADOR_OPERATOR_VERSION=$(LIMITADOR_OPERATOR_VERSION) \
DNS_OPERATOR_VERSION=$(DNS_OPERATOR_VERSION) \
WASM_SHIM_VERSION=$(WASM_SHIM_VERSION) \
RELATED_IMAGE_CONSOLEPLUGIN=$(RELATED_IMAGE_CONSOLEPLUGIN)
$(MAKE) update-catalogsource CATALOG_IMG=$(CATALOG_IMG)
prepare-release: $(YQ) $(CONTROLLER_GEN) $(OPM) $(KUSTOMIZE) $(OPERATOR_SDK) ## Prepare the manifests for OLM and Helm Chart for a release.
PATH=$(PROJECT_PATH)/bin:$$PATH; $(PROJECT_PATH)/hack/release/release.sh


.PHONY: bundle-operator-image-url
bundle-operator-image-url: $(YQ) ## Read operator image reference URL from the manifest bundle.
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions hack/release/dependencies/dependencies-manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

authorino_version=v$(yq '.dependencies.Authorino' $env/release.toml)
dns_version=v$(yq '.dependencies.DNS' $env/release.toml)
limitador_version=v$(yq '.dependencies.Limitador' $env/release.toml)

AUTHORINO_OPERATOR_GITREF=$authorino_version envsubst < $env/config/dependencies/authorino/kustomization.template.yaml > $env/config/dependencies/authorino/kustomization.yaml

DNS_OPERATOR_GITREF=$dns_version envsubst < $env/config/dependencies/dns/kustomization.template.yaml > $env/config/dependencies/dns/kustomization.yaml

LIMITADOR_OPERATOR_GITREF=$limitador_version envsubst < $env/config/dependencies/limitador/kustomization.template.yaml > $env/config/dependencies/limitador/kustomization.yaml
3 changes: 3 additions & 0 deletions hack/release/dependencies/manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
controller-gen crd paths="$env/api/v1beta1;$env/api/v1" output:crd:artifacts:config=$env/config/crd/bases
controller-gen rbac:roleName=manager-role webhook paths="$env/..."
60 changes: 60 additions & 0 deletions hack/release/load_envvar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

if [[ -z "${ROOT}" ]]; then
echo "[WARNING] env var ROOT not set, using $(pwd)"
ROOT=$(pwd)
fi

dry_run="0"
_log="0"

while [[ $# -gt 0 ]]; do
echo "ARG: \"$1\""
if [[ "$1" == "--dry_run" ]]; then
dry_run="1"
elif [[ "$1" == "--echo" ]]; then
_log="1"
else
grep="$1"
fi
shift
done

log() {
if [[ $dry_run == "1" ]]; then
echo "[DRY_RUN]: $1"
else
echo "$1"
fi
}

log "Loading Environment Variables"

authorinoOperatorVersion=$(yq '.dependencies.Authorino' $ROOT/release.toml)
consolePluginURL=$(yq '.dependencies.Console_plugin' $ROOT/release.toml)
dnsOperatorVersion=$(yq '.dependencies.DNS' $ROOT/release.toml)
limitadorOperatorVersion=$(yq '.dependencies.Limitador' $ROOT/release.toml)
wasmShimVersion=$(yq '.dependencies.Wasm_shim' $ROOT/release.toml)

releaseBody="**This release enables installations of Authorino Operator v$authorinoOperatorVersion, Limitador Operator v$limitadorOperatorVersion, DNS Operator v$dnsOperatorVersion, WASM Shim v$wasmShimVersion and ConsolePlugin $consolePluginURL**"

kuadrantOperatorVersion=$(yq '.kuadrant.release' $ROOT/release.toml)

prerelease=false
if [[ "$kuadrantOperatorVersion" == *"-"* ]]; then
prerelease=true
fi

if [[ $_log == "1" ]]; then
log $kuadrantOperatorVersion
log "$releaseBody"
log $prerelease
fi

if [[ $dry_run == "0" ]]; then
echo "kuadrantOperatorVersion=$kuadrantOperatorVersion" >> "$GITHUB_ENV"
echo "releaseBody=$releaseBody" >> "$GITHUB_ENV"
echo "prerelease=$prerelease" >> "$GITHUB_ENV"
fi
Empty file.
83 changes: 83 additions & 0 deletions hack/release/operator/make_bundles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

echo "make bundle"
root=$(pwd)
cd $env
operator-sdk generate kustomize manifests --interactive=false

# Set desired Wasm-shim image
wasm_shim=$(yq '.dependencies.Wasm_shim' $env/release.toml)
V="oci://quay.io/kuadrant/wasm-shim:v$wasm_shim" \
yq eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' --inplace config/manager/manager.yaml

# Set desired ConsolePlugin image
console_plugin=$(yq '.dependencies.Console_plugin' $env/release.toml)
V="quay.io/kuadrant/console-plugin:v$console_plugin" \
yq eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_CONSOLEPLUGIN").value) = strenv(V)' --inplace config/manager/manager.yaml

# Set desired operator image
cd $env/config/manager
# FIX: for the minute the values for the org and registry are hardcoded into the operator image.
# This should not be the case.

operator_version=$(yq '.kuadrant.release' $env/release.toml)
operator_image=quay.io/kuadrant/kuadrant-operator:v$operator_version
kustomize edit set image controller=$operator_image

csv=$env/config/manifests/bases/kuadrant-operator.clusterserviceversion.yaml
V="kuadrant-operator.v$operator_version" yq eval '.metadata.name = strenv(V)' --inplace $csv
V="$operator_version" yq eval '.spec.version = strenv(V)' --inplace $csv
V="$operator_image" yq eval '.metadata.annotations.containerImage = strenv(V)' --inplace $csv

cd -

channels=$(yq -oy '.kuadrant.channels | join(",")' $env/release.toml)
default_channel=$(yq '.kuadrant.default_channel' $env/release.toml)
kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version $operator_version --channels $channels --default-channel $default_channel

openshift_version_annotation_key="com.redhat.openshift.versions"
# Supports Openshift v4.12+ (https://redhat-connect.gitbook.io/certified-operator-guide/ocp-deployment/operator-metadata/bundle-directory/managing-openshift-versions)
openshift_supported_versions="v4.12"
key=$openshift_version_annotation_key value=$openshift_supported_versions yq --inplace '.annotations[strenv(key)] = strenv(value)' bundle/metadata/annotations.yaml
key=$openshift_version_annotation_key yq --inplace '(.annotations[strenv(key)] | key) headComment = "Custom annotations"' bundle/metadata/annotations.yaml

echo "reading data form quay.io, slow process."
dep_file="$env/bundle/metadata/dependencies.yaml"

limitador_version=$(yq '.dependencies.Limitador' $env/release.toml)
limitador_image=quay.io/kuadrant/limitador-operator-bundle:v$limitador_version
V=$(opm render $limitador_image | yq eval '.properties[] | select(.type == "olm.package") | .value.version' -)

COMPONENT=limitador-operator V=$V \
yq eval '(.dependencies[] | select(.value.packageName == strenv(COMPONENT)).value.version) = strenv(V)' -i $dep_file


authorino_version=$(yq '.dependencies.Authorino' $env/release.toml)
authorino_image=quay.io/kuadrant/authorino-operator-bundle:v$authorino_version
V=$(opm render $authorino_image | yq eval '.properties[] | select(.type == "olm.package") | .value.version' -)

COMPONENT=authorino-operator V=$V \
yq eval '(.dependencies[] | select(.value.packageName == strenv(COMPONENT)).value.version) = strenv(V)' -i $dep_file


dns_version=$(yq '.dependencies.DNS' $env/release.toml)
dns_image=quay.io/kuadrant/dns-operator-bundle:v$dns_version
V=$(opm render $dns_image | yq eval '.properties[] | select(.type == "olm.package") | .value.version' -)

COMPONENT=dns-operator V=$V \
yq eval '(.dependencies[] | select(.value.packageName == strenv(COMPONENT)).value.version) = strenv(V)' -i $dep_file
echo "finished reading data form quay.io, slow."

operator-sdk bundle validate $env/bundle
git diff --quiet -I'^ createdAt: ' ./bundle && git checkout ./bundle || true

quay_expiry_time_label="
# Quay image expiry
ARG QUAY_IMAGE_EXPIRY
ENV QUAY_IMAGE_EXPIRY=\${QUAY_IMAGE_EXPIRY:-never}
LABEL quay.expires-after=\${QUAY_IMAGE_EXPIRY}
"
echo -en "$quay_expiry_time_label" >> bundle.Dockerfile

# exit script and return to initail directory
cd $root
31 changes: 31 additions & 0 deletions hack/release/operator/make_helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Set desired Wasm-shim image
wasm_shim_version=$(yq '.dependencies.Wasm_shim' $env/release.toml)
wasm_shim_image="oci://quay.io/kuadrant/wasm-shim:v$wasm_shim_version"
V=$wasm_shim_image \
yq eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_WASMSHIM").value) = strenv(V)' --inplace $env/config/manager/manager.yaml

# Set desired ConsolePlugin image
consoleplugin_version=$(yq '.dependencies.Console_plugin' $env/release.toml)
consoleplugin_image="quay.io/kuadrant/console-plugin:v$consoleplugin_version"
V=$consoleplugin_image \
yq eval '(select(.kind == "Deployment").spec.template.spec.containers[].env[] | select(.name == "RELATED_IMAGE_CONSOLEPLUGIN").value) = strenv(V)' --inplace $env/config/manager/manager.yaml

# Set desired operator image
cd $env/config/manager
operator_version=$(yq '.kuadrant.release' $env/release.toml)
operator_image=quay.io/kuadrant/kuadrant-operator:v$operator_version
kustomize edit set image controller=$operator_image
cd -

# Build the helm chart templates from kustomize manifests
kustomize build $env/config/helm > $env/charts/kuadrant-operator/templates/manifests.yaml

# Set the helm chart version and dependencies versions
operator_version=$(yq '.kuadrant.release' $env/release.toml)
V="$(yq '.kuadrant.release' $env/release.toml)" yq --inplace eval '.version = strenv(V)' $env/charts/kuadrant-operator/Chart.yaml
V="$(yq '.kuadrant.release' $env/release.toml)" yq --inplace eval '.appVersion = strenv(V)' $env/charts/kuadrant-operator/Chart.yaml
V="$(yq '.dependencies.Authorino' $env/release.toml)" yq --inplace eval '(.dependencies[] | select(.name == "authorino-operator").version) = strenv(V)' $env/charts/kuadrant-operator/Chart.yaml
V="$(yq '.dependencies.Limitador' $env/release.toml)" yq --inplace eval '(.dependencies[] | select(.name == "limitador-operator").version) = strenv(V)' $env/charts/kuadrant-operator/Chart.yaml
V="$(yq '.dependencies.DNS' $env/release.toml)" yq --inplace eval '(.dependencies[] | select(.name == "dns-operator").version) = strenv(V)' $env/charts/kuadrant-operator/Chart.yaml
4 changes: 4 additions & 0 deletions hack/release/operator/update_catalog_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

v=quay.io/kuadrant/kuadrant-operator-catalog:v$(yq '.kuadrant.release' $env/release.toml) \
yq eval --inplace '.spec.image = strenv(v)' $env/config/deploy/olm/catalogsource.yaml
Empty file.
Empty file.
Loading
Loading