Skip to content

Commit a19fb85

Browse files
Merge pull request #225 from adambkaplan/release-procedure-operatorhub
doc: Procedure to Publish Operator on OperatorHub
2 parents 31b8208 + 2b89b56 commit a19fb85

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

docs/development/releasing.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This document outlines the steps required to release the operator. This document
44
have achieved the "Approver"/"Maintainer" status, and have permission to manually trigger GitHub
55
Actions on this repo.
66

7+
To release operator updates to the [k8s community operators](https://github.com/k8s-operatorhub/community-operators),
8+
you must be listed as an approver in our [operator CI configuration](https://github.com/k8s-operatorhub/community-operators/blob/main/operators/shipwright-operator/ci.yaml)
9+
or request approval from a listed GitHub user.
10+
711
## Release Candidates (`X.Y.0-rcN`)
812

913
### Step 0: Set Up the Release Branch
@@ -78,3 +82,49 @@ Work with the community to get these pull requests merged.
7882
Repeat the process in [Step 1](#step-1-create-a-release-candidate) and
7983
[Step 2](#step-2-publish-draft-release) above to create the release. For an official release, the
8084
version should adhere to the `X.Y.Z` format (not extra dashes).
85+
86+
### Step 3 (if needed): Set up your machine to run the OperatorHub release script
87+
88+
The OperatorHub release script requires the following:
89+
90+
1. Fork the [k8s community-operators](https://github.com/k8s-operatorhub/community-operators)
91+
repository.
92+
2. Clone your fork with the `origin` remote name. Be sure to set your name and email in your local
93+
`git` configuration.
94+
3. Add the community operators repository as the `upstream` remote:
95+
96+
```sh
97+
$ git remote add upstream https://github.com/k8s-operatorhub/community-operators.git
98+
```
99+
100+
4. Install the [crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md)
101+
tool locally.
102+
103+
### Step 4: Update the Operator on OperatorHub.io
104+
105+
[OperatorHub.io](https://operatorhub.io) publishes a catalog of operators sourced from git. To add
106+
a new operator version, we must submit a pull request to the appropriate git repository.
107+
108+
Run the script `./hack/release-operatorhub.sh` to create a new release branch in your fork. The
109+
script defaults to submitting pull requests to the k8s-operatorhub/community-operators catalog, but
110+
other catalogs with the same format are supported.
111+
112+
The script accepts the following environment variables:
113+
114+
- `OPERATORHUB_DIR`: directory where the operator catalog repository was cloned.
115+
- `VERSION`: version of the operator to submit for update. Do not include the leading `v` in the
116+
version name.
117+
- `HUB_REPO`: Regular expression to match for the operator catalog. Defaults to
118+
`k8s-operatorhub\/community-operators` - be sure to escape special characters when overriding
119+
this value.
120+
121+
Once the script completes and pushes the branch to your fork, open a pull request against the
122+
[community operators](https://github.com/k8s-operatorhub/community-operators) repository.
123+
124+
### Step 5 (optional): Update other operator catalogs
125+
126+
OperatorHub.io is not the only catalog that can be used to publish operators on Kubernetes
127+
clusters. Community members can use the `release-operatorhub.sh` script to update any other catalog
128+
that uses the OperatorHub file structure by providing appropriate environment variable overrides.
129+
130+
Maintainers are not required to submit updates to other operator catalogs.

hack/release-operatorhub.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
# This script generates a pull request to add the release to operatorhub.io
6+
# Prerequisites:
7+
# - The user has cloned and forked the operator catalog repository
8+
# - The machine running this script has crane installed: https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md
9+
10+
# Environment variables to tune the script's behavior
11+
# - OPERATORHUB_DIR: The local path to the operator catalog repository.
12+
# - VERSION: The version of the operator to release.
13+
# - HUB_REPO: A regular expression to match the GitHub org/repository of the catalog. Note that this
14+
# is a regular expression, so special characters need to be escaped.
15+
16+
OPERATORHUB_DIR=${OPERATORHUB_DIR:-$HOME/go/src/github.com/k8s-operatorhub/community-operators}
17+
VERSION=${VERSION:-latest}
18+
HUB_REPO=${HUB_REPO:-"k8s-operatorhub\/community-operators"}
19+
# Regular expression match [https://github.com/|[email protected]:]
20+
hubRegEx="(https:\/\/github\.com\/|git@github\.com:)${HUB_REPO}"
21+
22+
echo "Preparing to release Shipwright Operator ${VERSION} to Operator catalog github.com/${HUB_REPO}"
23+
24+
if [[ ! -d "$OPERATORHUB_DIR" ]]; then
25+
echo "Please clone the operator catalog repository repository to $OPERATORHUB_DIR"
26+
exit 1
27+
fi
28+
29+
pushd "$OPERATORHUB_DIR"
30+
31+
originURL=$(git remote get-url origin)
32+
if [[ "$originURL" =~ ${hubRegEx} ]]; then
33+
echo "Please set the origin remote to your fork of the operator catalog repository"
34+
exit 1
35+
fi
36+
37+
upstreamURL=$(git remote get-url upstream)
38+
if [[ ! "$upstreamURL" =~ ${hubRegEx} ]]; then
39+
echo "Please set the upstream remote ${upstreamURL} to the operator catalog repository"
40+
exit 1
41+
fi
42+
43+
git fetch
44+
git switch main
45+
git pull upstream main
46+
git checkout -b "shipwright-${VERSION}"
47+
48+
mkdir -p "operators/shipwright-operator/${VERSION}"
49+
pushd "operators/shipwright-operator/${VERSION}"
50+
51+
crane export "ghcr.io/shipwright-io/operator/operator-bundle:v${VERSION}" - | tar -xv
52+
53+
popd
54+
55+
# Commit and push changes to our GitHub fork
56+
git add "operators/shipwright-operator/${VERSION}"
57+
git commit -m "Update Shipwright Operator to ${VERSION}" -s
58+
git push --set-upstream origin "shipwright-${VERSION}"
59+
60+
popd

0 commit comments

Comments
 (0)