From 040bcca2cb656bf83b5133c54ac0cbac01ce9c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9AFAL=20bot?= Date: Tue, 15 Sep 2015 16:14:45 +0200 Subject: [PATCH] Fix build --- .travis.yml | 13 +++++++-- ci/github_release.sh | 0 ci/push_build.sh | 65 +++++++++++++++++--------------------------- gulp/release.js | 34 ++++++++--------------- 4 files changed, 47 insertions(+), 65 deletions(-) mode change 100644 => 100755 ci/github_release.sh mode change 100644 => 100755 ci/push_build.sh diff --git a/.travis.yml b/.travis.yml index 6377fda..7690a87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,11 @@ node_js: '0.11' before_install: - npm install && npm install bower - bower install +branches: + except: + - edge + - releases + - gh-pages addons: sauce_connect: true before_deploy: bash ./ci/github_release.sh @@ -16,12 +21,16 @@ deploy: - dist.zip skip_cleanup: true on: - tags: true + repo: ufal/lindat-common + all_branches: true + condition: '-n "$TRAVIS_TAG"' - provider: script script: bash ./ci/push_build.sh skip_cleanup: true on: - branch: master + repo: ufal/lindat-common + all_branches: true + condition: '-n "$TRAVIS_TAG" || "$TRAVIS_BRANCH" = "master"' cache: directories: - node_modules diff --git a/ci/github_release.sh b/ci/github_release.sh old mode 100644 new mode 100755 diff --git a/ci/push_build.sh b/ci/push_build.sh old mode 100644 new mode 100755 index cb2fbad..44044d1 --- a/ci/push_build.sh +++ b/ci/push_build.sh @@ -11,25 +11,32 @@ rev=$(git rev-parse --short HEAD) git_user="ÚFAL bot" git_email="lindat-technical@ufal.mff.cuni.cz" -pushd . +BRANCH=edge +COMMIT_MSG="Build based on ${rev}" -# Update pages -cp -u *.md pages/ -cd pages +if [ -z "$TRAVIS_TAG" ]; then + pushd . -git init -q -git config user.name "$git_user" -git config user.email "$git_email" + # Update pages + cp -u *.md pages/ + cd pages -touch . + git init -q + git config user.name "$git_user" + git config user.email "$git_email" -git add -A . -git commit -m "Rebuild Github pages at ${rev}" -git push --force -q "https://$GH_TOKEN@github.com/ufal/lindat-common.git" master:gh-pages > /dev/null 2>&1 + touch . -popd + git add -A . + git commit -m "Rebuild Github pages at ${rev}" + git push --force -q "https://$GH_TOKEN@github.com/ufal/lindat-common.git" master:gh-pages > /dev/null 2>&1 + + popd +else + BRANCH=releases + COMMIT_MSG="Releasing version ${TRAVIS_TAG}" +fi -# Update EDGE build cp -u *.md dist/ cp -u *.json dist/ cd dist @@ -37,6 +44,7 @@ cd dist # Fix paths for main files sed -i 's|dist/public/|public/|m' bower.json +git init -q git config user.name "$git_user" git config user.email "$git_email" @@ -44,41 +52,18 @@ touch . git remote add origin "https://$GH_TOKEN@github.com/ufal/lindat-common.git" # Fetch remote refs to a specific branch, equivalent to a pull without checkout -git fetch --update-head-ok origin edge:master +git fetch --update-head-ok origin $BRANCH:master # Make the current working tree the branch HEAD without checking out files git symbolic-ref HEAD refs/heads/master # Make sure the stage is clean # Track edge branch -git branch --set-upstream-to=origin/edge master +git branch --set-upstream-to=origin/$BRANCH master # Chech if there are things to commit STATUS=`git status --porcelain` if [ -n "$STATUS" ]; then git add -A . - git commit -m "Build based on ${rev}" - git push -q origin master:edge > /dev/null 2>&1 + git commit -m "$COMMIT_MSG" + git push -q origin master:$BRANCH > /dev/null 2>&1 fi - -if [ -z "$TRAVIS_TAG" ]; then - exit 0; -fi - -# Update release - only happens when tagging - -# Revert previous commit to edge -git reset --soft HEAD~1 -# Switch to releases -git fetch --update-head-ok origin releases:master -# Make the current working tree the branch HEAD without checking out files -git symbolic-ref HEAD refs/heads/master -# Make sure again the stage is clean -git reset - -# Track releases branch -git branch --set-upstream-to=origin/releases master - -# Add everything and commit -git add -A . -git commit -m "Releasing version ${TRAVIS_TAG}" -git push -q origin master:releases > /dev/null 2>&1 diff --git a/gulp/release.js b/gulp/release.js index 75d14f6..9311b9f 100644 --- a/gulp/release.js +++ b/gulp/release.js @@ -12,7 +12,7 @@ function getPackageJson() { return JSON.parse(fs.readFileSync('./package.json', 'utf8')); } -module.exports = function(options) { +module.exports = function() { function versioning() { if (argv.minor || argv.feature) { @@ -30,30 +30,18 @@ module.exports = function(options) { .pipe(gulp.dest('.')); }); - //gulp.task('add:dist', ['build'], function() { - // return gulp.src( options.dist + '/**') - // .pipe($.git.add({args: '--all -f'})); - //}); - - gulp.task('add', ['bump'], function() { - return gulp.src(files) - .pipe($.git.add()); - }); - - //gulp.task('add', ['add:dist', 'add:version']); - - gulp.task('tag', ['add'], function() { - return gulp.src('./package.json') - .pipe($.tagVersion()); - }); - - gulp.task('commit', ['tag'], function() { + gulp.task('add-and-commit', ['bump'], function(cb) { var pkg = getPackageJson(); - return gulp.src('.') - .pipe($.git.commit('Releasing version ' + pkg.version)); + gulp.src(files) + .pipe($.git.add()) + .pipe($.git.commit('Releasing version ' + pkg.version)) + .on('end', function () { + var tag = 'v'+pkg.version; + $.git.tag(tag, 'Tagging as ' + tag, cb); + }); }); - gulp.task('release', ['commit'], function(done) { - $.git.push('origin', 'master', {args: '--follow-tags'}, done); + gulp.task('release', ['add-and-commit'], function(cb) { + $.git.push('origin', 'master', {args: '--follow-tags'}, cb); }); };