Skip to content

Commit

Permalink
Add a workflow to automate config connector release bundle creation
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweim committed Feb 4, 2025
1 parent cab0d4e commit 2b489cb
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 25 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release-automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Config Connector Release Automation

on:
push:
tags:
- 'v*'

jobs:
create-and-push-release-bundle:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: Run the create-relese-bundle script
run: |
chmod +x ./scripts/github-actions/create-release-bundle.sh
./scripts/github-actions/create-release-bundle.sh
24 changes: 5 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -323,32 +323,18 @@ all-manifests: crd-manifests rbac-manifests build-operator-manifests

# Build kcc manifests for standard GKE clusters
.PHONY: config-connector-manifests-standard
config-connector-manifests-standard: build-crd-manifests build-rbac-manifests build-operator-manifests
cp config/installbundle/release-manifests/crds.yaml config/installbundle/release-manifests/standard/crds.yaml
cp config/installbundle/release-manifests/rbac.yaml config/installbundle/release-manifests/standard/rbac.yaml
kustomize build config/installbundle/release-manifests/standard -o config/installbundle/release-manifests/standard/manifests.yaml
config-connector-manifests-standard: build-operator-manifests
kustomize build config/installbundle/release-manifests/standard

# Build kcc manifests for autopilot clusters
.PHONY: config-connector-manifests-autopilot
config-connector-manifests-autopilot: build-crd-manifests build-rbac-manifests build-operator-manifests
cp config/installbundle/release-manifests/crds.yaml config/installbundle/release-manifests/autopilot/crds.yaml
cp config/installbundle/release-manifests/rbac.yaml config/installbundle/release-manifests/autopilot/rbac.yaml
kustomize build config/installbundle/release-manifests/autopilot -o config/installbundle/release-manifests/autopilot/manifests.yaml

.PHONY: build-crd-manifests
build-crd-manifests:
go run sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 crd paths="./operator/pkg/apis/..." output:crd:artifacts:config=operator/config/crd/bases
kustomize build operator/config/crd -o config/installbundle/release-manifests/crds.yaml

.PHONY: build-rbac-manifests
build-rbac-manifests:
kustomize build operator/config/rbac -o config/installbundle/release-manifests/rbac.yaml
config-connector-manifests-autopilot: build-operator-manifests
kustomize build config/installbundle/release-manifests/autopilot

.PHONY: build-operator-manifests
build-operator-manifests:
go run sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 crd paths="./operator/pkg/apis/..." output:crd:artifacts:config=operator/config/crd/bases
make -C operator docker-build
kustomize build operator/config/autopilot-manager -o config/installbundle/release-manifests/autopilot/manager.yaml
kustomize build operator/config/manager -o config/installbundle/release-manifests/standard/manager.yaml

.PHONY: push-operator-manifest
push-operator-manifest:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ commonLabels:
commonAnnotations:
cnrm.cloud.google.com/operator-version: "1.128.0"
resources:
- crds.yaml
- rbac.yaml
- manager.yaml
- ../../../../operator/config/rbac
- ../../../../operator/config/crd
- ../../../../operator/config/manager
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ commonLabels:
commonAnnotations:
cnrm.cloud.google.com/operator-version: "1.128.0"
resources:
- crds.yaml
- rbac.yaml
- manager.yaml
- ../../../../operator/config/rbac
- ../../../../operator/config/crd
- ../../../../operator/config/manager
72 changes: 72 additions & 0 deletions dev/tasks/deploy-release-manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

# runs the config-connector build across all desired systems and architectures and creates a release tarball
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd ${REPO_ROOT}


BUILD_DIR="${REPO_ROOT}/.build"
mkdir -p "${BUILD_DIR}"


MANUAL_DIR="${BUILD_DIR}/manual-release"
mkdir -p "${MANUAL_DIR}/operator-system"

# Find the version of the operator image
FOLDER_PATH="${REPO_ROOT}/operator/channels/packages/configconnector"

if [ ! -d "$FOLDER_PATH" ]; then
echo "Error: Directory $FOLDER_PATH does not exist"
exit 1
fi

# List all directories in the specified path and store them in an array
VERSIONS=($(ls -d "$FOLDER_PATH"/*/ 2>/dev/null | xargs -n 1 basename | sort -V))

if [ ${#VERSIONS[@]} -eq 0 ]; then
echo "Error: No version directories found in $FOLDER_PATH"
exit 1
fi

LATEST_VERSION="${VERSIONS[-1]}"
OPERATOR_IMG=gcr.io/gke-release/cnrm/operator:${LATEST_VERSION}

echo "Updating kustomize image patch file for manager."
cp ${REPO_ROOT}/operator/config/manager/manager_image_patch_template.yaml ${REPO_ROOT}/operator/config/manager/manager_image_patch.yaml
sed -i'' -e 's@image: .*@image: '"${OPERATOR_IMG}"'@' ${REPO_ROOT}/operator/config/manager/manager_image_patch.yaml
cp -f ${REPO_ROOT}/operator/config/autopilot-manager/manager_image_patch_template.yaml ${REPO_ROOT}/operator/config/autopilot-manager/manager_image_patch.yaml
sed -i'' -e 's@image: .*@image: '"${OPERATOR_IMG}"'@' ${REPO_ROOT}/operator/config/autopilot-manager/manager_image_patch.yaml

kustomize build ${REPO_ROOT}/config/installbundle/release-manifests/standard -o ${MANUAL_DIR}/operator-system/configconnector-operator.yaml
echo "Added standard release manifest to ${MANUAL_DIR}/operator-system/configconnector-operator.yaml"

kustomize build ${REPO_ROOT}/config/installbundle/release-manifests/autopilot -o ${MANUAL_DIR}/operator-system/autopilot-configconnector-operator.yaml
echo "Added autopilot release manifest to ${MANUAL_DIR}/operator-system/autopilot-configconnector-operator.yaml"

cp -rf operator/config/samples ${MANUAL_DIR}/

tar -czvf ${BUILD_DIR}/release-bundle.tar.gz -C ${MANUAL_DIR}/ .

echo "Generated ${BUILD_DIR}/release-bundle.tar.gz for manual installation."

gsutil cp ${REPO_ROOT}/.build/release-bundle.tar.gz gs://configconnector-operator/${LATEST_VERSION}/
gsutil cp ${REPO_ROOT}/.build/release-bundle.tar.gz gs://configconnector-operator/latest

echo "Pushed the latest release-bundle."
26 changes: 26 additions & 0 deletions scripts/github-actions/create-release-bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

echo "Start creating the release bundle"

REPO_ROOT="$(git rev-parse --show-toplevel)"

# build release manifest
source ${REPO_ROOT}/dev/tasks/deploy-release-manifest

0 comments on commit 2b489cb

Please sign in to comment.