From 3518728b1590b4984451dd4ff778a38ad0a0b509 Mon Sep 17 00:00:00 2001 From: lyxell Date: Thu, 8 Jul 2021 09:40:20 +0200 Subject: [PATCH] chore: Update release script --- scripts/create_release.sh | 56 +++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/scripts/create_release.sh b/scripts/create_release.sh index 358fb9c5..4b15baef 100755 --- a/scripts/create_release.sh +++ b/scripts/create_release.sh @@ -6,25 +6,41 @@ pattern='^v([0-9]+)\.([0-9]+)\.([0-9]+)' current_version=$(git describe --tags --abbrev=0) -if [[ $current_version =~ $pattern ]]; then +[[ $current_version =~ $pattern ]] + +if [[ "$1" = "major" ]]; then + next_version="v$((BASH_REMATCH[1]+1)).${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" +elif [[ "$1" = "minor" ]]; then next_version="v${BASH_REMATCH[1]}.$((BASH_REMATCH[2]+1)).${BASH_REMATCH[3]}" - git tag $next_version - rm -rf GithubRelease - mkdir GithubRelease - cd GithubRelease - cmake -DCMAKE_BUILD_TYPE=Release ../.. - make - # Make sure that the tests pass - make test - # test that binary outputs correct version - [[ "$(./logifix --version)" = "$next_version" ]] - # check linked libraries - ldd ./logifix - read -p "Looks ok? " -n 1 -r - echo # (optional) move to a new line - [[ $REPLY =~ ^[Yy]$ ]] - # create tarball - tarball="logifix-$next_version-x86_64-linux-gnu.tar.gz" - tar -cvzf $tarball logifix - gh release create --title $next_version --draft $next_version $tarball +elif [[ "$1" = "patch" ]]; then + next_version="v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((BASH_REMATCH[3]+1))" +fi + +if [[ -z $next_version ]]; then + echo "specify major, minor or patch" + exit 1 fi + +echo "Creating version $next_version" + +read -p "Looks ok? Answer y/n" -n 1 -r +[[ $REPLY =~ ^[Yy]$ ]] + +git tag $next_version +rm -rf GithubRelease +mkdir GithubRelease +cd GithubRelease +cmake -DCMAKE_BUILD_TYPE=Release ../.. +make +# Make sure that the tests pass +make test +# test that binary outputs correct version +[[ "$(./logifix --version)" = "$next_version" ]] +# check linked libraries +ldd ./logifix +read -p "Looks ok? Answer y/n" -n 1 -r +[[ $REPLY =~ ^[Yy]$ ]] +# create tarball +tarball="logifix-$next_version-x86_64-linux-gnu.tar.gz" +tar -cvzf $tarball logifix +gh release create --title $next_version --draft $next_version $tarball