Browse Source

For Travis CI - detect release tag and do the necessary automatically.

When a release tag is detected in a commit, instruct CI build to perform a released package build that uploaded into release directory instead of Snapshots directory.
Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
dce461469f
3 changed files with 17 additions and 2 deletions
  1. 1 0
      .travis.yml
  2. 12 1
      Rakefile
  3. 4 1
      Source/CMakeLists.txt

+ 1 - 0
.travis.yml

@@ -45,6 +45,7 @@ compiler: gcc
 before_install:
 before_install:
     - bash -c "[ '$TRAVIS_BRANCH' == 'master' ] && [ '$TRAVIS_PULL_REQUEST' == 'false' ]" && export ON_MASTER_COMMIT=1 && bash -c "[ $SITE_UPDATE ]" && export SITE_UPDATE_ON_MASTER_COMMIT=1 || true
     - bash -c "[ '$TRAVIS_BRANCH' == 'master' ] && [ '$TRAVIS_PULL_REQUEST' == 'false' ]" && export ON_MASTER_COMMIT=1 && bash -c "[ $SITE_UPDATE ]" && export SITE_UPDATE_ON_MASTER_COMMIT=1 || true
     - bash -c "[ $ON_MASTER_COMMIT ]" && export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT) && echo $COMMIT_MESSAGE |grep -cq '\[ci package\]' && git fetch --depth=2000 --tags origin $TRAVIS_BRANCH && export PACKAGE_UPLOAD=1 || true
     - bash -c "[ $ON_MASTER_COMMIT ]" && export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT) && echo $COMMIT_MESSAGE |grep -cq '\[ci package\]' && git fetch --depth=2000 --tags origin $TRAVIS_BRANCH && export PACKAGE_UPLOAD=1 || true
+    - bash -c "[ $ON_MASTER_COMMIT ]" && export RELEASE_TAG=$(git describe --tags --exact-match $TRAVIS_COMMIT 2>/dev/null) && bash -c "[ $RELEASE_TAG ]" && 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 "[ $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_ON_MASTER_COMMIT ] || [ $PACKAGE_UPLOAD ] )" && 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
     - sudo apt-get update -q -y

+ 12 - 1
Rakefile

@@ -130,9 +130,20 @@ task :travis_ci_package_upload do
   else
   else
     system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
     system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
   end
   end
+  # Determine the upload location
+  if ENV['RELEASE_TAG'].empty?
+    upload_dir = '/home/frs/project/urho3d/Urho3D/Snapshots'
+  else
+    upload_dir = "/home/frs/project/urho3d/Urho3D/#{ENV['RELEASE_TAG']}"
+    # Make sure the release directory exists remotely
+    system "sftp [email protected] <<EOF >/dev/null 2>&1
+mkdir #{upload_dir}
+bye
+EOF" or abort 'Failed to create release directory remotely'
+  end
   # Upload the package
   # Upload the package
   setup_digital_keys
   setup_digital_keys
-  system "scp #{platform_prefix}Build/Urho3D-* [email protected]:/home/frs/project/urho3d/Urho3D/Snapshots" or abort 'Failed to upload binary package'
+  system "scp #{platform_prefix}Build/Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload binary package'
   # Sync readme and license files, just in case they are updated in the repo
   # Sync readme and license files, just in case they are updated in the repo
   if ENV['SITE_UPDATE']
   if ENV['SITE_UPDATE']
     system 'for f in Readme.txt License.txt; do mtime=$(git log --format=%ai -n1 $f); touch -d "$mtime" $f; done' or abort 'Failed to acquire file modified time'
     system 'for f in Readme.txt License.txt; do mtime=$(git log --format=%ai -n1 $f); touch -d "$mtime" $f; done' or abort 'Failed to acquire file modified time'

+ 4 - 1
Source/CMakeLists.txt

@@ -110,7 +110,10 @@ endif ()
 if (ENABLE_64BIT)
 if (ENABLE_64BIT)
     set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-64bit)
     set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-64bit)
 endif ()
 endif ()
-set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-${URHO3D_LIB_TYPE}-snapshot)
+set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-${URHO3D_LIB_TYPE})
+if ("$ENV{RELEASE_TAG}" STREQUAL "")
+    set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-snapshot)
+endif ()
 include (CPack)
 include (CPack)
 
 
 # Add targets
 # Add targets