From bd596710f527a55aa05bbb5c2544d09f5ea716b0 Mon Sep 17 00:00:00 2001
From: Antoine Regimbeau <antoine.regimbeau@c-s.fr>
Date: Wed, 19 Jun 2019 10:53:28 +0200
Subject: [PATCH] Add a deploy script

---
 .gitlab-ci.yml |  4 +++-
 CI/deploy.sh   | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100755 CI/deploy.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b5fc7756d5..b58b7f75c4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -62,11 +62,12 @@ fast-build:
   after_script:
     - python3 CI/cdash_handler.py
   artifacts:
-    when: on_failure
+    when: always
     expire_in: 24 hrs
     paths:
       - build/*/*.log #CMake log
       - log/*.txt # Others
+      - packages-*.run # binary packages
 
 debian-build:
   extends: .common-build
@@ -113,6 +114,7 @@ ubuntu-superbuild-build:
       - build/CookBook-*-html.tar.gz
       - build/Documentation/Cookbook/latex/CookBook-*.pdf
       - build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2
+      - build_packages/OTB-*.run
 
 ## CentOS superbuild
 centos-superbuild-prepare:
diff --git a/CI/deploy.sh b/CI/deploy.sh
new file mode 100755
index 0000000000..d35f27ebbf
--- /dev/null
+++ b/CI/deploy.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Configure git for tar.xz
+git config tar.tar.xz.command "xz -c"
+# Create today's directory on serveur otb5-vm2
+ssh otbpush@otb5-vm2.orfeo-toolbox.org mkdir -p /home/otbpush/test/$(date +%F)
+# Delete latest
+ssh otbpush@otb5-vm2.orfeo-toolbox.org rm -rf /home/otbpush/test/latest
+# Create symilink
+ssh otbpush@otb5-vm2.orfeo-toolbox.org ln -s /home/otbpush/test/$(date +%F) /home/otbpush/test/latest
+# Push package
+scp build_packages/*.run otbpush@otb5-vm2.orfeo-toolbox.org:/home/otbpush/test/$(date +%F)/.
+# Push doc
+scp build/{CookBook-*-html.tar.gz,\
+/Documentation/{Cookbook/latex/CookBook-*.pdf,\
+Documentation/Doxygen/OTB-Doxygen-*.tar.bz2}} \
+otbpush@otb5-vm2.orfeo-toolbox.org:/home/otbpush/test/$(date +%F)/.
+
+# Create zip, tar.gz and tar.xy source
+git archive --format=zip -o OTB-develop-$CI_COMMIT_SHORT_SHA.zip HEAD
+git archive --format=tgz -o OTB-develop-$CI_COMMIT_SHORT_SHA.tar.gz HEAD
+git archive --format=tar.xz -o OTB-develop-$CI_COMMIT_SHORT_SHA.tar.xz HEAD
+# Remove old source file
+ssh otbpush@otb5-vm2.orfeo-toolbox.org \
+rm /home/otbpush/test/$(date +%F)/OTB-develop-*.zip \
+/home/otbpush/test/$(date +%F)/OTB-develop-*.tar.*
+
+# Push new source file
+scp OTB-develop-$CI_COMMIT_SHORT_SHA.* \
+otbpush@otb5-vm2.orfeo-toolbox.org:/home/otbpush/test/$(date +%F)/
+
+ 
\ No newline at end of file
-- 
GitLab