Sfoglia il codice sorgente

For Travis CI - upload snapshot source packages to FRS.
Test [ci package].

Yao Wei Tjong 姚伟忠 11 anni fa
parent
commit
7c014df6dd
1 ha cambiato i file con 17 aggiunte e 9 eliminazioni
  1. 17 9
      Rakefile

+ 17 - 9
Rakefile

@@ -78,7 +78,7 @@ task :travis_ci_site_update do
   # Generate and sync doxygen pages
   # Generate and sync doxygen pages
   system "cd Build && make -j$NUMJOBS doc >/dev/null 2>&1 && rsync -a --delete ../Docs/html/ ../doc-Build/documentation" or abort 'Failed to generate/rsync doxygen pages'
   system "cd Build && make -j$NUMJOBS doc >/dev/null 2>&1 && rsync -a --delete ../Docs/html/ ../doc-Build/documentation" or abort 'Failed to generate/rsync doxygen pages'
   # Supply GIT credentials and push site documentation to urho3d/urho3d.github.io.git
   # Supply GIT credentials and push site documentation to urho3d/urho3d.github.io.git
-  system "cd doc-Build && 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.github.io.git && git add -A . && ( git commit -q -m \"Travis CI: site documentation update at #{Time.now.utc}.\n\nCommit: https://github.com/urho3d/Urho3D/commit/$TRAVIS_COMMIT\n\nMessage: $COMMIT_MESSAGE\" || true) && git push -q >/dev/null 2>&1" or abort 'Failed to update site'
+  system "cd doc-Build && pwd && git config user.name '$GIT_NAME' && git config user.email '$GIT_EMAIL' && git remote set-url --push origin https://$GH_TOKEN@github.com/urho3d/urho3d.github.io.git && git add -A . && ( git commit -q -m \"Travis CI: site documentation update at #{Time.now.utc}.\n\nCommit: https://github.com/$TRAVIS_REPO_SLUG/commit/$TRAVIS_COMMIT\n\nMessage: $COMMIT_MESSAGE\" || true) && git push -q >/dev/null 2>&1" or abort 'Failed to update site'
   # Automatically give instruction to do packaging when API has changed, unless the instruction is already given in this commit
   # Automatically give instruction to do packaging when API has changed, unless the instruction is already given in this commit
   if ENV['PACKAGE_UPLOAD']
   if ENV['PACKAGE_UPLOAD']
     instruction = 'skip'
     instruction = 'skip'
@@ -86,13 +86,13 @@ task :travis_ci_site_update do
     instruction = 'package'
     instruction = 'package'
   end
   end
   # Supply GIT credentials and push API documentation to urho3d/Urho3D.git (the push may not be successful if detached HEAD is not a fast forward of remote master)
   # Supply GIT credentials and push API documentation to urho3d/Urho3D.git (the push may not be successful if detached HEAD is not a fast forward of remote master)
-  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 #{instruction}]' || true ) && git push origin HEAD:master -q >/dev/null 2>&1" or abort 'Failed to update API documentation, most likely due to remote master has diverged, the API documentation update will be performed again in the subsequent CI build'
+  system "pwd && git config user.name '$GIT_NAME' && git config user.email '$GIT_EMAIL' && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git && git add Docs/*API* && ( git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]' || true ) && git push origin HEAD:master -q >/dev/null 2>&1" or abort 'Failed to update API documentation, most likely due to remote master has diverged, the API documentation update will be performed again in the subsequent CI build'
 end
 end
 
 
 # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... 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'
 desc 'Rebase OSX-CI mirror branch'
 task :travis_ci_rebase do
 task :travis_ci_rebase do
-  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/#{ENV['TRAVIS_REPO_SLUG']}.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" or abort 'Failed to rebase OSX-CI mirror branch'
+  system "git config user.name '$GIT_NAME' && git config user.email '$GIT_EMAIL' && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.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" or abort 'Failed to rebase OSX-CI mirror branch'
 end
 end
 
 
 # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
 # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
