Skip to content

Commit

Permalink
add script bump_fastjson2_version:
Browse files Browse the repository at this point in the history
usage:

$ bump_fastjson2_version 2.0.2-SNAPSHOT
  • Loading branch information
oldratlee committed Apr 25, 2022
1 parent 7e98850 commit 1c0216c
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions scripts/bump_fastjson2_version
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"

0 comments on commit 1c0216c

Please sign in to comment.