From 2bef635e21a8d200247ac3bc83efb8d4cb430c6c Mon Sep 17 00:00:00 2001 From: Ariel Demarco Date: Fri, 6 Sep 2024 13:36:55 -0300 Subject: [PATCH 1/2] Created promote-release script to prevent issues --- bin/promote_release | 38 ++++++++++++++++++++++++++++++++++++++ bin/version_bump | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 bin/promote_release diff --git a/bin/promote_release b/bin/promote_release new file mode 100755 index 00000000..90597e04 --- /dev/null +++ b/bin/promote_release @@ -0,0 +1,38 @@ +#!/bin/bash + +function print_usage { + echo "Usage: promote_release " + echo "" + echo "Arguments:" + echo " The version number of the release to promote (semver format)" +} + +# Validate received parameters +if [ $# -eq 0 ]; then + printf "[ERROR] No arguments were provided\n" + print_usage + exit 1 +fi + +RC_VERSION=$1 + +# Validate version format: check if it's semver compliant +if ! [[ "$RC_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Version number '$RC_VERSION' is not in semver format." + exit 1 +fi + +echo "Preparing to promote release version: $RC_VERSION" + +# Bump version +bash "$(dirname "$(realpath "$0")")/version_bump" $RC_VERSION || exit 1 + +# Get current branch, tag, commit & push +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +git tag $RC_VERSION || { echo "Error: Failed to create tag."; exit 1; } + +git add EmbraceIO.podspec \ + Sources/EmbraceCommonInternal/EmbraceMeta.swift + +git commit -m "Bumps version to '$RC_VERSION'" +git push origin $CURRENT_BRANCH --tags diff --git a/bin/version_bump b/bin/version_bump index 49edc872..c99cbcd3 100755 --- a/bin/version_bump +++ b/bin/version_bump @@ -42,7 +42,7 @@ create_meta_file() { // Copyright © 2024 Embrace Mobile, Inc. All rights reserved. // -// This file is automatically generated by the "${BASH_SOURCE[0]}" script +// This file is automatically generated by the '$(basename "$0")' script // Do not edit this file manually public class EmbraceMeta { From 3f10034b3b6073c1951228fb51ab0adb95fbe837 Mon Sep 17 00:00:00 2001 From: Ariel Demarco Date: Fri, 6 Sep 2024 15:05:23 -0300 Subject: [PATCH 2/2] Moved tagging after doing commit --- bin/promote_release | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/promote_release b/bin/promote_release index 90597e04..f3b8122b 100755 --- a/bin/promote_release +++ b/bin/promote_release @@ -29,10 +29,12 @@ bash "$(dirname "$(realpath "$0")")/version_bump" $RC_VERSION || exit 1 # Get current branch, tag, commit & push CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -git tag $RC_VERSION || { echo "Error: Failed to create tag."; exit 1; } git add EmbraceIO.podspec \ Sources/EmbraceCommonInternal/EmbraceMeta.swift git commit -m "Bumps version to '$RC_VERSION'" + +git tag $RC_VERSION || { echo "Error: Failed to create tag."; exit 1; } + git push origin $CURRENT_BRANCH --tags