From 6cc1a0723583817d1c1bad13db5167c07aa84aa2 Mon Sep 17 00:00:00 2001
From: archshift <gh@archshift.com>
Date: Fri, 6 Mar 2015 15:54:09 -0800
Subject: [PATCH] CI: upload builds to builds.citra-emu.org instead of MEGA

---
 .travis-build.sh  |  6 +++---
 .travis-deps.sh   |  4 ++--
 .travis-upload.sh | 29 +++++++++++++++++++++++++++++
 .travis.yml       |  7 +++++++
 appveyor.yml      | 39 ++++++++++++++++++++++++---------------
 upload_to_mega.js | 28 ----------------------------
 6 files changed, 65 insertions(+), 48 deletions(-)
 mode change 100644 => 100755 .travis-build.sh
 mode change 100644 => 100755 .travis-deps.sh
 create mode 100644 .travis-upload.sh
 delete mode 100644 upload_to_mega.js

diff --git a/.travis-build.sh b/.travis-build.sh
old mode 100644
new mode 100755
index b869b8b8f0..21582c6899
--- a/.travis-build.sh
+++ b/.travis-build.sh
@@ -4,13 +4,13 @@ set -e
 set -x
 
 #if OS is linux or is not set
-if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then 
+if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
     mkdir build && cd build
     cmake -DUSE_QT5=OFF .. 
     make -j4
-elif [ "$TRAVIS_OS_NAME" = osx ]; then
+elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
     export Qt5_DIR=$(brew --prefix)/opt/qt5
     mkdir build && cd build
     cmake .. -GXcode
-    xcodebuild
+    xcodebuild -configuration Release
 fi
diff --git a/.travis-deps.sh b/.travis-deps.sh
old mode 100644
new mode 100755
index bd09da0d0c..f8074fb91b
--- a/.travis-deps.sh
+++ b/.travis-deps.sh
@@ -4,7 +4,7 @@ set -e
 set -x
 
 #if OS is linux or is not set
-if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
+if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
     sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
     sudo apt-get -qq update
     sudo apt-get -qq install g++-4.9 xorg-dev libglu1-mesa-dev libxcursor-dev
@@ -23,7 +23,7 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
     sudo mkdir -p /usr/local
     curl http://www.cmake.org/files/v2.8/cmake-2.8.11-Linux-i386.tar.gz \
         | sudo tar -xz -C /usr/local --strip-components=1
-elif [ "$TRAVIS_OS_NAME" = osx ]; then
+elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
     brew tap homebrew/versions
     brew install qt5 glfw3 pkgconfig
 fi
