-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usage: $ bump_fastjson2_version 2.0.2-SNAPSHOT
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
set -eEuo pipefail | ||
|
||
################################################################################ | ||
# util functions | ||
################################################################################ | ||
|
||
# NOTE: $'foo' is the escape sequence syntax of bash | ||
readonly ec=$'\033' # escape char | ||
readonly eend=$'\033[0m' # escape end | ||
readonly nl=$'\n' # new line | ||
|
||
colorEcho() { | ||
local color=$1 | ||
shift | ||
|
||
# if stdout is the console, turn on color output. | ||
[ -t 1 ] && echo "${ec}[1;${color}m$*${eend}" || echo "$*" | ||
} | ||
|
||
redEcho() { | ||
colorEcho 31 "$@" | ||
} | ||
|
||
yellowEcho() { | ||
colorEcho 33 "$@" | ||
} | ||
|
||
blueEcho() { | ||
colorEcho 36 "$@" | ||
} | ||
|
||
logAndRun() { | ||
local simple_mode=false | ||
[ "$1" = "-s" ] && { | ||
simple_mode=true | ||
shift | ||
} | ||
|
||
if $simple_mode; then | ||
echo "Run under work directory $PWD : $*" | ||
"$@" | ||
else | ||
blueEcho "Run under work directory $PWD :$nl$*" | ||
time "$@" | ||
fi | ||
} | ||
|
||
die() { | ||
redEcho "Error: $*" 1>&2 | ||
exit 1 | ||
} | ||
|
||
################################################################################ | ||
# biz logic | ||
################################################################################ | ||
|
||
# shellcheck disable=SC2154 | ||
[ $# -ne 1 ] && die "need only 1 argument for version!$nl${nl}usage:$nl $0 1.x.y" | ||
readonly bump_version="$1" | ||
|
||
# adjust current dir to project root dir | ||
cd "$(dirname "$(readlink -f "$0")")/.." | ||
|
||
# bump pom version | ||
./mvnw \ | ||
org.codehaus.mojo:versions-maven-plugin:2.10.0:set \ | ||
-DgenerateBackupPoms=false \ | ||
-DnewVersion="$bump_version" |