From 18e00975d9c8fc3b46523c87036e2e729791e017 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Thu, 18 Jan 2024 10:14:44 -0500 Subject: [PATCH 01/10] automate version changing for release Signed-off-by: Jordan Dubrick --- Makefile | 3 ++ make-release.sh | 98 +++++++++++++++++++++++++++++++++++++++++ replace-alm-examples.sh | 19 ++++++++ 3 files changed, 120 insertions(+) create mode 100644 make-release.sh create mode 100644 replace-alm-examples.sh diff --git a/Makefile b/Makefile index 3f79773..88cd102 100644 --- a/Makefile +++ b/Makefile @@ -262,11 +262,14 @@ $(ENVTEST): $(LOCALBIN) test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) GOFLAGS="" go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest # Generate bundle manifests and metadata, then validate generated files. +## sh replace-alm-examples.sh is there to fix an issue with Kustomize removing List items +## More information can be found here: https://github.com/kubernetes-sigs/kustomize/issues/5042 .PHONY: bundle bundle: manifests $(OPERATOR_SDK_CLI) generate kustomize manifests -q cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK_CLI) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) + sh replace-alm-examples.sh $(OPERATOR_SDK_CLI) bundle validate ./bundle # Build the bundle image. diff --git a/make-release.sh b/make-release.sh new file mode 100644 index 0000000..4161d5c --- /dev/null +++ b/make-release.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# +# +# Copyright Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +usage () +{ echo "Usage: ./make-release.sh " + exit +} + +if [[ $# -lt 1 ]]; then usage; fi +SCHEMA_VERSION=$1 + +if ! command -v hub > /dev/null; then + echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases" + exit +fi +if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "[ERROR] The GITHUB_TOKEN environment variable must be set." + exit +fi +if ! [[ "$SCHEMA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo >&2 "$SCHEMA_VERSION isn't a valid semver tag for the schema. Aborting..." + exit 1 +fi + + +## Ensures local branch matches the remote +resetChanges() { + echo "[INFO] Reset changes in $1 branch" + git reset --hard + git checkout $1 + git fetch origin --prune + git pull origin $1 +} + +## Branch containing releases and tags in main upstream repo will be named 'release-vx' where 'vx' is the major release +## All minor and patch releases will be contained within a major release branch +## On the local side (the release engineers), the branches will be their full versioning name e.g. x.x.x +## Local branch will create a PR to its respective major release branch (if exists) or create a new one +checkoutToReleaseBranch() { + echo "[INFO] Checking out to $SCHEMA_VERSION branch." + if git ls-remote -q --heads | grep -q $SCHEMA_VERSION ; then + echo "[INFO] $SCHEMA_VERSION exists." + #resetChanges $SCHEMA_VERSION --- commented out so it doesnt delete my work when testing + else + echo "[INFO] $SCHEMA_VERSION does not exist. Will create a new one from main." + #resetChanges main --- commented out so it doesnt delete my work when testing + git push origin main:$SCHEMA_VERSION + fi + git checkout -B $SCHEMA_VERSION +} + + +updateVersionNumbers() { + SHORT_UNAME=$(uname -s) + + ## Updating version.md based off of operating system + if [ "$(uname)" == "Darwin" ]; then + sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION + elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then + sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION + fi + + ## Remaining version number updates to yaml files + yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + yq eval ".metadata.name = \"registry-operator.v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml +} + +exportEnvironmentVariables() { + CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml) + export IMG=quay.io/devfile/registry-operator:$SCHEMA_VERSION + export CHANNELS=$CHANNEL + +} + +main(){ + updateVersionNumbers + exportEnvironmentVariables + make bundle +} + +main \ No newline at end of file diff --git a/replace-alm-examples.sh b/replace-alm-examples.sh new file mode 100644 index 0000000..4f438ff --- /dev/null +++ b/replace-alm-examples.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# +# Copyright Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ALM_EXAMPLES=$(yq -r '.metadata.annotations.alm-examples' ./config/manifests/bases/registry-operator.clusterserviceversion.yaml) +yq -i ".metadata.annotations.alm-examples = ($ALM_EXAMPLES | to_json)" ./bundle/manifests/registry-operator.clusterserviceversion.yaml \ No newline at end of file From e0fe8ed21a8c448faddf7de344793fca6e78ca24 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Thu, 18 Jan 2024 14:17:47 -0500 Subject: [PATCH 02/10] add automated commit Signed-off-by: Jordan Dubrick --- make-release.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/make-release.sh b/make-release.sh index 4161d5c..67275eb 100644 --- a/make-release.sh +++ b/make-release.sh @@ -88,11 +88,20 @@ exportEnvironmentVariables() { export CHANNELS=$CHANNEL } + +commitChanges() { + echo "[INFO] Pushing changes to $SCHEMA_VERSION branch" + git add -A + git commit -s -m "$1" + git push origin $SCHEMA_VERSION +} main(){ + checkoutToReleaseBranch updateVersionNumbers exportEnvironmentVariables make bundle + commitChanges "chore(release): release version ${SCHEMA_VERSION}" } main \ No newline at end of file From 2b6574686d957417c47bd669ec66ab8cc7ea8c8d Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Thu, 18 Jan 2024 15:46:17 -0500 Subject: [PATCH 03/10] add makefile rule Signed-off-by: Jordan Dubrick --- Makefile | 6 ++++++ make-release.sh | 31 ++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 88cd102..dc90350 100644 --- a/Makefile +++ b/Makefile @@ -288,3 +288,9 @@ gosec: # Run this command to install gosec, if not installed: # go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0 gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir pkg/test -exclude-dir tests ./... + +### Release +# RUN: make release new-version=x.x.x +.PHONY: +release: + sh make-release.sh ${new-version} \ No newline at end of file diff --git a/make-release.sh b/make-release.sh index 67275eb..e699335 100644 --- a/make-release.sh +++ b/make-release.sh @@ -24,6 +24,8 @@ usage () if [[ $# -lt 1 ]]; then usage; fi SCHEMA_VERSION=$1 +FIRST_DIGIT="${SCHEMA_VERSION%%.*}" +RELEASE_BRANCH="release-v${FIRST_DIGIT}" if ! command -v hub > /dev/null; then echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases" @@ -70,21 +72,21 @@ updateVersionNumbers() { SHORT_UNAME=$(uname -s) ## Updating version.md based off of operating system - if [ "$(uname)" == "Darwin" ]; then - sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION - elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then - sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION - fi + if [ "$(uname)" == "Darwin" ]; then + sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION + elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then + sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION + fi ## Remaining version number updates to yaml files - yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml yq eval ".metadata.name = \"registry-operator.v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml } exportEnvironmentVariables() { CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml) - export IMG=quay.io/devfile/registry-operator:$SCHEMA_VERSION + export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION export CHANNELS=$CHANNEL } @@ -95,6 +97,20 @@ commitChanges() { git commit -s -m "$1" git push origin $SCHEMA_VERSION } + +# Creates a new branch in the registry-operator repo for a new major release +# with the name release-vX +## This func will be used when we have a new major release and there is no branch in the upstream repo +createNewReleaseBranch(){ + git checkout -b "${RELEASE_BRANCH}" + git push origin "${RELEASE_BRANCH}" + hub sync +} + +createPullRequest(){ + echo "[INFO] Creating a PR" + hub pull-request --base ${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" +} main(){ checkoutToReleaseBranch @@ -102,6 +118,7 @@ main(){ exportEnvironmentVariables make bundle commitChanges "chore(release): release version ${SCHEMA_VERSION}" + createPullRequest "v${SCHEMA_VERSION} Release" } main \ No newline at end of file From 46c8b22c3359d4a82109aeea93cc620884d197f9 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Thu, 18 Jan 2024 16:35:34 -0500 Subject: [PATCH 04/10] add logic for creating new release branch Signed-off-by: Jordan Dubrick --- make-release.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/make-release.sh b/make-release.sh index e699335..9b36c94 100644 --- a/make-release.sh +++ b/make-release.sh @@ -102,23 +102,30 @@ commitChanges() { # with the name release-vX ## This func will be used when we have a new major release and there is no branch in the upstream repo createNewReleaseBranch(){ - git checkout -b "${RELEASE_BRANCH}" + git checkout -b "${RELEASE_BRANCH}" main git push origin "${RELEASE_BRANCH}" - hub sync + #hub sync } createPullRequest(){ echo "[INFO] Creating a PR" - hub pull-request --base ${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" + hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" } main(){ - checkoutToReleaseBranch - updateVersionNumbers - exportEnvironmentVariables - make bundle - commitChanges "chore(release): release version ${SCHEMA_VERSION}" - createPullRequest "v${SCHEMA_VERSION} Release" + # checkoutToReleaseBranch + # updateVersionNumbers + # exportEnvironmentVariables + # make bundle + # commitChanges "chore(release): release version ${SCHEMA_VERSION}" + #createPullRequest "v${SCHEMA_VERSION} Release" + # Check if the branch exists in the remote repository + if git ls-remote --exit-code --heads origin "$RELEASE_BRANCH" >/dev/null 2>&1; then + echo "Branch $RELEASE_BRANCH exists in the remote repository." + else + echo "Branch $RELEASE_BRANCH does not exist in the remote repository." + createNewReleaseBranch + fi } main \ No newline at end of file From d9cbefc3536df5e64060df178ddb4ee172dfcb0c Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Fri, 19 Jan 2024 11:14:53 -0500 Subject: [PATCH 05/10] verify release branch logic Signed-off-by: Jordan Dubrick --- make-release.sh | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/make-release.sh b/make-release.sh index 9b36c94..afd45ee 100644 --- a/make-release.sh +++ b/make-release.sh @@ -26,6 +26,11 @@ if [[ $# -lt 1 ]]; then usage; fi SCHEMA_VERSION=$1 FIRST_DIGIT="${SCHEMA_VERSION%%.*}" RELEASE_BRANCH="release-v${FIRST_DIGIT}" +DEVFILE_REPO="git@github.com:devfile/registry-operator.git" +## This will be uncommented for actual devfile repo +RELEASE_UPSTREAM_NAME="devfile-upstream-release" +# This goes to my origin for testing +#RELEASE_UPSTREAM_NAME="origin" if ! command -v hub > /dev/null; then echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases" @@ -40,14 +45,23 @@ if ! [[ "$SCHEMA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then exit 1 fi +# Sets the upstream to devfile repo to ensure that git commands are performed on the correct repo +# Ensures users who don't have an upstream set will be able to run script with no setup +setUpstream(){ + if git remote -v | grep -q "$RELEASE_UPSTREAM_NAME[[:space:]]\+$DEVFILE_REPO"; then + git remote rm ${RELEASE_UPSTREAM_NAME} + fi + git remote add ${RELEASE_UPSTREAM_NAME} "${DEVFILE_REPO}" +} + ## Ensures local branch matches the remote resetChanges() { echo "[INFO] Reset changes in $1 branch" git reset --hard git checkout $1 - git fetch origin --prune - git pull origin $1 + git fetch ${RELEASE_UPSTREAM_NAME} --prune + git pull ${RELEASE_UPSTREAM_NAME} $1 } ## Branch containing releases and tags in main upstream repo will be named 'release-vx' where 'vx' is the major release @@ -84,13 +98,14 @@ updateVersionNumbers() { yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml } +# Export env variables that are used in bundle scripts exportEnvironmentVariables() { CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml) export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION export CHANNELS=$CHANNEL - } +# Commits version changes to your forked repository commitChanges() { echo "[INFO] Pushing changes to $SCHEMA_VERSION branch" git add -A @@ -102,14 +117,24 @@ commitChanges() { # with the name release-vX ## This func will be used when we have a new major release and there is no branch in the upstream repo createNewReleaseBranch(){ - git checkout -b "${RELEASE_BRANCH}" main - git push origin "${RELEASE_BRANCH}" - #hub sync + git checkout -b "${RELEASE_BRANCH}" "${RELEASE_UPSTREAM_NAME}"/main + git push "${RELEASE_UPSTREAM_NAME}" "${RELEASE_BRANCH}" + #hub sync -- this supposedly will create that branch in upstream +} + +verifyReleaseBranch() { + if git ls-remote --exit-code --heads ${RELEASE_UPSTREAM_NAME} "$RELEASE_BRANCH" >/dev/null 2>&1; then + echo "Branch $RELEASE_BRANCH exists in the upstream repository." + else + echo "Branch $RELEASE_BRANCH does not exist in the upstream repository." + #createNewReleaseBranch + + fi } createPullRequest(){ echo "[INFO] Creating a PR" - hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" + hub pull-request --base ${RELEASE_UPSTREAM_NAME}:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" } main(){ @@ -120,12 +145,8 @@ main(){ # commitChanges "chore(release): release version ${SCHEMA_VERSION}" #createPullRequest "v${SCHEMA_VERSION} Release" # Check if the branch exists in the remote repository - if git ls-remote --exit-code --heads origin "$RELEASE_BRANCH" >/dev/null 2>&1; then - echo "Branch $RELEASE_BRANCH exists in the remote repository." - else - echo "Branch $RELEASE_BRANCH does not exist in the remote repository." - createNewReleaseBranch - fi + verifyReleaseBranch + #setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE } main \ No newline at end of file From 4e97704f45eb3c4f1f0ef54817c405fa1f3cca0f Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Fri, 19 Jan 2024 11:23:12 -0500 Subject: [PATCH 06/10] logic to create release branch in upstream: -s Signed-off-by: Jordan Dubrick --- make-release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make-release.sh b/make-release.sh index afd45ee..1c899f5 100644 --- a/make-release.sh +++ b/make-release.sh @@ -117,7 +117,7 @@ commitChanges() { # with the name release-vX ## This func will be used when we have a new major release and there is no branch in the upstream repo createNewReleaseBranch(){ - git checkout -b "${RELEASE_BRANCH}" "${RELEASE_UPSTREAM_NAME}"/main + git checkout -b "${RELEASE_BRANCH}" main git push "${RELEASE_UPSTREAM_NAME}" "${RELEASE_BRANCH}" #hub sync -- this supposedly will create that branch in upstream } @@ -127,7 +127,7 @@ verifyReleaseBranch() { echo "Branch $RELEASE_BRANCH exists in the upstream repository." else echo "Branch $RELEASE_BRANCH does not exist in the upstream repository." - #createNewReleaseBranch + createNewReleaseBranch fi } From 971aff86bb5739097a1aa5aed3567c705fc3712e Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Fri, 19 Jan 2024 11:52:21 -0500 Subject: [PATCH 07/10] testing process Signed-off-by: Jordan Dubrick --- make-release.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/make-release.sh b/make-release.sh index 1c899f5..ba90ce2 100644 --- a/make-release.sh +++ b/make-release.sh @@ -28,9 +28,9 @@ FIRST_DIGIT="${SCHEMA_VERSION%%.*}" RELEASE_BRANCH="release-v${FIRST_DIGIT}" DEVFILE_REPO="git@github.com:devfile/registry-operator.git" ## This will be uncommented for actual devfile repo -RELEASE_UPSTREAM_NAME="devfile-upstream-release" +#RELEASE_UPSTREAM_NAME="devfile-upstream-release" # This goes to my origin for testing -#RELEASE_UPSTREAM_NAME="origin" +RELEASE_UPSTREAM_NAME="origin" if ! command -v hub > /dev/null; then echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases" @@ -72,11 +72,11 @@ checkoutToReleaseBranch() { echo "[INFO] Checking out to $SCHEMA_VERSION branch." if git ls-remote -q --heads | grep -q $SCHEMA_VERSION ; then echo "[INFO] $SCHEMA_VERSION exists." - #resetChanges $SCHEMA_VERSION --- commented out so it doesnt delete my work when testing + resetChanges $SCHEMA_VERSION --- commented out so it doesnt delete my work when testing else echo "[INFO] $SCHEMA_VERSION does not exist. Will create a new one from main." - #resetChanges main --- commented out so it doesnt delete my work when testing - git push origin main:$SCHEMA_VERSION + resetChanges release-automation --- commented out so it doesnt delete my work when testing #change release-automation to main after testing + git push origin release-automation:$SCHEMA_VERSION fi git checkout -B $SCHEMA_VERSION } @@ -117,18 +117,18 @@ commitChanges() { # with the name release-vX ## This func will be used when we have a new major release and there is no branch in the upstream repo createNewReleaseBranch(){ - git checkout -b "${RELEASE_BRANCH}" main + git checkout -b "${RELEASE_BRANCH}" release-automation #change to main after testing git push "${RELEASE_UPSTREAM_NAME}" "${RELEASE_BRANCH}" - #hub sync -- this supposedly will create that branch in upstream } +# Checks if release-vX branch is in the upstream +# If it is not it creates the new major release branch based off main verifyReleaseBranch() { if git ls-remote --exit-code --heads ${RELEASE_UPSTREAM_NAME} "$RELEASE_BRANCH" >/dev/null 2>&1; then echo "Branch $RELEASE_BRANCH exists in the upstream repository." else echo "Branch $RELEASE_BRANCH does not exist in the upstream repository." createNewReleaseBranch - fi } @@ -138,14 +138,14 @@ createPullRequest(){ } main(){ - # checkoutToReleaseBranch - # updateVersionNumbers - # exportEnvironmentVariables - # make bundle - # commitChanges "chore(release): release version ${SCHEMA_VERSION}" - #createPullRequest "v${SCHEMA_VERSION} Release" - # Check if the branch exists in the remote repository + checkoutToReleaseBranch + updateVersionNumbers + exportEnvironmentVariables + make bundle + commitChanges "chore(release): release version ${SCHEMA_VERSION}" verifyReleaseBranch + createPullRequest "v${SCHEMA_VERSION} Release" + #setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE } From e8294d969e4ff2fbb6d7d5b213da900e15192eec Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Fri, 19 Jan 2024 11:55:25 -0500 Subject: [PATCH 08/10] change pr recipient Signed-off-by: Jordan Dubrick --- make-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make-release.sh b/make-release.sh index ba90ce2..ad094e8 100644 --- a/make-release.sh +++ b/make-release.sh @@ -134,7 +134,7 @@ verifyReleaseBranch() { createPullRequest(){ echo "[INFO] Creating a PR" - hub pull-request --base ${RELEASE_UPSTREAM_NAME}:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" + hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" } main(){ From 459b56d3f0a12db04214a0b622064621bb29ab99 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Fri, 19 Jan 2024 13:19:00 -0500 Subject: [PATCH 09/10] update docs Signed-off-by: Jordan Dubrick --- README.md | 7 +++++++ make-release.sh | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58cb4b7..5add92c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ Releases are available on [GitHub](https://github.com/devfile/registry-operator/ For more updates on releases, please join our [communication channels](https://devfile.io/docs/2.2.2/community#getting-involved). +## Preparing Releases +A script has been created to make the release process more efficient. This script takes care of all changes to version numbers in all necessary files. Additionally this script opens the initial PR to devfile/registry-operator. The release engineer will be responsible for running this script with the instructions below. + +1. Navigate to main branch of your forked registry-operator repository. +2. Run `make release new-version=x.x.x` where x.x.x is the version you are trying to cut. +3. Edit the PR opened by the script on devfile/registry-operator to include a proper description. + ## Issue Tracking Issue tracking repo: https://github.com/devfile/api with label area/registry diff --git a/make-release.sh b/make-release.sh index ad094e8..07c3416 100644 --- a/make-release.sh +++ b/make-release.sh @@ -72,10 +72,10 @@ checkoutToReleaseBranch() { echo "[INFO] Checking out to $SCHEMA_VERSION branch." if git ls-remote -q --heads | grep -q $SCHEMA_VERSION ; then echo "[INFO] $SCHEMA_VERSION exists." - resetChanges $SCHEMA_VERSION --- commented out so it doesnt delete my work when testing + resetChanges $SCHEMA_VERSION else echo "[INFO] $SCHEMA_VERSION does not exist. Will create a new one from main." - resetChanges release-automation --- commented out so it doesnt delete my work when testing #change release-automation to main after testing + resetChanges release-automation #change release-automation to main after testing git push origin release-automation:$SCHEMA_VERSION fi git checkout -B $SCHEMA_VERSION @@ -134,10 +134,11 @@ verifyReleaseBranch() { createPullRequest(){ echo "[INFO] Creating a PR" - hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" + hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" #jdubrick changes to devfile } main(){ + #setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE checkoutToReleaseBranch updateVersionNumbers exportEnvironmentVariables @@ -145,8 +146,6 @@ main(){ commitChanges "chore(release): release version ${SCHEMA_VERSION}" verifyReleaseBranch createPullRequest "v${SCHEMA_VERSION} Release" - - #setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE } main \ No newline at end of file From 574d46dc1514a8b33c3c0241f73088673d55ce52 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Mon, 22 Jan 2024 14:04:27 -0500 Subject: [PATCH 10/10] update make rule docs Signed-off-by: Jordan Dubrick --- Makefile | 4 ++-- README.md | 9 ++------- make-release.sh | 50 ++++++++++++++++++++++++------------------------- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index dc90350..0df2611 100644 --- a/Makefile +++ b/Makefile @@ -290,7 +290,7 @@ gosec: gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir pkg/test -exclude-dir tests ./... ### Release -# RUN: make release new-version=x.x.x +# RUN: make release NEW_VERSION=x.x.x .PHONY: release: - sh make-release.sh ${new-version} \ No newline at end of file + sh make-release.sh ${NEW_VERSION} \ No newline at end of file diff --git a/README.md b/README.md index 5add92c..a6ede79 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,6 @@ Releases are available on [GitHub](https://github.com/devfile/registry-operator/ For more updates on releases, please join our [communication channels](https://devfile.io/docs/2.2.2/community#getting-involved). -## Preparing Releases -A script has been created to make the release process more efficient. This script takes care of all changes to version numbers in all necessary files. Additionally this script opens the initial PR to devfile/registry-operator. The release engineer will be responsible for running this script with the instructions below. - -1. Navigate to main branch of your forked registry-operator repository. -2. Run `make release new-version=x.x.x` where x.x.x is the version you are trying to cut. -3. Edit the PR opened by the script on devfile/registry-operator to include a proper description. - ## Issue Tracking Issue tracking repo: https://github.com/devfile/api with label area/registry @@ -104,6 +97,7 @@ The repository contains a Makefile; building and deploying can be configured via | `TARGET_OS` | Target operating system for operator manager build, **only for `make manager`** | `linux` | | `PLATFORMS` | Target architecture(s) for `make docker-buildx` | All supported: `linux/arm64,linux/amd64,linux/s390x,linux/ppc64le` | | `KUSTOMIZE_INSTALL_SCRIPT` | URL of kustomize installation script, see [kustomize installation instructions](https://kubectl.docs.kubernetes.io/installation/kustomize/binaries/) | `https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh` | +| `NEW_VERSION` | Release version being cut | | Some of the rules supported by the makefile: @@ -131,6 +125,7 @@ Some of the rules supported by the makefile: | fmt_license | Ensure license header is set on all files | | vet | Check suspicious constructs into code | | gosec | Check for security problems in non-test source files | +| release | Starts the process for cutting a new release | To see all rules supported by the makefile, run `make help` diff --git a/make-release.sh b/make-release.sh index 07c3416..c827b4b 100644 --- a/make-release.sh +++ b/make-release.sh @@ -18,19 +18,17 @@ set -eu usage () -{ echo "Usage: ./make-release.sh " +{ echo "Usage: make release NEW_VERSION=" exit } if [[ $# -lt 1 ]]; then usage; fi + SCHEMA_VERSION=$1 FIRST_DIGIT="${SCHEMA_VERSION%%.*}" RELEASE_BRANCH="release-v${FIRST_DIGIT}" DEVFILE_REPO="git@github.com:devfile/registry-operator.git" -## This will be uncommented for actual devfile repo -#RELEASE_UPSTREAM_NAME="devfile-upstream-release" -# This goes to my origin for testing -RELEASE_UPSTREAM_NAME="origin" +RELEASE_UPSTREAM_NAME="devfile-upstream-release" if ! command -v hub > /dev/null; then echo "[ERROR] The hub CLI needs to be installed. See https://github.com/github/hub/releases" @@ -75,34 +73,34 @@ checkoutToReleaseBranch() { resetChanges $SCHEMA_VERSION else echo "[INFO] $SCHEMA_VERSION does not exist. Will create a new one from main." - resetChanges release-automation #change release-automation to main after testing - git push origin release-automation:$SCHEMA_VERSION + resetChanges main + git push origin main:$SCHEMA_VERSION fi git checkout -B $SCHEMA_VERSION } updateVersionNumbers() { - SHORT_UNAME=$(uname -s) - - ## Updating version.md based off of operating system - if [ "$(uname)" == "Darwin" ]; then - sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION - elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then - sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION - fi - - ## Remaining version number updates to yaml files - yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml - yq eval ".metadata.name = \"registry-operator.v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml - yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + SHORT_UNAME=$(uname -s) + + ## Updating version.md based off of operating system + if [ "$(uname)" == "Darwin" ]; then + sed -i '' "s/^.*$/$SCHEMA_VERSION/" VERSION + elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then + sed -i "s/^.*$/$SCHEMA_VERSION/" VERSION + fi + + ## Remaining version number updates to yaml files + yq eval ".metadata.annotations.containerImage = \"quay.io/devfile/registry-operator:v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + yq eval ".metadata.name = \"registry-operator.v$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml + yq eval ".spec.version = \"$SCHEMA_VERSION\"" --inplace ./config/manifests/bases/registry-operator.clusterserviceversion.yaml } # Export env variables that are used in bundle scripts exportEnvironmentVariables() { - CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml) - export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION - export CHANNELS=$CHANNEL + CHANNEL=$(yq eval '.annotations."operators.operatorframework.io.bundle.channels.v1"' ./bundle/metadata/annotations.yaml) + export IMG=quay.io/devfile/registry-operator:v$SCHEMA_VERSION + export CHANNELS=$CHANNEL } # Commits version changes to your forked repository @@ -117,7 +115,7 @@ commitChanges() { # with the name release-vX ## This func will be used when we have a new major release and there is no branch in the upstream repo createNewReleaseBranch(){ - git checkout -b "${RELEASE_BRANCH}" release-automation #change to main after testing + git checkout -b "${RELEASE_BRANCH}" main git push "${RELEASE_UPSTREAM_NAME}" "${RELEASE_BRANCH}" } @@ -134,11 +132,11 @@ verifyReleaseBranch() { createPullRequest(){ echo "[INFO] Creating a PR" - hub pull-request --base jdubrick:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" #jdubrick changes to devfile + hub pull-request --base devfile:${RELEASE_BRANCH} --head ${SCHEMA_VERSION} -m "$1" } main(){ - #setUpstream -- LEAVE COMMENTED AS THIS WILL SET MY ORIGIN TO DEVFILE + setUpstream checkoutToReleaseBranch updateVersionNumbers exportEnvironmentVariables