diff --git a/.travis-upload.sh b/.travis-upload.sh
new file mode 100644
index 0000000000..4b9446a968
--- /dev/null
+++ b/.travis-upload.sh
@@ -0,0 +1,29 @@
+if [ "$TRAVIS_BRANCH" = "master" ]; then
+    GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
+    GITREV="`git show -s --format='%h'`"
+
+    if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
+        REV_NAME="citra-${GITDATE}-${GITREV}-linux-amd64"
+        UPLOAD_DIR="/citra/nightly/linux-amd64"
+        mkdir "$REV_NAME"
+        
+        sudo apt-get -qq install lftp
+        cp build/src/citra/citra "$REV_NAME"
+        cp build/src/citra_qt/citra-qt "$REV_NAME"
+    elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
+        REV_NAME="citra-${GITDATE}-${GITREV}-osx-amd64"
+        UPLOAD_DIR="/citra/nightly/osx-amd64"
+        mkdir "$REV_NAME"
+        
+        brew install lftp
+        cp build/src/citra/Release/citra "$REV_NAME"
+        cp -r build/src/citra_qt/Release/citra-qt.app "$REV_NAME"
+
+        # move qt libs into app bundle for deployment
+        $(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/citra-qt.app"
+    fi
+    
+    ARCHIVE_NAME="${REV_NAME}.tar.xz"
+    tar -cJvf "$ARCHIVE_NAME" "$REV_NAME"
+    lftp -c "open -u citra-builds,$BUILD_PASSWORD sftp://builds.citra-emu.org; put -O '$UPLOAD_DIR' '$ARCHIVE_NAME'"
+fi
diff --git a/.travis.yml b/.travis.yml
index 1cb369d5b3..b878cc1604 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,8 +4,15 @@ os:
 
 language: cpp
 
+env:
+  global:
+    - secure: "AXHFIafTmbGDsHD3mUVj5a4I397DQjti/WoqAJGUp2PglxTcc04BwxZ9Z+xLuf5N2Hs5r9ojAJLT8OGxJCLBDXzneQTNSqXbFuYSLbqrEAiIRlA9eRIotWCg+wYcO+5e8MKX+cHVKwiIWasUB21AtCdq6msh6Y3pUshZp212VPg=" 
+
 before_install:
  - sh .travis-deps.sh
 
 script:
  - sh .travis-build.sh
+
+after_success:
+ - sh .travis-upload.sh
diff --git a/appveyor.yml b/appveyor.yml
index c9edb9e198..ae22101ebc 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,10 +6,8 @@ clone_depth: 5
 
 environment:
   QTDIR: C:\Qt\5.4\msvc2013_64_opengl
-  MEGA_EMAIL:
-    secure: rEo9CGAYX87GKTqZCZ9vLCNCNqxO5JLgbERaHF3YJWg=
-  MEGA_PASSWORD:
-    secure: zE1zmgjS/6GfN/19ROl/O0fVR58svORQ5gdtsxI7J8k=
+  BUILD_PASSWORD:
+    secure: EXGNlWKJsCtbeImEJ5EP9qrxZ+EqUFfNy+CP61nDOMA=
 
 platform:
   - x64
@@ -27,11 +25,6 @@ before_build:
   - cd ..
 
 after_build:
-  # upload the build to Mega
-  - cinst wget -x86
-  - wget -q http://megatools.megous.com/builds/megatools-1.9.94-win64.zip
-    # extract megatools silently. See http://stackoverflow.com/a/11629736/1748450
-  - 7z x megatools-1.9.94-win64.zip | FIND /V "ing  "
     # copy the qt dlls
   - copy C:\Qt\5.4\msvc2013_64_opengl\bin\icudt53.dll build\bin\release
   - copy C:\Qt\5.4\msvc2013_64_opengl\bin\icuin53.dll build\bin\release
@@ -42,9 +35,25 @@ after_build:
   - copy C:\Qt\5.4\msvc2013_64_opengl\bin\Qt5Widgets.dll  build\bin\release
   - mkdir build\bin\release\platforms\
   - copy C:\Qt\5.4\msvc2013_64_opengl\plugins\platforms\qwindows.dll build\bin\release\platforms
-    # zip up the build folder -> build.7z
-  - 7z a build .\build\bin\release\*
-    # rename, upload to Mega
-  - npm install sanitize-filename
-  - cd megatools-1.9.94-win64
-  - node ..\upload_to_mega.js
+  
+  - ps: >
+        if (!"$env:APPVEYOR_PULL_REQUEST_TITLE" -and ("$env:APPVEYOR_REPO_BRANCH" -eq "master"))
+          {
+            $GITDATE = $(git show -s --date=short --format='%ad') -replace "-",""
+            $GITREV = git show -s --format='%h'
+            $BUILD_NAME = "citra-${GITDATE}-${GITREV}-windows-amd64.7z"
+            # zip up the build folder
+            7z a $BUILD_NAME .\build\bin\release\*
+            
+            # download winscp
+            Invoke-WebRequest "http://hivelocity.dl.sourceforge.net/project/winscp/WinSCP/5.7/winscp570.zip" -OutFile "winscp570.zip"
+            7z e -y winscp570.zip
+            
+            # upload to server
+            .\WinSCP.com /command `
+                "option batch abort" `
+                "option confirm off" `
+                "open sftp://citra-builds:${env:BUILD_PASSWORD}@builds.citra-emu.org -hostkey=*" `
+                "put $BUILD_NAME /citra/nightly/windows-amd64/" `
+                "exit"
+          }
diff --git a/upload_to_mega.js b/upload_to_mega.js
deleted file mode 100644
index c0abd5ed51..0000000000
--- a/upload_to_mega.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var util = require('util');
-var exec = require('child_process').exec;
-var sanitize = require("sanitize-filename");
-
-var email = process.env.MEGA_EMAIL;
-var password = process.env.MEGA_PASSWORD;
-var sourceFileName = 'build.7z';
-var dstFileName = process.env.APPVEYOR_REPO_COMMIT.substring(0, 8) + " - " + 
-                process.env.APPVEYOR_REPO_COMMIT_MESSAGE.substring(0, 100) + ".7z";
-dstFileName = sanitize(dstFileName);
-
-var cmd = util.format('megaput ../%s --path \"/Root/Citra/Windows/%s\" --username=%s --password=%s --no-progress',
-                        sourceFileName,
-                        dstFileName,
-                        email,
-                        password);
-
-// only upload build on master branch, and not on other branches or PRs
-if (process.env.APPVEYOR_REPO_BRANCH == "master") {
-    console.log("Uploading file " + dstFileName + " to Mega...");
-    exec(cmd, function(error, stdout, stderr) {
-        console.log('stdout: ' + stdout);
-        console.log('stderr: ' + stderr);
-        if (error !== null) {
-            console.log('exec error: ' + error);
-        }
-    });            
-}
-- 
GitLab