From 931f924189c06b9e421f5f07d01a4c1615bf76bd Mon Sep 17 00:00:00 2001 From: Kurnianto Trilaksono Date: Sun, 24 Mar 2024 15:22:04 +0800 Subject: [PATCH] add helper script for releasing --- releasing/check-release-helper.sh | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 releasing/check-release-helper.sh diff --git a/releasing/check-release-helper.sh b/releasing/check-release-helper.sh new file mode 100755 index 000000000..2ae9c7ca1 --- /dev/null +++ b/releasing/check-release-helper.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +declare PATCH=false +declare MINOR=false +declare MAJOR=false +declare rc=0 + +git log $(git describe --tags --abbrev=0)..HEAD --oneline | tee /tmp/release-changelogs.txt + +if [[ $(cat /tmp/release-changelogs.txt | grep fix) || $(cat /tmp/release-changelogs.txt | grep patch) ]]; then + PATCH=true +fi + +if [[ $(cat /tmp/release-changelogs.txt | grep feat) ]]; then + MINOR=true +fi + +for f in $(find api); do + git diff --exit-code "${f}" + if [ $? -eq 1 ]; then + echo "Found changes on api dir at ${f}" + rc=1 + exit 1 + fi +done + +if [ $rc -eq 1 ]; then + MAJOR=true +fi + +echo -e "\n" +echo -e "=================================================================================" + +if [[ $MAJOR == false && $MINOR == false ]]; then + echo "Release type: patch" +elif [[ $MAJOR == false && $MINOR == true ]]; then + echo "Release type: minor" +else + echo "Release type: major" +fi \ No newline at end of file