-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Procedure to Publish Operator on OperatorHub
Add a procedure and script to publish an operator release to the upstream k8s community operators OperatorHub. The script requires the user to fork the upstream k8s operators repsository and afterwards submit a pull request by hand. The script also supports releasing to any catalog that uses the OperatorHub file structure. In the future this procedure/script can be added to our release automation so when an operator release is published, we initiate the process to update the upstream OperatorHub catalog. Co-authored-by: Sascha Schwarze <[email protected]> Signed-off-by: Adam Kaplan <[email protected]>
- Loading branch information
1 parent
b07eb64
commit 2b89b56
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -eu -o pipefail | ||
|
||
# This script generates a pull request to add the release to operatorhub.io | ||
# Prerequisites: | ||
# - The user has cloned and forked the operator catalog repository | ||
# - The machine running this script has crane installed: https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md | ||
|
||
# Environment variables to tune the script's behavior | ||
# - OPERATORHUB_DIR: The local path to the operator catalog repository. | ||
# - VERSION: The version of the operator to release. | ||
# - HUB_REPO: A regular expression to match the GitHub org/repository of the catalog. Note that this | ||
# is a regular expression, so special characters need to be escaped. | ||
|
||
OPERATORHUB_DIR=${OPERATORHUB_DIR:-$HOME/go/src/github.com/k8s-operatorhub/community-operators} | ||
VERSION=${VERSION:-latest} | ||
HUB_REPO=${HUB_REPO:-"k8s-operatorhub\/community-operators"} | ||
# Regular expression match [https://github.com/|[email protected]:] | ||
hubRegEx="(https:\/\/github\.com\/|git@github\.com:)${HUB_REPO}" | ||
|
||
echo "Preparing to release Shipwright Operator ${VERSION} to Operator catalog github.com/${HUB_REPO}" | ||
|
||
if [[ ! -d "$OPERATORHUB_DIR" ]]; then | ||
echo "Please clone the operator catalog repository repository to $OPERATORHUB_DIR" | ||
exit 1 | ||
fi | ||
|
||
pushd "$OPERATORHUB_DIR" | ||
|
||
originURL=$(git remote get-url origin) | ||
if [[ "$originURL" =~ ${hubRegEx} ]]; then | ||
echo "Please set the origin remote to your fork of the operator catalog repository" | ||
exit 1 | ||
fi | ||
|
||
upstreamURL=$(git remote get-url upstream) | ||
if [[ ! "$upstreamURL" =~ ${hubRegEx} ]]; then | ||
echo "Please set the upstream remote ${upstreamURL} to the operator catalog repository" | ||
exit 1 | ||
fi | ||
|
||
git fetch | ||
git switch main | ||
git pull upstream main | ||
git checkout -b "shipwright-${VERSION}" | ||
|
||
mkdir -p "operators/shipwright-operator/${VERSION}" | ||
pushd "operators/shipwright-operator/${VERSION}" | ||
|
||
crane export "ghcr.io/shipwright-io/operator/operator-bundle:v${VERSION}" - | tar -xv | ||
|
||
popd | ||
|
||
# Commit and push changes to our GitHub fork | ||
git add "operators/shipwright-operator/${VERSION}" | ||
git commit -m "Update Shipwright Operator to ${VERSION}" -s | ||
git push --set-upstream origin "shipwright-${VERSION}" | ||
|
||
popd |