@@ -145,9 +145,11 @@ task :travis_ci_package_upload do
   # Determine the upload location
   # Determine the upload location
   setup_digital_keys
   setup_digital_keys
   if ENV['RELEASE_TAG'].empty?
   if ENV['RELEASE_TAG'].empty?
-    upload_dir = '/home/frs/project/urho3d/Urho3D/Snapshots'
-    # Only keep the snapshots from the last +/- 50 revisions
+    upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/Snapshots"
     if ENV['SITE_UPDATE']
     if ENV['SITE_UPDATE']
+      # Download source packages from GitHub
+      system 'SNAPSHOP_VER=`git describe`; export SNAPSHOP_VER && wget https://github.com/$TRAVIS_REPO_SLUG/tarball/$TRAVIS_COMMIT -O Urho3D-$SNAPSHOP_VER-Source-snapshot.tar.gz && wget https://github.com/$TRAVIS_REPO_SLUG/zipball/$TRAVIS_COMMIT -O Urho3D-$SNAPSHOP_VER-Source-snapshot.zip' or abort 'Failed to get source packages'
+      # Only keep the snapshots from the last +/- 50 revisions
       # The package revisions and their creation time may not always be in perfect chronological order due to Travis-CI build latency, so sort the final result one more time in order to get a unique revision removal list
       # The package revisions and their creation time may not always be in perfect chronological order due to Travis-CI build latency, so sort the final result one more time in order to get a unique revision removal list
       system "for v in $(sftp [email protected] <<EOF |tr ' ' '\n' |grep Urho3D- |cut -d '-' -f1,2 |uniq |tail -n +51 |sort |uniq
       system "for v in $(sftp [email protected] <<EOF |tr ' ' '\n' |grep Urho3D- |cut -d '-' -f1,2 |uniq |tail -n +51 |sort |uniq
 cd #{upload_dir}
 cd #{upload_dir}
@@ -157,8 +159,12 @@ EOF
 ); do echo rm #{upload_dir}/${v}*; done |sftp -b - [email protected]" or abort 'Failed to housekeep snapshots'
 ); do echo rm #{upload_dir}/${v}*; done |sftp -b - [email protected]" or abort 'Failed to housekeep snapshots'
     end
     end
   else
   else
-    upload_dir = "/home/frs/project/urho3d/Urho3D/#{ENV['RELEASE_TAG']}"
-    # Make sure the release directory exists remotely
+    upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/#{ENV['RELEASE_TAG']}"
+    if ENV['SITE_UPDATE']
+      # Download source packages from GitHub
+      system 'wget https://github.com/$TRAVIS_REPO_SLUG/archive/$RELEASE_TAG.tar.gz -O Urho3D-$RELEASE_TAG-Source.tar.gz && wget https://github.com/$TRAVIS_REPO_SLUG/archive/$RELEASE_TAG.zip -O Urho3D-$RELEASE_TAG-Source.zip' or abort 'Failed to get source packages'
+    end
+    # Make sure the release directory exists remotely, do this in all the build jobs as we don't know which one would start uploading first
     system "sftp [email protected] <<EOF >/dev/null 2>&1
     system "sftp [email protected] <<EOF >/dev/null 2>&1
 mkdir #{upload_dir}
 mkdir #{upload_dir}
 bye
 bye
@@ -166,10 +172,12 @@ EOF" or abort 'Failed to create release directory remotely'
   end
   end
   # Upload the package
   # Upload the package
   system "scp #{platform_prefix}Build/Urho3D-* [email protected]:#{upload_dir}" 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
   if ENV['SITE_UPDATE']
   if ENV['SITE_UPDATE']
+    # Upload the source package
+    system "scp Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload source package'
+    # Sync readme and license files, just in case they are updated in the repo
     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'
-    system 'rsync -e ssh -az Readme.txt License.txt [email protected]:/home/frs/project/urho3d/Urho3D' or abort 'Failed to sync readme and license files'
+    system 'rsync -e ssh -az Readme.txt License.txt [email protected]:/home/frs/project/$TRAVIS_REPO_SLUG' or abort 'Failed to sync readme and license files'
   end
   end
 end
 end