From 2bdb53e77937996c9435509d95e9f0ba7378cede Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Sun, 1 Oct 2023 16:11:24 +0900 Subject: [PATCH] fix release script --- scripts/release.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index 04edf4e..8f4bff2 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -17,7 +17,22 @@ if [ `git symbolic-ref --short HEAD` != 'main' ]; then fi if [ "$(git status -s | grep "${APPLICATION_INFO_FILE}")" = '' ]; then - echo "\e[31m${APPLICATION_INFO_FILE} is not modified.\e[m" + CURRENT_VERSION=$(swift run "$EXECUTABLE_NAME" --version) + read "NEXT_VERSION?Next version(current: $(echo "\e[1m${CURRENT_VERSION}\e[m")) > " + if [ "${NEXT_VERSION}" = '' ]; then + NEXT_VERSION="${CURRENT_VERSION}" + fi + if [[ ! "${NEXT_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$ ]]; then + echo "\e[31m[Error] Invalid version format.\e[m" + exit 1 + fi + + sed -i '' -E "s/let version = \"(.*)\"/let version = \"${NEXT_VERSION}\"/" "${APPLICATION_INFO_FILE}" +fi + +if [ "$(git tag | grep "$(swift run "$EXECUTABLE_NAME" --version)")" != '' ]; then + echo "\e[31m${NEXT_VERSION} is already tagged.\e[m" + git checkout HEAD -- Sources/Common/ApplicationInfo.swift exit 1 fi