Skip to content
Snippets Groups Projects
Commit fdea9c2f authored by al.schwinn's avatar al.schwinn
Browse files

create tags / branches with release-script

parent 9588c066
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,76 @@
# $ source releaseSilecs.sh
#
# release a new version v1.0.0
# $ release 1.0.0 /common/usr/cscofe/silecs /home/bel/schwinn/lnx/git
# $ release 1.0.0 /home/bel/schwinn/lnx/git /common/usr/cscofe/silecs
#
# patch 2 packages of an existing version 1.2.3
# $ patch silecs-codegen 1.2.4 1.2.3 /common/usr/cscofe/silecs /home/bel/schwinn/lnx/git
# $ patch silecs-model 1.2.4 1.2.3 /common/usr/cscofe/silecs /home/bel/schwinn/lnx/git
# patch two packages of an existing version 1.2.3, resulting of a installation of 1.2.4
# $ patch silecs-codegen 1.2.3 /home/bel/schwinn/lnx/git /common/usr/cscofe/silecs
# $ patch silecs-model 1.2.3 /home/bel/schwinn/lnx/git /common/usr/cscofe/silecs
#
# release a new version of the silecs-eclipse plugin
# $ plugin_release /common/usr/cscofe/silecs /home/bel/schwinn/lnx/git-silecs-plugin
# $ plugin_release /home/bel/schwinn/lnx/git-silecs-plugin /common/usr/cscofe/silecs
# List of silecs packages which can be released or patched
PACKAGES="silecs-codegen silecs-model silecs-communication-cpp silecs-diagnostic-cpp silecs-cli-client snap7"
# branch to release
RELEASE_BRANCH=gsi
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
validateBranch()
{
REQUIRED_BRANCH=$1
CURRENT_BRANCH = $(git branch | grep \* | cut -d ' ' -f2)
if [ "$CURRENT_BRANCH" != "$REQUIRED_BRANCH" ]; then
echo "Error: Release only can be done if branch '${REQUIRED_BRANCH}' is checked out."
echo "Installation cancelled."
return 1
fi
git fetch
if [ $LOCAL = $REMOTE ]; then
echo "branch is identical with remote"
return 0
elif [ $LOCAL = $BASE ]; then
echo "Error: Pull required on branch '${RELEASE_BRANCH}'"
echo "Installation cancelled."
return 1
elif [ $REMOTE = $BASE ]; then
echo "Error: Push required on branch '${RELEASE_BRANCH}'"
echo "Installation cancelled."
return 1
else
echo "Error: branch '${RELEASE_BRANCH}' is diverged"
echo "Installation cancelled."
return 1
fi
}
createAndPushReleaseBranch()
{
BRANCH_NAME=$1
# TODO: check if already exists
git ls-remote --heads <remote-name> ${BRANCH_NAME} | wc -l
git checkout -b ${BRANCH_NAME}
git push ${BRANCH_NAME}
}
createAndPushTag()
{
TAG_NAME=$1
# TODO: check if already exists
git ls-remote <remote-name> refs/tags/<TAG_NAME>
git tag ${TAG_NAME}
git push origin ${TAG_NAME}
}
# Check that folder exists, print proper error if not
checkFolderExists()
{
......@@ -30,8 +88,9 @@ checkFolderExists()
release()
{
VERSION=$1
RELEASE_DIR_BASE=$2
WORKSPACE=$3
WORKSPACE=$2
RELEASE_DIR_BASE=$3
checkFolderExists ${WORKSPACE}
for PACKAGE in $PACKAGES; do
......@@ -52,8 +111,9 @@ plugin_release()
{
(
set -e
RELEASE_DIR_BASE=$1
WORKSPACE=$2
WORKSPACE=$1
RELEASE_DIR_BASE=$2
PACKAGE=silecs-eclipse-plugin-update-site
INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}
checkFolderExists ${WORKSPACE}/${PACKAGE}
......@@ -62,17 +122,35 @@ plugin_release()
return 0
)
}
increment_version ()
{
declare -a part=( ${1//\./ } )
declare new
declare -i carry=1
for (( CNTR=${#part[@]}-1; CNTR>=0; CNTR-=1 )); do
len=${#part[CNTR]}
new=$((part[CNTR]+carry))
[ ${#new} -gt $len ] && carry=1 || carry=0
[ $CNTR -gt 0 ] && part[CNTR]=${new: -len} || part[CNTR]=${new}
done
new="${part[*]}"
echo -e "${new// /.}"
}
# releases a specific package to release-dir. For all other packages symlinks to the base-version are generated
patch()
{
PACKAGE_TO_PATCH=$1
NEW_VERSION=$2
BASE_VERSION=$3
RELEASE_DIR_BASE=$4
WORKSPACE=$5
BASE_VERSION=$2
WORKSPACE=$4
RELEASE_DIR_BASE=$5
checkFolderExists ${WORKSPACE}
NEW_VERSION=$(increment_version $BASE_VERSION)
echo "New version will be: '$NEW_VERSION'"
for PACKAGE in $PACKAGES; do
INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${NEW_VERSION}
BASE_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${BASE_VERSION}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment