Travis CI: Implement automatic deployment of prebuilt versions on each commit, and caching of assets and NVM.

Builds are deployed to prebuilt/dist an prebuilt/module branches.
This commit is contained in:
Jürg Lehni 2016-01-30 02:56:05 +01:00
parent 90e1cf8f5e
commit 834d2303a6
8 changed files with 155 additions and 24 deletions

View file

@ -1,30 +1,42 @@
language: node_js
node_js:
- '4'
- stable
- '4'
sudo: false
env:
matrix:
- CXX=g++-4.9
global:
- secure: QD8wgggmlF0PPOSdQ84JLO9quLMlTDXu3Cg0+UM9yFSyih2ukL/XGn5wxR3B3XmaHfzRqxtrfhjMX6LT7DKFsriolhNVu0kER4zGyrKWK5irxAy2veosyj8qs/R1pXh9qnItlgXrz0fJwpH9o/08q8X+ZjXb0veZ34EMODLbV5zBJXoaHVC6WN62GzInAEEfdB0AEacb44sDIdK++1ujcTFLGnc+LJw8Ck2C/eOWwRhJyiNUrHHTQV3KaM0YtHz+DCz5InC9vWl+BG656AOU5C6PMTvnZ1M3CGfjmXydZoBbDvCQIcB5ylf17tXGoJKevHnmLWm6U3fPVwUwiPiKvisxyNShZw4BEDS7m1b799GnzGOiYsi37aH3G+iAORg1QVqoCAK/yQ77MkkA6a3tlLVHRaInVA6QlFxlbqc8WNlx+fa8lo4L7Y9KPGfr1Bpix/kHQV5JCzKS16Zc7wblTrOvIR/qb8qPfLoxhXi5fUZ3eRuXgR699X1IHJ1LlhkOoBfSiWl88qba01FBLrYSCPeVGb6/N91OFpIlq6eORnzBbc4mtoJSYttvZ45Hu3M5V0KDrGIHr7kNyPThdKr7PVaMXHLCpNrnmBSaxVCU5uhb8Ae3bnLAq/aBxHWZNA8cQ43/s6rS7QqOVJfquXNFYa6V9/QjbU3sJyqIgRzMkAM=
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
- git-core
packages:
- g++-4.9
- libcairo2-dev
- libpango1.0-dev
- libssl-dev
- libjpeg62-dev
- libgif-dev
before_script:
- npm install -g gulp
- npm install
script:
- gulp jshint
- gulp minify
- gulp test
- g++-4.9
- git
- libcairo2-dev
- libpango1.0-dev
- libssl-dev
- libjpeg62-dev
- libgif-dev
cache:
directories:
- ~/.assets
- ~/.nvm
- node_modules
install:
- |
wget http://sourceforge.net/p/tellmatic/git/ci/master/tree/img/arial.ttf?format=raw -O arial.ttf
mkdir -p ~/.fonts
mv arial.ttf ~/.fonts
fc-cache -f -v
- travis/install-assets.sh
before_script:
- travis/setup-git.sh
- npm set progress=false
- which gulp || npm install -g gulp
- npm install
script:
- gulp jshint
- gulp minify
- gulp test
- gulp dist
after_script:
- '[ "${TRAVIS_BRANCH}" = "develop" ] && [ "${TRAVIS_NODE_VERSION}" = "stable" ] && travis/deploy-prebuilt.sh'

View file

@ -70,7 +70,7 @@ buildNames.forEach(function(name) {
gulp.task('clean:build:' + name, function() {
return del([
'dist/paper-' + name + '.js'
'dist/paper-' + name + '*.js'
]);
});
});

View file

@ -11,10 +11,11 @@
*/
var gulp = require('gulp'),
del = require('del'),
merge = require('merge-stream'),
zip = require('gulp-zip');
gulp.task('dist', ['minify', 'docs'], function() {
gulp.task('dist', ['minify', 'docs', 'clean:dist'], function() {
return merge(
gulp.src([
'dist/paper-full*.js',
@ -26,6 +27,12 @@ gulp.task('dist', ['minify', 'docs'], function() {
'dist/docs/**/*'
], { base: 'dist' })
)
.pipe(zip('/paperjs.zip'))
.pipe(zip('paperjs.zip'))
.pipe(gulp.dest('dist'));
});
gulp.task('clean:dist', function() {
return del([
'dist/paperjs.zip'
]);
});

View file

@ -36,6 +36,6 @@ gulp.task('test:node', ['minify:acorn'], function(callback) {
// present and handles the loading transparently.
{ path: '../dist/paper-full.js', namespace: 'paper' }
],
timeout: 20
timeout: 40
}));
});

View file

@ -14,6 +14,9 @@
"path": "../gulp",
"folder_exclude_patterns": ["jsdoc"]
},
{
"path": "../travis",
},
{
"path": "..",
"name": "root",

54
travis/deploy-prebuilt.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/bash
#
# Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
# http://paperjs.org/
#
# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
# http://scratchdisk.com/ & http://jonathanpuckey.com/
#
# Distributed under the MIT license. See LICENSE file for details.
#
# All rights reserved.
# Determine target for commit messages.
if [ -n "${TRAVIS_TAG}" ]; then
TARGET=$TRAVIS_TAG
else
TARGET="commit ${TRAVIS_COMMIT}"
fi
# Set up a temporary folder to prepare distribution files.
TMP=~/tmp
mkdir $TMP
# Copy everything to the this folder first, then clean up.
cp -a dist $TMP/
# Copy all visible root files (LICENSE.txt, README.md, package.json, etc.).
cp -p *.* $TMP/
# No need for .gitignore or build files.
rm $TMP/dist/.gitignore
rm $TMP/gulpfile.js
# Reset the branch so we can switch to prebuilt/module and prebuilt/dist after.
git clean -fdx --quiet # Remove all ignored and untracked files from the build.
git checkout -- . # Reset all tracked files to the original state.
# Create a new orphaned buid/dist branch and switch to it.
git checkout --orphan prebuilt/dist
# Remove and delete all tracked files left after the switch.
git rm -rf --quiet .
# Move the zipped dist file into the branch and commit.
mv $TMP/dist/paperjs.zip .
git add --all *
git commit -m "Prebuilt package for ${TARGET}"
# Push with --force since we're always overriding the previous built version.
git push -u origin prebuilt/dist --force
# Specifically fetch and check out the prebuilt/module branch from origin.
git fetch origin +refs/heads/prebuilt/module:refs/remotes/origin/prebuilt/module
git checkout -b prebuilt/module -t origin/prebuilt/module
# Remove everything so we can fully replace it. Git will create the diffs.
rm -fr *
mv $TMP/* .
git add --all *
git commit -m "Prebuilt module for ${TARGET}"
git push -u origin prebuilt/module
rmdir $TMP

23
travis/install-assets.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
#
# Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
# http://paperjs.org/
#
# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
# http://scratchdisk.com/ & http://jonathanpuckey.com/
#
# Distributed under the MIT license. See LICENSE file for details.
#
# All rights reserved.
# Download and instal assets, but only if they haven't been installed from the
# cache yet.
if [ ! -d ~/.assets ] || [ -z "$(ls -A ~/.assets)" ]; then
mkdir -p ~/.assets
wget http://sourceforge.net/p/tellmatic/git/ci/master/tree/img/arial.ttf?format=raw -O ~/.assets/arial.ttf
fi
# Install fonts each time, as they can't be cached in Travis.
mkdir -p ~/.fonts
cp -p ~/.assets/arial.ttf ~/.fonts
fc-cache -f -v

32
travis/setup-git.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
#
# Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
# http://paperjs.org/
#
# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
# http://scratchdisk.com/ & http://jonathanpuckey.com/
#
# Distributed under the MIT license. See LICENSE file for details.
#
# All rights reserved.
# Setup the git user with the right credentials so we can push to the paper.js
# repository. The GH_TOKEN is generated as a secure environment variable:
#
# travis encrypt GH_TOKEN=<TOKEN> --add
git config user.name "Paper.js Bot"
git config user.email "bot@paperjs.org"
git config credential.helper "store --file=.git/credentials"
echo "https://${GH_TOKEN}:@github.com" > .git/credentials
# It took ages to figures this one out:
# Travis CI sets up the origin to only fetch the specific branch, e.g.:
# fetch = +refs/heads/develop:refs/remotes/origin/develop
# Since we want to deploy to prebuilt/module also, we need to change that:
# fetch = +refs/heads/*:refs/remotes/origin/*
# We can change the fetch setting by removing and adding the origin again:
git remote remove origin
git remote add origin https://github.com/paperjs/paper.js.git
# Avoid detached head...
git checkout $TRAVIS_BRANCH