From d9c96e8d26b04f7382b3dd8c28c70575b8df2000 Mon Sep 17 00:00:00 2001 From: Jan Kobersky Date: Thu, 25 Jan 2024 14:49:32 +0100 Subject: [PATCH] Added prepare release script --- .limedeploy | 3 - scripts/prepare-release.sh | 111 +++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 3 deletions(-) delete mode 100644 .limedeploy create mode 100755 scripts/prepare-release.sh diff --git a/.limedeploy b/.limedeploy deleted file mode 100644 index 678c41f..0000000 --- a/.limedeploy +++ /dev/null @@ -1,3 +0,0 @@ -DEPLOY_POD_NAME='WultraMobileTokenSDK' -DEPLOY_VERSIONING_FILES=( "Deploy/WultraMobileTokenSDK.podspec,WultraMobileTokenSDK.podspec" "Deploy/Info.plist,WultraMobileTokenSDK/Info.plist" ) -DEPLOY_MODE='cocoapods' \ No newline at end of file diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh new file mode 100755 index 0000000..1f752d9 --- /dev/null +++ b/scripts/prepare-release.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +set -e # stop sript when error occures +set -u # stop when undefined variable is used + +############################################################################### +# This script prepares a release with provided version +# ---------------------------------------------------------------------------- + +TOP=$(dirname $0) +SRC_ROOT="`( cd \"$TOP/..\" && pwd )`" +DO_COMMIT=0 +DO_PUSH=0 +DO_RELEASE=0 +VERSION= +VERSIONING_FILES=( + "Deploy/WultraMobileTokenSDK.podspec,${SRC_ROOT}/WultraMobileTokenSDK.podspec" + "Deploy/Info.plist,${SRC_ROOT}/WultraMobileTokenSDK/Info.plist" +) + +function USAGE +{ + echo "" + echo "Usage: prepare-release.sh [options] version" + echo "" + echo "options are:" + echo "" + echo " -c | --commit commit changed files and create tag" + echo "" + echo " -p | --push push commits and tags" + echo "" + echo " -r | --release release to CocoaPods" + echo "" + echo " -h | --help prints this help information" + echo "" + exit $1 +} + +while [[ $# -gt 0 ]] +do + opt="$1" + case "$opt" in + -c | --commit) + DO_COMMIT=1 + ;; + -h | --help) + USAGE 0 + ;; + -p | --push) + DO_PUSH=1 + ;; + -r | --release) + DO_RELEASE=1 + ;; + *) + VERSION=$opt + ;; + esac + shift +done + +if [ -z "${VERSION}" ]; then + echo "You have to provide version string." + exit 1 +fi + +echo "Settings version to ${VERSION}." + +pushd $SRC_ROOT + +for (( i=0; i<${#VERSIONING_FILES[@]}; i++ )); +do + patch_info="${VERSIONING_FILES[$i]}" + files=(${patch_info//,/ }) + template="${files[0]}" + target="${files[1]}" + if [ ! -f "$template" ]; then + echo "Template file not found: ${template}" + exit 1 + fi + if [ ! -f "$target" ]; then + echo "Target should exist: ${target}" + exit 1 + fi + + echo " + ${target}" + sed -e "s/%DEPLOY_VERSION%/$VERSION/g" "${template}" > "${target}" + if [ x$DO_COMMIT == x1 ]; then + git add "${target}" + fi +done + +popd + +pushd "${SRC_ROOT}" + +if [ x$DO_COMMIT == x1 ]; then + git commit -m "Bumped version to ${VERSION}" + git tag "${VERSION}" +fi + +if [ x$DO_PUSH == x1 ]; then + git push --tags +fi + +if [ x$DO_RELEASE == x1 ]; then + pod lib lint + pod trunk push +fi + +popd