From 78a0d4e4e7313b737824ddd40769f2791c4060d7 Mon Sep 17 00:00:00 2001 From: Jonas Zaugg Date: Thu, 4 Feb 2021 14:29:03 +0100 Subject: [PATCH] Checks SemVer and default to force tagging --- Configurations/make-release-package.sh | 2 ++ Configurations/release-move-tag.sh | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index c32059eb..f9348007 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -90,6 +90,8 @@ if [ "$ACTION" = "" ] ; then # Get latest git tag cd "$SRCROOT" latest_git_tag=$(git describe --abbrev=0) + # Check semantic versioning + [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]] && echo "Tag $latest_git_tag follows semantic versioning" || echo "WARNING: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" # Generate new Package manifest cd "$CONFIGURATION_BUILD_DIR" cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR" diff --git a/Configurations/release-move-tag.sh b/Configurations/release-move-tag.sh index 5f3e029e..7a5edbcb 100755 --- a/Configurations/release-move-tag.sh +++ b/Configurations/release-move-tag.sh @@ -10,9 +10,11 @@ if [ "$commits_since_tag" -gt 0 ]; then echo "Package.swift has not been committed and tag has not been moved." else # TODO: add sanity check to see if version is actually being updated or not? - read -p "Do you want to commit changes to Package.swift and force move tag '$latest_git_tag'? (required for SPM release) [y/N]" -n 1 -r + read -p "Do you want to commit changes to Package.swift and force move tag '$latest_git_tag'? (required for SPM release) [Y/n]" -n 1 -r echo # (optional) move to a new line - if [[ $REPLY =~ ^[Yy]$ ]]; then + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo "Package.swift has not been committed and tag has not been moved." + else long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message long_message=${long_message/$latest_git_tag} # trims tag name long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace @@ -20,7 +22,5 @@ else git commit -m "Update Package.swift" git tag -fa $latest_git_tag -m "${long_message}" echo "Package.swift committed and tag '$latest_git_tag' moved." - else - echo "Package.swift has not been committed and tag has not been moved." fi fi