From 98ddb5782865346e05081158e464d5d78565ef2d Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Fri, 27 Mar 2015 21:58:51 -0500 Subject: [PATCH 1/2] Let Travis publish bower-chosen On master commits, bower-publish.sh will push all changes in compiled files straight to harvesthq/bower-chosen. If Chosen's version has changed, the repo will also get tagged with the latest version. Science! --- .gitignore | 1 + .travis.yml | 10 ++++++++-- Gruntfile.coffee | 13 +++---------- bower-publish.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100755 bower-publish.sh diff --git a/.gitignore b/.gitignore index b8e63227fd3..c8bffc1b8fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules .project public/*.js public/*.css +public/bower.json chosen.zip .sass-cache .ruby-version diff --git a/.travis.yml b/.travis.yml index 0d4a81ce593..37b5a3e2f89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,12 @@ node_js: - "0.10" before_install: - - npm install -g grunt-cli - - gem install compass + - npm install -g grunt-cli + - gem install compass before_script: grunt build + +after_success: ./bower-publish.sh + +env: + global: + secure: WbrrS9cR3vpRXtPp/YdtsKZHwWkTDBaqPdXh6+rasQf1pvKfjPaL1bVFDomxsppIa6RjVJyTxJDU4sYnsemop/0vlSs+YuF1e+iPXfzc/javpvk9CIelrXrktehCXxVEZqkTKIAd6OGo668pfov24F5RmaSCr5hQLd6buNIVApo= diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 6626b2abf8e..e6b9061519a 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -90,20 +90,13 @@ This file is generated by `grunt build`, do not edit it by hand. options: base: 'public', message: "Updated to new Chosen version #{version()}" - 'gh-pages': - src: ['**'] - 'bower': - options: - repo: 'https://github.com/harvesthq/bower-chosen' - tag: version_tag() - src: ['bower.json', 'chosen.jquery.min.js', 'chosen.min.css', 'chosen-sprite.png', 'chosen-sprite@2x.png'] + src: ['**'] grunt.registerTask 'default', ['build'] - grunt.registerTask 'build', ['coffee', 'compass', 'concat', 'uglify', 'cssmin'] + grunt.registerTask 'build', ['coffee', 'compass', 'concat', 'uglify', 'cssmin', 'package-bower'] grunt.registerTask 'prep-release', ['build', 'dom_munger:latest_version', 'zip:chosen','package-jquery'] - grunt.registerTask 'publish-bower', ['package-bower', 'gh-pages:bower', 'cleanup-bower'] - grunt.registerTask 'publish-release', ['gh-pages:gh-pages','publish-bower'] + grunt.registerTask 'publish-release', ['gh-pages'] grunt.registerTask 'package-jquery', 'Generate a jquery.json manifest file from package.json', () -> src = "package.json" diff --git a/bower-publish.sh b/bower-publish.sh new file mode 100755 index 00000000000..b4dbea64418 --- /dev/null +++ b/bower-publish.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` + +if [ $CURRENT_BRANCH != 'master' ] ; then + exit 0 +fi + +git clone https://pfiller:${GH_TOKEN}@github.com/harvesthq/bower-chosen.git +rm -rf bower-chosen/* +cp public/bower.json public/*.png public/chosen.jquery.min.js public/chosen.min.css bower-chosen/ +cd bower-chosen + + +LATEST_VERSION=$(git diff bower.json | grep version | cut -d':' -f2 | cut -d'"' -f2 | tail -1) + +if [ ! -z $LATEST_VERSION ] ; then + echo "Tagging version ${LATEST_VERSION}\n" + git tag -a "v${LATEST_VERSION}" -m "Version ${LATEST_VERSION}" +fi + +git remote set-url origin https://pfiller:${GH_TOKEN}@github.com/harvesthq/bower-chosen.git +git add -A +git commit -m "Chosen build to bower-chosen" +git push origin master +git push origin --tags + +echo "Done with science" From 35d55924241a6c73464a91e217d60ab3612cb8c7 Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Fri, 27 Mar 2015 22:11:01 -0500 Subject: [PATCH 2/2] Friendly bower-publish output --- bower-publish.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bower-publish.sh b/bower-publish.sh index b4dbea64418..add8b8c98ff 100755 --- a/bower-publish.sh +++ b/bower-publish.sh @@ -3,6 +3,7 @@ CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` if [ $CURRENT_BRANCH != 'master' ] ; then + echo "Build not on master. Skipped bower-chosen release" exit 0 fi @@ -14,8 +15,10 @@ cd bower-chosen LATEST_VERSION=$(git diff bower.json | grep version | cut -d':' -f2 | cut -d'"' -f2 | tail -1) -if [ ! -z $LATEST_VERSION ] ; then - echo "Tagging version ${LATEST_VERSION}\n" +if [ -z $LATEST_VERSION ] ; then + echo "No Chosen version change. Skipped tagging" +else + echo "Chosen version changed. Tagging version ${LATEST_VERSION}\n" git tag -a "v${LATEST_VERSION}" -m "Version ${LATEST_VERSION}" fi @@ -25,4 +28,4 @@ git commit -m "Chosen build to bower-chosen" git push origin master git push origin --tags -echo "Done with science" +echo "Chosen published to harvesthq/bower-chosen"