Skip to content

Commit 2de8000

Browse files
author
Anton
authored
CLOUDP-84352: generate OLM bundle during release process (#160)
1 parent 6f9f33b commit 2de8000

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

.github/actions/gen-install-scripts/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ ENV KUBECTL_VERSION 1.18.12
55
# Install
66
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl -o /usr/bin/kubectl && \
77
chmod +x /usr/bin/kubectl
8+
89
RUN cd /usr/local/bin &&\
910
curl -L https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash
11+
1012
RUN CONTROLLER_GEN_TMP_DIR=$(mktemp -d) && \
1113
cd $CONTROLLER_GEN_TMP_DIR && \
1214
go mod init tmp && \
1315
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 && \
1416
rm -rf $CONTROLLER_GEN_TMP_DIR && \
1517
CONTROLLER_GEN=${GOBIN}/controller-gen
1618

19+
RUN curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.4.2/operator-sdk_linux_amd64 && \
20+
chmod +x operator-sdk_linux_amd64 && \
21+
mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk
22+
1723
# Copies your code file from your action repository to the filesystem path `/` of the container
1824
COPY entrypoint.sh /home/entrypoint.sh
1925
RUN chmod +x /home/entrypoint.sh

.github/actions/gen-install-scripts/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ inputs:
44
IMAGE_URL:
55
description: "Operator image"
66
required: true
7+
VERSION:
8+
description: "Version of the Operator"
9+
required: true
710
ENV:
811
description: "Kustomize patch name (enviroment configuration patch)"
912
required: true

.github/actions/gen-install-scripts/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cd -
1919

2020
which kustomize
2121
kustomize version
22+
2223
# all-in-one
2324
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/allinone" > "${target_dir}/all-in-one.yaml"
2425
echo "Created all-in-one config"
@@ -36,4 +37,13 @@ echo "Created namespaced config"
3637
# crds
3738
cp config/crd/bases/* "${crds_dir}"
3839

40+
# CSV bundle
41+
operator-sdk generate kustomize manifests -q --apis-dir=pkg/api
3942

43+
# We pass the version only for non-dev deployments (it's ok to have "0.0.0" for dev)
44+
if [[ "${INPUT_ENV}" == "dev" ]]; then
45+
kustomize build --load-restrictor LoadRestrictionsNone config/manifests | operator-sdk generate bundle -q --overwrite
46+
else
47+
kustomize build --load-restrictor LoadRestrictionsNone config/manifests | operator-sdk generate bundle -q --overwrite --version "${INPUT_VERSION}"
48+
fi
49+
operator-sdk bundle validate ./bundle

.github/workflows/release-branch.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
uses: ./.github/actions/gen-install-scripts
3131
with:
3232
IMAGE_URL: ${{ env.DOCKER_RELEASE_REPO }}:${{ env.VERSION }}
33+
VERSION: ${{ env.VERSION }}
3334
ENV: prod
3435

3536
- name: Create branch and push it
@@ -44,6 +45,20 @@ jobs:
4445
PATH_TO_COMMIT: "deploy"
4546
DESTINATION_BRANCH: "release/${{ env.VERSION }}"
4647

48+
- name: Commit and push bundle directory
49+
uses: ./.github/actions/push-files
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
PATH_TO_COMMIT: "bundle"
53+
DESTINATION_BRANCH: "release/${{ env.VERSION }}"
54+
55+
- name: Commit and push bundle dockerfile
56+
uses: ./.github/actions/push-files
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
PATH_TO_COMMIT: "bundle.Dockerfile"
60+
DESTINATION_BRANCH: "release/${{ env.VERSION }}"
61+
4762
- name: Create PR
4863
uses: ./.github/actions/create-pr
4964
env:

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
uses: ./.github/actions/gen-install-scripts
9898
with:
9999
IMAGE_URL: ${{ env.DOCKER_REPO }}:${{ steps.prepare.outputs.tag }}
100+
VERSION: ${{ steps.prepare.outputs.tag }}
100101
ENV: dev
101102

102103
- name: Set properties

0 commit comments

Comments
 (0)