setup_ci.sh 1.92 KB
Newer Older
eric pellegrini's avatar
eric pellegrini committed
1
2
3
4
5
6
7
8
9
#!/bin/bash

if [ -z ${CI_PROJECT_DIR} ]; then
    export CI_PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
fi

export CI_TEMP_DIR=${CI_PROJECT_DIR}/temp

export CI_TEMP_BUILD_DIR=${CI_PROJECT_DIR}/temp/build
10
export CI_TEMP_BUILD_DIR=${CI_PROJECT_DIR}/build
eric pellegrini's avatar
eric pellegrini committed
11
12
13

export CI_TEMP_INSTALL_DIR=${CI_PROJECT_DIR}/temp/install

14
export PYTHONPATH=${CI_TEMP_INSTALL_DIR}/lib/python2.7/site-packages/:${PYTHONPATH}
eric pellegrini's avatar
eric pellegrini committed
15
16
17
18
19

mkdir -p ${CI_TEMP_DIR}

cd ${CI_PROJECT_DIR}

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Get revision number from Git
CI_COMMIT_ID=${CI_COMMIT_SHORT_SHA}
#if [ -z ${CI_COMMIT_SHA} ]; then
#    export CI_COMMIT_ID=$(git rev-parse HEAD)
#else
#    export CI_COMMIT_ID=${CI_COMMIT_SHA}
#fi
#export CI_COMMIT_ID=${CI_COMMIT_ID:0:8}
#
## Get commit branch from Gitlab
#if [ -z ${CI_COMMIT_REF_NAME} ]; then
#    CI_COMMIT_REF_NAME=$(git show -s --pretty=%d HEAD)
#    CI_COMMIT_REF_NAME=$(echo ${CI_COMMIT_REF_NAME} | rev | cut -d, -f1 | cut -c2- | cut -d/ -f1 | rev)
#    export CI_COMMIT_REF_NAME
#fi
#
eric pellegrini's avatar
eric pellegrini committed
36
37
38

echo -e "${BLUE}""Commit id = ${CI_COMMIT_ID}""${NORMAL}"
echo -e "${BLUE}""Branch name = ${CI_COMMIT_REF_NAME}""${NORMAL}"
39

40
PKG_INFO=${CI_PROJECT_DIR}/Src/__pkginfo__.py
41
42

# Update the __pkginfo__ file with the current commit
eric pellegrini's avatar
eric pellegrini committed
43
"${SED_I_COMMAND[@]}" "s/.*__commit__.*/__commit__ = \"${CI_COMMIT_ID}\"/" ${PKG_INFO}
44
45
46
47
48
49
50
51

# Get MDANSE version
MDANSE_VERSION=`sed -n 's/__version__.*=.*\"\(.*\)\"/\1/p' ${PKG_INFO}`

# Check if branch is master
if [[ ${CI_COMMIT_REF_NAME} == "master" ]]
then
    VERSION_NAME=${MDANSE_VERSION}
eric pellegrini's avatar
eric pellegrini committed
52
    "${SED_I_COMMAND[@]}" "s/.*__beta__.*/__beta__ = None/" ${PKG_INFO}
53
54
55
56
57
else
    # Check if branch is release*
	if [[ ${CI_COMMIT_REF_NAME::7} == "release" ]]
	then
	    VERSION_NAME=${MDANSE_VERSION}-rc-${CI_COMMIT_ID}
eric pellegrini's avatar
eric pellegrini committed
58
	    "${SED_I_COMMAND[@]}" "s/.*__beta__.*/__beta__ = \"rc\"/" ${PKG_INFO}
59
60
	else
	    VERSION_NAME=${MDANSE_VERSION}-beta-${CI_COMMIT_ID}
eric pellegrini's avatar
eric pellegrini committed
61
	    "${SED_I_COMMAND[@]}" "s/.*__beta__.*/__beta__ = \"beta\"/" ${PKG_INFO}
62
63
64
	fi
fi
export VERSION_NAME