Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ufalbot authored and m1ch4ls committed Sep 16, 2015
1 parent c8e50e8 commit 040bcca
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 65 deletions.
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Empty file modified ci/github_release.sh
100644 → 100755
Empty file.
65 changes: 25 additions & 40 deletions ci/push_build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,59 @@ rev=$(git rev-parse --short HEAD)
git_user="ÚFAL bot"
git_email="[email protected]"

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

# 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"

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
34 changes: 11 additions & 23 deletions gulp/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
});
};

0 comments on commit 040bcca

Please sign in to comment.