🏷️ Release operator and create branches to add new operators versions to repositories for Kubernetes and Openshift #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🏷️ Release operator and create branches to add new operators versions to repositories for Kubernetes and Openshift | |
on: | |
workflow_dispatch: | |
inputs: | |
default_bump: | |
type: choice | |
description: | | |
Define what kind of bump you want | |
options: | |
- major | |
- minor | |
- patch | |
required: true | |
operator_version: | |
type: string | |
description: | | |
Define the operator version | |
required: true | |
replace_operator_version: | |
type: string | |
description: | | |
Define the operator version to replace | |
required: true | |
supported_openshift_range: | |
type: string | |
description: | | |
The supported Openshift version range. This could be a single version, like for example v4.13 or v4.9-v4.13 as a range | |
required: false | |
default: v4.13 | |
latest: | |
required: true | |
description: | | |
Define if we want to tag the image as latest too | |
type: boolean | |
jobs: | |
build-and-push: | |
permissions: | |
contents: write | |
env: | |
VERSION: ${{ github.event.inputs.operator_version }} | |
USE_IMAGE_DIGESTS: true | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Build" | |
run: make build | |
- name: "Test" | |
run: make test | |
- name: "Set up Go" | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
check-latest: true | |
- name: "Login to Container registry" | |
uses: docker/login-action@v3 | |
with: | |
registry: "quay.io" | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Set versions | |
run: | | |
export INPUT_VERSION="${{ github.event.inputs.operator_version }}" | |
export C_VERSION="${INPUT_VERSION#v}" | |
echo "VERSION=${C_VERSION}" >> $GITHUB_ENV | |
echo "IMG_VERSION=${C_VERSION}" >> $GITHUB_ENV | |
- name: "Set Up Crane" | |
run: | | |
make crane | |
- name: "Build Container Image" | |
run: | | |
export IMAGE_DIGEST=$(bin/crane digest quay.io/kaotoio/kaoto-app:stable) | |
export KAOTO_APP_IMAGE="quay.io/kaotoio/kaoto-app@${IMAGE_DIGEST}" | |
make docker-build | |
make docker-push | |
- name: "Tag Container Image as latest" | |
if: ${{ inputs.latest }} | |
run: | | |
docker tag quay.io/kaotoio/kaoto-operator:${VERSION} quay.io/kaotoio/kaoto-operator:latest | |
docker push quay.io/kaotoio/kaoto-operator:latest | |
- name: "Build OLM bundle" | |
run: | | |
make bundle | |
- name: Checking Diff | |
run: | | |
if [[ `git status --porcelain` ]]; then | |
echo "OK: Changes detected." | |
echo "OK: Showing changes." | |
git diff | |
else | |
echo "WARNING: No changes were detected." | |
fi | |
- name: "🔧 Enrich Bundle" | |
shell: bash | |
run: | | |
cd bundle/manifests | |
echo " replaces: kaoto-operator.v${{ github.event.inputs.replace_operator_version }}" >> kaoto-operator.clusterserviceversion.yaml | |
- name: "🔧 Tar bundle" | |
shell: bash | |
run: | | |
tar -czf ${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz -C bundle . | |
ls -lh ${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz | |
- name: "🔧 Persist Bundle" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "bundle-${{ github.event.inputs.operator_version }}.tgz" | |
path: "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" | |
retention-days: 1 | |
tag-and-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "🛰️ Download Bundle" | |
uses: actions/download-artifact@v4 | |
with: | |
name: bundle-${{ github.event.inputs.operator_version }}.tgz | |
path: "${{ runner.temp }}" | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ github.event.inputs.tag_version }} | |
create_annotated_tag: true | |
tag_prefix: "v" | |
- name: Create a GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: Release ${{ steps.tag_version.outputs.new_tag }} | |
artifacts: "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" | |
prepare-k8s-operator-branch: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push | |
- tag-and-release | |
steps: | |
- name: "Checkout Operarot" | |
uses: actions/checkout@v4 | |
- name: "Checkout k8s-operator project" | |
uses: actions/checkout@v4 | |
with: | |
repository: KaotoIO/community-operators | |
token: ${{ secrets.KAOTO_CI_TOKEN }} | |
path: community-operators | |
ref: main | |
- name: "🛰️ Download Bundle" | |
uses: actions/download-artifact@v4 | |
with: | |
name: bundle-${{ github.event.inputs.operator_version }}.tgz | |
path: "${{ runner.temp }}" | |
- name: "Create, prepare branch and open PR for k8s-operator" | |
env: | |
BRANCH_NAME: "kaoto-operator.${{ github.event.inputs.operator_version }}" | |
GH_TOKEN: ${{ secrets.KAOTO_CI_TOKEN }} | |
run: | | |
pushd community-operators | |
echo "" | |
echo "branch : $BRANCH_NAME" | |
echo "" | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git remote add upstream https://github.com/k8s-operatorhub/community-operators.git | |
git pull --rebase upstream main | |
git push -d origin ${BRANCH_NAME} || echo 'Skip branch deletion' | |
git checkout -b ${BRANCH_NAME} | |
mkdir -p operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
tar -xzf "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" -C operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
git add operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
git commit -m "operator kaoto-operator (${{ github.event.inputs.operator_version }})" | |
git push -u origin ${BRANCH_NAME} | |
gh pr create --title "operator kaoto (${{ github.event.inputs.operator_version }})" -F ../.github/operatorhub/community-operators -R k8s-operatorhub/community-operators | |
popd | |
prepare-openshift-operator-branch: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push | |
- tag-and-release | |
steps: | |
- name: "Checkout Operarot" | |
uses: actions/checkout@v4 | |
- name: "Checkout k8s-operator project" | |
uses: actions/checkout@v4 | |
with: | |
repository: KaotoIO/community-operators-prod | |
token: ${{ secrets.KAOTO_CI_TOKEN }} | |
path: community-operators-prod | |
ref: main | |
- name: "🛰️ Download UI Dist" | |
uses: actions/download-artifact@v4 | |
with: | |
name: bundle-${{ github.event.inputs.operator_version }}.tgz | |
path: "${{ runner.temp }}" | |
- name: "Create, prepare branch and open PR for community-operators-prod" | |
env: | |
BRANCH_NAME: "kaoto-operator.${{ github.event.inputs.operator_version }}" | |
GH_TOKEN: ${{ secrets.KAOTO_CI_TOKEN }} | |
run: | | |
pushd community-operators-prod | |
echo "" | |
echo "branch : $BRANCH_NAME" | |
echo "" | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod.git | |
git pull --rebase upstream main | |
git push -d origin ${BRANCH_NAME} || echo 'Skip branch deletion' | |
git checkout -b ${BRANCH_NAME} | |
mkdir -p operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
tar -xzf "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" -C operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
echo " com.redhat.openshift.versions: ${{ github.event.inputs.supported_openshift_range }}" >> operators/kaoto-operator/${{ github.event.inputs.operator_version }}/metadata/annotations.yaml | |
git add operators/kaoto-operator/${{ github.event.inputs.operator_version }} | |
git commit -m "operator kaoto-operator (${{ github.event.inputs.operator_version }})" | |
git push -u origin ${BRANCH_NAME} | |
gh pr create --title "operator kaoto (${{ github.event.inputs.operator_version }})" -F ../.github/openshift/community-operators-prod -R redhat-openshift-ecosystem/community-operators-prod | |
popd |