Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE: Automate release scripts #100

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions 1_release_upstream_bom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

# Releases a new BOM based on a new Spring Boot version
# Updates the boosters for this new BOM so that they can be tested
set -e

# Defining some colors for output
RED='\033[0;31m'
NC='\033[0m' # No Color
BLUE='\033[0;34m'

simple_log() {
echo -e "${BLUE}${1}${NC}"
}

# get the directory of the script
CMD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"

# create a temporary directory WORK_DIR to be removed at the exit of the script
# see: https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory
# ====
WORK_DIR=$(mktemp -d)

# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
simple_log "Could not create temp directory"
exit 1
fi

# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
}

# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
# ====


error() {
echo -e "${RED}Error: ${1}${NC}"
exit ${2:-1}
}

# compute BOM branch based on provided SB version
simple_log "Releases a new BOM based on the specified Spring Boot version in the x.y.zz form."
simple_log "Updates the boosters for this new BOM so that they can be tested."
declare -r sbVersion=${1?"Must provide a target Spring Boot version in the x.y.zz form"}
if [[ ${sbVersion} =~ ([1-9].[0-9]).([0-9]+) ]]; then
sbMajorVersion="${BASH_REMATCH[1]}"
bomBranch="sb-${sbMajorVersion}.x"
nextBOMVersion="${sbMajorVersion}.$((BASH_REMATCH[2] + 1))-SNAPSHOT"
else
error "Unsupported Spring Boot version: ${sbVersion}" 1>&2
fi

# Clone BOM project in temp dir
cd ${WORK_DIR}
git clone [email protected]:snowdrop/spring-boot-bom.git >/dev/null 2>/dev/null
pushd spring-boot-bom
git checkout ${bomBranch}

# update the BOM based on SB version (presumably other dependencies have already been updated)
pushd ${CMD_DIR}/src/
groovy update-pom.groovy ${WORK_DIR}/spring-boot-bom/pom.xml ${sbVersion} "hibernate.version=,hibernate-validator.version="
popd
mvn install
# TODO: Update BOM README notably to update Spring Boot version

# release the BOM
releaseVersion="${sbVersion}.Final"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The qualifier should also be a parameter I would say

mvn -B release:prepare -Prelease -Dtag="${releaseVersion}" -DreleaseVersion="${releaseVersion}" -DdevelopmentVersion="${nextBOMVersion}"
mvn release:perform -Prelease
popd

# update the boosters for the new SB version
./for-all-boosters.sh -pn -l boosters-release set_maven_property -v "spring-boot-bom.version" "${releaseVersion}"
./for-all-boosters.sh -f -l boosters-release set_maven_property -v "spring-boot.version" "${sbVersion}"
./for-all-boosters.sh -f -l boosters-release change_version -v "${sbVersion}-1-SNAPSHOT"




37 changes: 37 additions & 0 deletions 2_release_boosters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e

# Defining some colors for output
NC='\033[0m' # No Color
BLUE='\033[0;34m'

simple_log() {
echo -e "${BLUE}${1}${NC}"
}

# create a temporary directory WORK_DIR to be removed at the exit of the script
# see: https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory
# ====
WORK_DIR=$(mktemp -d)

# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
simple_log "Could not create temp directory"
exit 1
fi

# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
}

# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
# ====

simple_log "Script to release the boosters once QA has validated them with the prod BOM."
simple_log "You need to be connected to the VPN to be able to successfully run this script."

declare -r sbVersion=${1?"Must provide a target Spring Boot version in the x.y.zz form"}
for-all-boosters.sh -pn -l ${WORK_DIR}/boosters-release release ${sbVersion}
for-all-boosters.sh -f -l ${WORK_DIR}/boosters-release catalog ${sbVersion}
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Scripts to process boosters

## `1_release_upstream_bom.sh`

A script that performs an upstream BOM release when a new Spring Boot version is released and updates the boosters accordingly.
The script will automatically update the Spring Boot-defined dependencies in the BOM but it is still required to update manually
any other dependencies such as Spring Cloud dependencies. It will also update the boosters to use the newly released Spring Boot
and BOM and change their version according to the versioning scheme.

## `2_release_boosters.sh`

Releases the boosters once the productized BOM has been validated by QE, tagging both the community and productized versions.
The script will then use these newly released versions to generate a launcher-catalog pull request updating the boosters version
and Spring Boot runtime.

## `for-all-boosters`

A script that operates on all boosters under the `snowdrop` organization that have the `booster` topic attached to them
Expand All @@ -20,6 +33,7 @@ when all the boosters are processed.
* oc
* jq
* yq (see instructions to download [here](https://github.com/kislyuk/yq))
* hub (https://github.com/github/hub)

### Examples

Expand Down Expand Up @@ -56,7 +70,7 @@ when all the boosters are processed.

`./for-all-boosters.sh -f -b foo cmd -p "Made some change" "/home/scripts/adhoc.py"`

Due to the presense of the `-f` flag, before running the command the script will show a warning if local changes exist (to remove the warning add the `-n` flag)
Due to the presence of the `-f` flag, before running the command the script will show a warning if local changes exist (to remove the warning add the `-n` flag)
Any changes that the `adhoc.py` script makes to the booster files will automatically be committed using the message specified in `-p` and pushed to the `foo` branch (which needs to exist)

* This command will execute the `fmp_deploy` function found in the script on the `redhat` branch of the `crud` booster
Expand Down
11 changes: 9 additions & 2 deletions for-all-boosters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ release() {

local -r currentVersion=$(evaluate_mvn_expr 'project.version')

local -r pncBuildQualifier=${1:-CR1}
local -r releaseSBVersion=${1?"Usage: release <Spring Boot version associated with the release (for validation purposes)>"}
local -r pncBuildQualifier=${2:-CR1}

if [[ "${currentVersion}" != *-SNAPSHOT ]]; then
log_ignored "Cannot release a non-snapshot version"
Expand All @@ -529,6 +530,11 @@ release() {
local -a components
eval $(parse_version ${currentVersion})
local -r sbVersion=${components[0]}

if [ "${releaseSBVersion}" != "${sbVersion}" ]; then
log_failed "Booster uses Spring Boot version ${sbVersion} while release specified Spring Boot version ${releaseSBVersion}"
fi

local -r versionInt=${components[1]}
local -r newVersionInt=$((versionInt + 1))
local qualifier=${components[2]}
Expand Down Expand Up @@ -1253,7 +1259,8 @@ case "$subcommand" in
log_failed "The dry-run option is not supported for the release command"
exit 1
fi
cmd="release"
shift
cmd="release ${1}"
branches=( "master" )
echo -e "${YELLOW}== Release only works on the '${BLUE}master${YELLOW}' branch, disregarding any branch set by -b option ==${NC}"
echo
Expand Down