deploy.sh 2.57 KB
Newer Older
Antoine Regimbeau's avatar
Antoine Regimbeau committed
1 2 3
#!/bin/bash
# Configure git for tar.xz
git config tar.tar.xz.command "xz -c"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
4 5

pack_suffix=""
6
if [ $1 = "develop" ] # check if the branch name is develop or not
Antoine Regimbeau's avatar
Antoine Regimbeau committed
7 8 9 10
then # we are on develop
  jobs_directory=/home/otbpush/test/$(date +%F)
else # we are on a release branch
  jobs_directory=/home/otbpush/test/staging
11
  if [ "$#" -eq 2 ]
Antoine Regimbeau's avatar
Antoine Regimbeau committed
12
    then # there is a rc tag, we need a suffix for packages
Antoine Regimbeau's avatar
Antoine Regimbeau committed
13
    pack_suffix=-$(echo "$2" | grep -o "rc[0-9]*") # this retrieve the rc number
Antoine Regimbeau's avatar
Antoine Regimbeau committed
14 15 16 17 18 19
  fi
fi

echo "jobs_directory=${jobs_directory}"
echo "pack_suffix=${pack_suffix}"

Antoine Regimbeau's avatar
Antoine Regimbeau committed
20
# Create today's directory on serveur otb5-vm2
21
echo "Creating today's directory"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
22
ssh otbpush@otb5-vm2.orfeo-toolbox.org mkdir -p ${jobs_directory}
Antoine Regimbeau's avatar
Antoine Regimbeau committed
23
# Delete latest
24
echo "Deleting latest directory"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
if [ $1 = "develop" ]
then # On develop
  ssh otbpush@otb5-vm2.orfeo-toolbox.org rm -rf /home/otbpush/test/latest
  # Create symilink
  ssh otbpush@otb5-vm2.orfeo-toolbox.org ln -s ${jobs_directory} /home/otbpush/test/latest
  # Cleaning old directory
  matching_dirs=$(ls -1 | grep -oE '^20[0-9]{2}-[0-9]{2}-[0-9]{2}$' | sort)
  history_length=11
  rm -rf $(echo $matching_dirs | tr ' ' '\n' | head -n -${history_length})
else # On release
  # Remove what is inside staging area
  ssh otbpush@otb5-vm2.orfeo-toolbox.org rm -rf ${jobs_directory}/*
fi

Antoine Regimbeau's avatar
Antoine Regimbeau committed
39
# Push package
40
ls -all build_packages/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
41
echo "Renaming binary packages"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
42 43
# find build_packages/. -name "*.run" \
# -exec sh -c 'mv "$1" "${1%.run}${pack_suffix}.run"' _ {} \;
44
for name in $(find build_packages/. -name "OTB-*.*")
Antoine Regimbeau's avatar
Antoine Regimbeau committed
45
  do 
46 47
  len=(${#name})
  mv "$name" "${name:0:$len-4}${pack_suffix}${name:$len-4}"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
48
done
Antoine Regimbeau's avatar
Antoine Regimbeau committed
49 50
# TO REMOVE
###########
51
ls -all build_packages/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
52 53
###########

54
echo "Pushing binary packages"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
55
scp build_packages/OTB-*.{run,zip} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
56
# Push doc
57
echo "Pushing documentation"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
58
scp build/{CookBook-*-html.tar.gz,\
Antoine Regimbeau's avatar
Antoine Regimbeau committed
59
/Documentation/{Cookbook/latex/CookBook-*.pdf,Doxygen/OTB-Doxygen-*.tar.bz2}} \
Antoine Regimbeau's avatar
Antoine Regimbeau committed
60
otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/.
Antoine Regimbeau's avatar
Antoine Regimbeau committed
61 62

# Create zip, tar.gz and tar.xy source
63
echo "Creating source tarball and zip"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
64 65 66
git archive --format=zip -o OTB-sources-$CI_COMMIT_SHORT_SHA.zip HEAD
git archive --format=tgz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.gz HEAD
git archive --format=tar.xz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.xz HEAD
Antoine Regimbeau's avatar
Antoine Regimbeau committed
67
# Remove old source file
68
echo "Removing old sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
69
ssh otbpush@otb5-vm2.orfeo-toolbox.org \
Antoine Regimbeau's avatar
Antoine Regimbeau committed
70 71
rm ${jobs_directory}/OTB-sources-*.zip \
${jobs_directory}/OTB-sources-*.tar.*
Antoine Regimbeau's avatar
Antoine Regimbeau committed
72 73

# Push new source file
74
echo "Pushing new sources"
Antoine Regimbeau's avatar
Antoine Regimbeau committed
75 76
scp OTB-sources-$CI_COMMIT_SHORT_SHA.* \
otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/
Antoine Regimbeau's avatar
Antoine Regimbeau committed
77 78