Browse Source

For Travis CI - attempt to make packages on demand. [ci package]

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
89836f11fc
3 changed files with 27 additions and 14 deletions
  1. 7 3
      .travis.yml
  2. 19 10
      Rakefile
  3. 1 1
      Source/CMakeLists.txt

+ 7 - 3
.travis.yml

@@ -40,15 +40,19 @@ env:
 language: cpp
 compiler: gcc
 before_install:
+    - bash -c "[ $SITE_UPDATE ] && [ '$TRAVIS_BRANCH' == 'master' ] && [ '$TRAVIS_PULL_REQUEST' == 'false' ]" && export SITE_UPDATE_ON_MASTER_COMMIT=1 || true
+    - bash -c "msg=$(git log --format=%%B -n 1 $TRAVIS_COMMIT); [[ '$msg' =~ '[ci package]' ]]" && export PACKAGE_UPLOAD=1 || true
     - bash -c "[ $ANDROID ]" && wget -q http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 && tar xjf *.bz2 && rm *.bz2 && ln -s android-ndk* android-ndk && export ANDROID_NDK=$(pwd)/android-ndk || true
-    - bash -c "[ $SITE_UPDATE ] && [ $TRAVIS_PULL_REQUEST == 'false' ]" && sudo add-apt-repository ppa:george-edison55/precise-backports -y || true
+    - bash -c "( [ $SITE_UPDATE_ON_MASTER_COMMIT ] || [ $PACKAGE_UPLOAD ] )" && sudo add-apt-repository ppa:george-edison55/precise-backports -y || true
     - sudo apt-get update -q -y
 install:
     - sudo apt-get install -q -y --no-install-recommends libasound2-dev
     - rvm gemset use global && gem install rake
     - bash -c "[ x$ENABLE_64BIT == 'x' ]" && sudo apt-get remove -q -y gvfs-daemons && sudo apt-get install -q -y libxrandr-dev:i386 libgl1-mesa-dev:i386 libxext-dev:i386 libxrender-dev:i386 g++-multilib && export CMAKE_PREFIX_PATH=/usr/lib/i386-linux-gnu || true
-    - bash -c "[ $SITE_UPDATE ] && [ $TRAVIS_PULL_REQUEST == 'false' ]" && sudo apt-get install -q -y --no-install-recommends doxygen graphviz || true
+    - bash -c "( [ $SITE_UPDATE_ON_MASTER_COMMIT ] || [ $PACKAGE_UPLOAD ] )" && sudo apt-get install -q -y --no-install-recommends doxygen graphviz || true
     - bash -c "[ $WINDOWS ]" && sudo apt-get install -q -y gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 binutils-mingw-w64 binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 && export MINGW_PREFIX=/usr/bin/x86_64-w64 MINGW_ROOT=/usr/x86_64-w64-mingw32 || true
     - bash -e /etc/init.d/xvfb start
 script: rake travis_ci
-after_success: rake travis_ci_site_update && rake travis_ci_rebase
+after_success:
+    - bash -c "[ $SITE_UPDATE_ON_MASTER_COMMIT ]" && rake travis_ci_site_update && rake travis_ci_rebase
+    - bash -c "[ $PACKAGE_UPLOAD ]" && rake travis_ci_package_upload

+ 19 - 10
Rakefile

@@ -56,13 +56,9 @@ task :travis_ci do
   end
 end
 
-# Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... TRAVIS_BRANCH=master SITE_UPDATE=1 rake travis_ci_site_update)
+# Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_site_update)
 desc 'Update site documentation to GitHub Pages'
 task :travis_ci_site_update do
-  # Skip documentation update if one of the following conditions is met
-  if ENV['TRAVIS_PULL_REQUEST'].to_i > 0 or ENV['TRAVIS_BRANCH'] != 'master' or ENV['SITE_UPDATE'] != '1'
-    abort
-  end
   # Pull or clone
   system 'cd doc-Build 2>/dev/null && git pull -q -r || git clone -q https://github.com/urho3d/urho3d.github.io.git doc-Build' or abort 'Failed to pull/clone'
   # Update credits from Readme.txt to about.md
@@ -78,16 +74,29 @@ task :travis_ci_site_update do
   system "pwd && git config user.name '#{ENV['GIT_NAME']}' && git config user.email '#{ENV['GIT_EMAIL']}' && git remote set-url --push origin https://#{ENV['GH_TOKEN']}@github.com/urho3d/Urho3D.git && git add Docs/*API* && ( git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci skip]' || true ) && git push origin HEAD:master -q >/dev/null 2>&1" or abort 'Failed to update API documentation'
 end
 
-# Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... TRAVIS_BRANCH=master SITE_UPDATE=1 rake travis_ci_rebase)
+# Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_rebase)
 desc 'Rebase OSX-CI mirror branch'
 task :travis_ci_rebase do
-  # Skip rebase if one of the following conditions is met
-  if ENV['TRAVIS_PULL_REQUEST'].to_i > 0 or ENV['TRAVIS_BRANCH'] != 'master' or ENV['SITE_UPDATE'] != '1'
-    abort
-  end
   system "git config user.name '#{ENV['GIT_NAME']}' && git config user.email '#{ENV['GIT_EMAIL']}' && git remote set-url --push origin https://#{ENV['GH_TOKEN']}@github.com/urho3d/Urho3D.git && git fetch origin OSX-CI:OSX-CI && git rebase origin/master OSX-CI && git push -qf -u origin OSX-CI >/dev/null 2>&1"
 end
 
+# Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
+desc 'Make binary package and upload it to a designated central hosting server'
+task :travis_ci_package_upload do
+  if ENV['ANDROID']
+    platform_prefix = 'android-'
+  elsif ENV['WINDOWS']
+    platform_prefix = 'mingw-'
+  elsif ENV['IOS']
+    platform_prefix = 'ios-'
+  else
+    platform_prefix = ''
+  end
+  system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
+  # \todo: upload the package
+  system "ls -l #{platform_prefix}Build/Urho3D-*"
+end
+
 def scaffolding(dir)
   system "bash -c \"mkdir -p #{dir}/{Source,Bin} && cp Source/Tools/Urho3DPlayer/Urho3DPlayer.* #{dir}/Source && for f in {.,}*.sh; do ln -sf `pwd`/\\$f #{dir}; done && ln -sf `pwd`/Bin/{Core,}Data #{dir}/Bin\" && cat <<EOF >#{dir}/Source/CMakeLists.txt
 # Set project name

+ 1 - 1
Source/CMakeLists.txt

@@ -100,7 +100,7 @@ elseif (RASPI)
 elseif (IOS)
     set (CPACK_SYSTEM_NAME IOS)
 elseif (WIN32)
-    set (CPACK_GENERATOR ZIP) 
+    set (CPACK_GENERATOR ZIP)
 endif ()
 if (ENABLE_64BIT)
     set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-64bit)