Skip to content

Commit

Permalink
fix(scripts): New version and release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
obalunenko committed Dec 1, 2021
1 parent 6fa80e1 commit 3757e24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
23 changes: 14 additions & 9 deletions scripts/release/new-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,27 @@ function menu() {
printf "4 - Exit\n"
read -r selection


TAG_COMMIT=$(git rev-list --tags --max-count=1)
CURRENT_TAG=$(git describe --tags --always ${TAG_COMMIT})
if [ -z "${TAG_COMMIT}" ]
then
CURRENT_TAG="v0.0.0"
fi


case "$selection" in
1)
printf "Major updates......\n"
NEW_VERSION=$(git tag | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, ($1+1),0,0 }')
NEW_VERSION=$(echo "${CURRENT_TAG}" | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, ($1+1),0,0 }')
;;
2)
printf "Run Minor update.........\n"
NEW_VERSION=$(git tag | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,($2+1),0 }')
NEW_VERSION=$(echo "${CURRENT_TAG}" | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,($2+1),0 }')
;;
3)
printf "Patch update.........\n"
NEW_VERSION=$(git tag | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,$2,($3 + 1) }')
NEW_VERSION=$(echo "${CURRENT_TAG}" | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,$2,($3 + 1) }')
;;
4)
printf "Exit................................\n"
Expand All @@ -83,19 +92,15 @@ menu

NEW_TAG=${NEW_VERSION}

TAG_COMMIT=$(git rev-list --tags --max-count=1)
CURRENT_TAG=$(git describe --tags "${TAG_COMMIT}")
CHANGELOG="$(git log --pretty=format:"%s" HEAD..."${CURRENT_TAG}")"


echo "New version is: ${NEW_TAG}"

while true; do
echo "Is it ok? (:y)?:"
read -r yn
case $yn in
[Yy]*)

git tag -a "${NEW_TAG}" -m "${CHANGELOG}" && \
git tag -a "${NEW_TAG}" && \
git push --tags

break
Expand Down
3 changes: 2 additions & 1 deletion scripts/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ git fetch --tags -f
export BUILD_COMMIT=$(git rev-parse HEAD)
export BUILD_SHORTCOMMIT=$(git rev-parse --short HEAD)
export BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
export BUILD_VERSION=$(git describe --tags --always $(git rev-list --tags --max-count=1))
CURRENT_TAG_COMMIT=$(git rev-list --tags --max-count=1)
export BUILD_VERSION=$(git describe --tags --always ${CURRENT_TAG_COMMIT})

export BUILD_APPNAME=bitech-go-shared

Expand Down

0 comments on commit 3757e24

Please sign in to comment.