Skip to content

Commit

Permalink
update make rule docs
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Dubrick <[email protected]>
  • Loading branch information
Jdubrick committed Jan 22, 2024
1 parent 8419707 commit 211084c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
sh make-release.sh ${NEW_VERSION}
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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`

Expand Down
50 changes: 24 additions & 26 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@
set -eu

usage ()
{ echo "Usage: ./make-release.sh <schema-version>"
{ echo "Usage: make release NEW_VERSION=<x.x.x>"
exit
}

if [[ $# -lt 1 ]]; then usage; fi

SCHEMA_VERSION=$1
FIRST_DIGIT="${SCHEMA_VERSION%%.*}"
RELEASE_BRANCH="release-v${FIRST_DIGIT}"
DEVFILE_REPO="[email protected]: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"
Expand Down Expand Up @@ -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
Expand All @@ -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}"
}

Expand All @@ -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
Expand Down

0 comments on commit 211084c

Please sign in to comment.