-
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.
Merge pull request #225 from adambkaplan/release-procedure-operatorhub
doc: Procedure to Publish Operator on OperatorHub
- Loading branch information
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 |