Skip to content

Commit

Permalink
Added prepare release script
Browse files Browse the repository at this point in the history
  • Loading branch information
kober32 committed Jan 25, 2024
1 parent b37df09 commit d9c96e8
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .limedeploy

This file was deleted.

111 changes: 111 additions & 0 deletions scripts/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9c96e8

Please sign in to comment.