Skip to content

Commit

Permalink
Updates jib-core release script to accept version suffixes. (GoogleCo…
Browse files Browse the repository at this point in the history
  • Loading branch information
coollog authored Oct 11, 2018
1 parent 4bd31f0 commit e942c1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
26 changes: 13 additions & 13 deletions jib-core/scripts/prepare_release.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@

set -e

Colorize() {
echo "$(tput setff $2)$1$(tput sgr0)"
}

EchoRed() {
echo "$(tput setaf 1; tput bold)$1$(tput sgr0)"
echo "$(tput setaf 1; tput bold)$1$(tput sgr0)"
}
EchoGreen() {
echo "$(tput setaf 2; tput bold)$1$(tput sgr0)"
echo "$(tput setaf 2; tput bold)$1$(tput sgr0)"
}

Die() {
EchoRed "$1"
exit 1
EchoRed "$1"
exit 1
}

DieUsage() {
Die "Usage: ./scripts/prepare_release.sh <release version>"
Die "Usage: ./prepare_release.sh <release version> [<post-release-version>]"
}

# Usage: CheckVersion <version>
CheckVersion() {
[[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || Die "Version not in ###.###.### format."
[[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+)?$ ]] || Die "Version: $1 not in ###.###.###[-XXX] format."
}

[ $# -ne 2 ] || DieUsage
[ $# -ne 1 ] && [ $# -ne 2 ] && DieUsage

EchoGreen '===== RELEASE SETUP SCRIPT ====='

VERSION=$1
CheckVersion ${VERSION}
if [ -n "$2" ]; then
POST_RELEASE_VERSION=$2
CheckVersion ${POST_RELEASE_VERSION}
fi

if [[ $(git status -uno --porcelain) ]]; then
Die 'There are uncommitted changes.'
Die 'There are uncommitted changes.'
fi

# Runs integration tests.
Expand All @@ -47,7 +47,7 @@ BRANCH=core_release_v${VERSION}
git checkout -b ${BRANCH}

# Changes the version for release and creates the commits/tags.
echo | ./gradlew release -PreleaseVersion=${VERSION}
echo | ./gradlew release -Prelease.releaseVersion=${VERSION} ${POST_RELEASE_VERSION:+"-Prelease.newVersion=${POST_RELEASE_VERSION}"}

# Pushes the release branch and tag to Github.
git push origin ${BRANCH}
Expand Down
28 changes: 12 additions & 16 deletions jib-maven-plugin/scripts/prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,36 @@

set -e

Colorize() {
echo "$(tput setff $2)$1$(tput sgr0)"
}

EchoRed() {
echo "$(tput setaf 1; tput bold)$1$(tput sgr0)"
echo "$(tput setaf 1; tput bold)$1$(tput sgr0)"
}
EchoGreen() {
echo "$(tput setaf 2; tput bold)$1$(tput sgr0)"
echo "$(tput setaf 2; tput bold)$1$(tput sgr0)"
}

Die() {
EchoRed "$1"
exit 1
EchoRed "$1"
exit 1
}

DieUsage() {
Die "Usage: ./scripts/prepare_release.sh <release version>"
Die "Usage: ./scripts/prepare_release.sh <release version> [<post-release-version>]"
}

# Usage: CheckVersion <version>
CheckVersion() {
[[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || Die "Version not in ###.###.### format."
[[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+)?$ ]] || Die "Version: $1 not in ###.###.###[-XXX] format."
}

# Usage: IncrementVersion <version>
IncrementVersion() {
local version=$1
local minorVersion=$(echo $version | sed 's/[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]\)*/\1/')
local nextMinorVersion=$((minorVersion+1))
echo $version | sed "s/\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*/\1.$nextMinorVersion/"
local version=$1
local minorVersion=$(echo $version | sed 's/[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]\)*/\1/')
local nextMinorVersion=$((minorVersion+1))
echo $version | sed "s/\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*/\1.$nextMinorVersion/"
}

[ $# -ne 2 ] || DieUsage
[ $# -ne 1 ] && [ $# -ne 2 ] && DieUsage

EchoGreen '===== RELEASE SETUP SCRIPT ====='

Expand All @@ -47,7 +43,7 @@ NEXT_VERSION=$(IncrementVersion $VERSION)
CheckVersion ${NEXT_VERSION}

if [[ $(git status -uno --porcelain) ]]; then
Die 'There are uncommitted changes.'
Die 'There are uncommitted changes.'
fi

# Runs integration tests.
Expand Down

0 comments on commit e942c1a

Please sign in to comment.