Skip to content

Commit

Permalink
add version check for bundle, pre/post processing of catalog resources
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Dec 13, 2024
1 parent 52f2ab5 commit fe7e1db
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Set Image Tag Env
run: echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Operator Version Check
run: ./operator/bin/version-check.sh "${{ env.PROJECT_VERSION }}"

- name: Set Up JDK 17
uses: actions/setup-java@v4
with:
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,27 @@ jobs:
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b release
mvn -B release:prepare -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}}
git checkout ${{github.base_ref}}
git rebase release
PRERELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]')
export QUARKUS_CONTAINER_IMAGE_REGISTRY="${{ secrets.IMAGE_REPO_HOSTNAME }}"
export QUARKUS_CONTAINER_IMAGE_GROUP="${{ secrets.IMAGE_REPO_NAMESPACE }}"
export QUARKUS_CONTAINER_IMAGE_USERNAME="${{ secrets.IMAGE_REPO_USERNAME }}"
export QUARKUS_CONTAINER_IMAGE_PASSWORD="${{ secrets.IMAGE_REPO_PASSWORD }}"
export QUARKUS_CONTAINER_IMAGE_PUSH="true"
export QUARKUS_CONTAINER_IMAGE_ADDITIONAL_TAGS=latest
export QUARKUS_KUBERNETES_NAMESPACE='$${NAMESPACE}'
mvn -B release:prepare \
-DprereleaseVersion=${PRERELEASE_VERSION} \
-DreleaseVersion=${{ steps.metadata.outputs.current-version }} \
-DdevelopmentVersion=${{ steps.metadata.outputs.next-version }} \
-Dcontainer-image.registry=${{ secrets.IMAGE_REPO_HOSTNAME }}
git checkout ${{github.base_ref}}
git rebase release
export GIT_REVISION=$(git rev-parse --short release)
# Build and push the release images using the commit tagged in `release:prepare`
mvn -B -P container-image release:perform --no-transfer-progress \
'-Drelease.arguments=-Dquarkus.docker.buildx.platform=${{ env.PLATFORMS }}'
Expand Down
5 changes: 5 additions & 0 deletions operator/bin/common.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# Operator naming
OPERATOR_NAME="streamshub-console-operator"
OPERATOR_INSTANCE_NAME="${OPERATOR_NAME}-v${VERSION}"
OPERATOR_CSV_NAME="${OPERATOR_NAME}.v${VERSION}"

YQ="$(which yq 2>/dev/null)" || :

if [ "${YQ}" == "" ] ; then
Expand Down
5 changes: 0 additions & 5 deletions operator/bin/modify-bundle-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ fi

source ${SCRIPT_PATH}/common.sh

# Operator naming
OPERATOR_NAME="streamshub-console-operator"
OPERATOR_INSTANCE_NAME="${OPERATOR_NAME}-v${VERSION}"
OPERATOR_CSV_NAME="${OPERATOR_NAME}.v${VERSION}"

BUNDLE_PATH=${SCRIPT_PATH}/../target/bundle/streamshub-console-operator/
CSV_FILE_PATH=${BUNDLE_PATH}/manifests/streamshub-console-operator.clusterserviceversion.yaml

Expand Down
48 changes: 48 additions & 0 deletions operator/bin/release-prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

set -xEeuo pipefail

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
OPERATOR_PATH="$(cd -- "${SCRIPT_PATH}/.." >/dev/null 2>&1 ; pwd -P)"

PRERELEASE_VERSION="${1?prerelease version is required}"
RELEASE_VERSION="${2?release version is required}"
POSTRELEASE_VERSION="${3?postrelease version is required}"
VERSION="${4?current version is required}"
IMAGE_NAME="${5?image name is required}"
GIT_STAGE="${6:-false}"

source ${SCRIPT_PATH}/common.sh

PRERELEASE_CSV_NAME="${OPERATOR_NAME}.v${PRERELEASE_VERSION}"
RELEASE_CSV_NAME="${OPERATOR_NAME}.v${RELEASE_VERSION}"
POSTRELEASE_CSV_NAME="${OPERATOR_NAME}.v${POSTRELEASE_VERSION}"

if [ "${VERSION}" == "${POSTRELEASE_VERSION}" ] ; then
# Running via the `completionGoals` of the maven-release-plugin
echo "[INFO] Running release completion with version ${VERSION}"

# Create new entry for the next development cycle, "replaces" the version just released
${YQ} -i '.entries += {
"name": "'${POSTRELEASE_CSV_NAME}'",
"replaces": "'${RELEASE_CSV_NAME}'"
}' ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml

if [ "${GIT_STAGE}" == "true" ] ; then
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml
fi
else
# Running via the `preparationGoals` of the maven-release-plugin
echo "[INFO] Running release preparation for version ${VERSION}"

# Change the name of the entry to be the released version (e.g removing the -snapshot suffix)
${YQ} -i '(.entries[].name | select(. == "'${PRERELEASE_CSV_NAME}'")) = "'${RELEASE_CSV_NAME}'"' \
${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml

# Create a file with a reference to the bundle image to be generated during the release
echo "image: ${IMAGE_NAME}:${VERSION}" > ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml

if [ "${GIT_STAGE}" == "true" ] ; then
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml
fi
fi
19 changes: 19 additions & 0 deletions operator/bin/version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -xEeuo pipefail

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
OPERATOR_PATH="$(cd -- "${SCRIPT_PATH}/.." >/dev/null 2>&1 ; pwd -P)"

VERSION="${1?version is required}"

source ${SCRIPT_PATH}/common.sh
ALPHA_CHANNEL=${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml

if [ "$(${YQ} '(.entries[].name | select(. == "'${OPERATOR_CSV_NAME}'"))' ${ALPHA_CHANNEL})" != "" ] ; then
echo "[INFO] Bundle ${OPERATOR_CSV_NAME} has an entry in ${ALPHA_CHANNEL}"
exit 0;
fi

echo "[ERROR] Bundle ${OPERATOR_CSV_NAME} has no entry in ${ALPHA_CHANNEL}"
exit 1;
33 changes: 33 additions & 0 deletions operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,38 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>release-preparation</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>olm-channel-update</id>
<phase>process-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bin/release-prepare.sh</executable>
<arguments>
<argument>${prereleaseVersion}</argument>
<argument>${releaseVersion}</argument>
<argument>${developmentVersion}</argument>
<argument>${project.version}</argument>
<argument>${container-image.registry}/${container-image.group}/console-operator-bundle</argument>
<!-- stage to git index -->
<argument>true</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@
<profiles>
<profile>
<id>release-preparation</id>
<properties>
<!-- Used for operator bundle during preparation/completion of release:prepare goal -->
<prereleaseVersion></prereleaseVersion>
<releaseVersion></releaseVersion>
<developmentVersion></developmentVersion>
</properties>
</profile>
</profiles>
</project>

0 comments on commit fe7e1db

Please sign in to comment.