diff --git a/docs/development/releasing.md b/docs/development/releasing.md index 184390fc..047a6322 100644 --- a/docs/development/releasing.md +++ b/docs/development/releasing.md @@ -4,6 +4,10 @@ This document outlines the steps required to release the operator. This document have achieved the "Approver"/"Maintainer" status, and have permission to manually trigger GitHub Actions on this repo. +To release operator updates to the [k8s community operators](https://github.com/k8s-operatorhub/community-operators), +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) +or request approval from a listed GitHub user. + ## Release Candidates (`X.Y.0-rcN`) ### Step 0: Set Up the Release Branch @@ -78,3 +82,36 @@ Work with the community to get these pull requests merged. Repeat the process in [Step 1](#step-1-create-a-release-candidate) and [Step 2](#step-2-publish-draft-release) above to create the release. For an official release, the version should adhere to the `X.Y.Z` format (not extra dashes). + +### Step 3 (if needed): Set up your machine to run the OperatorHub release script + +The OperatorHub release script requires the following: + +1. Fork the [k8s community-operators](https://github.com/k8s-operatorhub/community-operators) + repository. +2. Clone your fork with the `origin` remote name. Be sure to set your name and email in your local + `git` configuration. +3. Add the community operators repository as the `upstream` remote: + + ```sh + $ git remote add upstream https://github.com/k8s-operatorhub/community-operators.git + ``` + +4. Install the [crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md) + tool locally. + +### Step 4: Update the Operator on OperatorHub.io + +[OperatorHub.io](https://operatorhub.io) publishes a catalog of operators sourced from the +community operators repository. To add a new operator version, we must submit a pull request +to the appropriate Git repository. + +Run the script `./hack/release-operatorhub.sh` to create a new release branch in your fork. +The script accepts the following environment variables: + +- `OPERATORHUB_DIR`: directory where the community operators repository was cloned. +- `VERSION`: version of the operator to submit for update. Do not include the leading `v` in the + version name. + +Once the script completes and pushes the branch to your fork, open a pull request against the +[community operators](https://github.com/k8s-operatorhub/community-operators) repository. diff --git a/hack/release-operatorhub.sh b/hack/release-operatorhub.sh new file mode 100755 index 00000000..df4d16a6 --- /dev/null +++ b/hack/release-operatorhub.sh @@ -0,0 +1,54 @@ +#!/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 https://github.com/k8s-operatorhub/community-operators +# - The machine running this script has crane installed: https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md + +OPERATORHUB_DIR=${OPERATORHUB_DIR:-$HOME/go/src/github.com/k8s-operatorhub/community-operators} +VERSION=${VERSION:-latest} +# Regular expression match [https://github.com/|git@github.com:] +hubRegEx="(https:\/\/github\.com\/|git@github\.com:)k8s-operatorhub" + +echo "Preparing to release Shipwright Operator ${VERSION} to OperatorHub" + +if [[ ! -d "$OPERATORHUB_DIR" ]]; then + echo "Please clone the community-operators 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 hub repository" + exit 1 +fi + +upstreamURL=$(git remote get-url upstream) +if [[ ! "$upstreamURL" =~ ${hubRegEx} ]]; then + echo "Please set the upstream remote ${upstreamURL} to the operator hub 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}" +git commit --amend --no-edit -s +git push --set-upstream origin "shipwright-${VERSION}" + +popd