From 0b56a15583b195b1d87f0d00a5c9ba7d137b4579 Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Mon, 16 Jun 2014 18:19:28 +0000 Subject: [PATCH] chore(build): fix release script bugs --- config/gulp-tasks/docs.js | 23 ++-- scripts/app-base/publish.sh | 2 +- scripts/release/publish.sh | 1 - scripts/site/config.sh | 2 +- scripts/site/docs.sh | 2 +- scripts/travis/ci.sh | 158 -------------------------- scripts/travis/release-new-version.sh | 56 --------- 7 files changed, 18 insertions(+), 226 deletions(-) delete mode 100755 scripts/travis/ci.sh delete mode 100755 scripts/travis/release-new-version.sh diff --git a/config/gulp-tasks/docs.js b/config/gulp-tasks/docs.js index 7a1bfe0062..f8e6f5f855 100644 --- a/config/gulp-tasks/docs.js +++ b/config/gulp-tasks/docs.js @@ -1,11 +1,15 @@ var buildConfig = require('../build.config.js'); var cp = require('child_process'); var dgeni = require('dgeni'); +var es = require('event-stream'); +var fs = require('fs'); var gutil = require('gulp-util'); var htmlparser = require('htmlparser2'); var lunr = require('lunr'); +var mkdirp = require('mkdirp'); var path = require('canonical-path'); var projectRoot = path.resolve(__dirname, '../..'); +var semver = require('semver'); var yaml = require('js-yaml'); module.exports = function(gulp, argv) { @@ -80,19 +84,22 @@ module.exports = function(gulp, argv) { refId++; } + var docPath = buildConfig.dist + '/ionic-site'; + gutil.log('Reading docs from', gutil.colors.cyan(docPath)); + return gulp.src([ - 'temp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}', - 'temp/ionic-site/docs/index.html', - 'temp/ionic-site/getting-started/index.html', - 'temp/ionic-site/tutorials/**/*.{md,html,markdown}', - 'temp/ionic-site/_posts/**/*.{md,html,markdown}' + docPath + '/docs/{components,guide,api,overview}/**/*.{md,html,markdown}', + docPath + '/docs/index.html', + docPath + '/getting-started/index.html', + docPath + '/tutorials/**/*.{md,html,markdown}', + docPath + '/_posts/**/*.{md,html,markdown}' ]) .pipe(es.map(function(file, callback) { //docs for gulp file objects: https://github.com/wearefractal/vinyl var contents = file.contents.toString(); //was buffer // Grab relative path from ionic-site root - var relpath = file.path.replace(/^.*?temp\/ionic-site\//, ''); + var relpath = file.path.replace(RegExp('^.*?' + docPath + '/'), ''); // Read out the yaml portion of the Jekyll file var yamlStartIndex = contents.indexOf('---'); @@ -186,9 +193,9 @@ module.exports = function(gulp, argv) { })).on('end', function() { // Write out as one json file - mkdirp.sync('temp/ionic-site/data'); + mkdirp.sync(docPath + '/data'); fs.writeFileSync( - 'temp/ionic-site/data/index.json', + docPath + '/data/index.json', JSON.stringify({'ref': ref, 'index': idx.toJSON()}) ); }); diff --git a/scripts/app-base/publish.sh b/scripts/app-base/publish.sh index 1826d12ada..f4b92c63c1 100755 --- a/scripts/app-base/publish.sh +++ b/scripts/app-base/publish.sh @@ -9,7 +9,7 @@ echo "#####" function init { APPBASE_DIR=$HOME/ionic-app-base - APPBASE_LIB_DIR=$HOME/www/lib/ionic + APPBASE_LIB_DIR=$APPBASE_DIR/www/lib/ionic ../clone/clone.sh --repository="driftyco/ionic-app-base" \ --directory="$APPBASE_DIR" \ diff --git a/scripts/release/publish.sh b/scripts/release/publish.sh index a07fb328ff..82e46e93b4 100755 --- a/scripts/release/publish.sh +++ b/scripts/release/publish.sh @@ -15,7 +15,6 @@ function run { cd ../.. node_modules/.bin/gulp build --release --dist="$RELEASE_DIR/release" - node_modules/.bin/gulp version --dist="$RELEASE_DIR/release" node_modules/.bin/gulp changelog --dest="$RELEASE_DIR/CHANGELOG.md" cp package.json $RELEASE_DIR diff --git a/scripts/site/config.sh b/scripts/site/config.sh index f7c758ebf5..1b08037858 100755 --- a/scripts/site/config.sh +++ b/scripts/site/config.sh @@ -20,7 +20,7 @@ function run { VERSION=$(readJsonProp "package.json" "version") CODENAME=$(readJsonProp "package.json" "codename") - DATE=$(readJsonProp "dist/version.json" "date") + DATE=$(date +"%Y-%m-%d") cd $SITE_DIR diff --git a/scripts/site/docs.sh b/scripts/site/docs.sh index 17ee234fba..fa1282aad9 100755 --- a/scripts/site/docs.sh +++ b/scripts/site/docs.sh @@ -23,7 +23,7 @@ function run { VERSION=$(readJsonProp "package.json" "version") node_modules/.bin/gulp docs --doc-version="$VERSION_NAME" --dist=$SITE_DIR - node_modules/.bin/gulp docs-index + node_modules/.bin/gulp docs-index --dist=$SITE_DIR cd $SITE_DIR diff --git a/scripts/travis/ci.sh b/scripts/travis/ci.sh deleted file mode 100755 index 829c3d2514..0000000000 --- a/scripts/travis/ci.sh +++ /dev/null @@ -1,158 +0,0 @@ -#!/bin/bash - -# Task that runs every time CI server is pushed to - -ARG_DEFS=( -) - -function init { - # If we are on travis, set our git credentials to make the travis commits look better - if [[ "$TRAVIS" == "true" ]]; then - git config --global user.name 'Ionitron' - git config --global user.email hi@ionicframework.com - export GIT_PUSH_DRYRUN="false" - else - # For testing if we aren't on travis - export TRAVIS_BUILD_NUMBER=$RANDOM - export TRAVIS_PULL_REQUEST=false - export TRAVIS_COMMIT=$(git rev-parse HEAD) - export TRAVIS_BRANCH=master - export GIT_PUSH_DRYRUN="true" - fi -} - -function run { - cd ../.. - - echo "GH_ORG=driftyco" - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" - echo "TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER" - echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" - echo "TRAVIS_COMMIT=$TRAVIS_COMMIT" - echo "GIT_PUSH_DRYRUN=$GIT_PUSH_DRYRUN" - - # check for stupid mistakes - gulp jshint - gulp ddescribe-iit - - # Run simple quick tests on Phantom to be sure any tests pass - # Tests are run on cloud browsers after build - gulp karma --browsers=PhantomJS --reporters=dots - - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then - echo "-- This is a pull request build; will not push build out." - exit 0 - fi - - git show $TRAVIS_COMMIT~1:package.json > package-old.json.tmp - OLD_VERSION=$(readJsonProp "package-old.json.tmp" "version") - - VERSION=$(readJsonProp "package.json" "version") - CODENAME=$(readJsonProp "package.json" "codename") - - if [[ "$OLD_VERSION" != "$VERSION" ]]; then - IS_RELEASE=true - - # Get first codename in list - CODENAME=$(cat config/CODENAMES | head -n 1) - # Remove first line of codenames, it's used now - echo "`tail -n +2 config/CODENAMES`" > config/CODENAMES - - replaceJsonProp "package.json" "codename" "$CODENAME" - replaceJsonProp "bower.json" "codename" "$CODENAME" - replaceJsonProp "component.json" "codename" "$CODENAME" - - echo "#######################################" - echo "# Releasing v$VERSION \"$CODENAME\"! #" - echo "#######################################" - else - if [[ "$TRAVIS_BRANCH" != "master" ]]; then - echo "-- We are not on branch master, instead we are on branch $TRAVIS_BRANCH. Aborting build." - exit 0 - fi - echo "#####################################" - echo "# Pushing out a new nightly release #" - echo "#####################################" - - CURRENT_VERSION=$VERSION - VERSION="$CURRENT_VERSION-nightly-$TRAVIS_BUILD_NUMBER" - replaceJsonProp "package.json" "version" "$VERSION" - - echo "-- Build version is $NEW_VERSION." - fi - - export IONIC_DIR=$PWD - export IONIC_SCSS_DIR=$IONIC_DIR/scss - export IONIC_DIST_DIR=$IONIC_DIR/dist - export IONIC_BUILD_DIR=$IONIC_DIR/dist/build - - mkdir -p $IONIC_DIST_DIR $IONIC_BUILD_DIR - gulp build --release --dist="$IONIC_BUILD_DIR" - - echo "IONIC_DIR=$IONIC_DIR" - echo "IONIC_SCSS_DIR=IONIC_SCSS_DIR=$IONIC_SCSS_DIR" - echo "IONIC_DIST_DIR=$IONIC_DIST_DIR" - echo "IONIC_BUILD_DIR=$IONIC_BUILD_DIR" - - - if [[ $IS_RELEASE == "true" ]]; then - - ./scripts/travis/release-new-version.sh \ - --action="push" \ - --version=$VERSION - - # Version name used on the CDN/docs: nightly or the version - VERSION_NAME=$VERSION - - ./scripts/site/publish.sh --action="updateConfig" - ./scripts/app-base/publish.sh --version="$VERSION" - - gulp release-tweet - gulp release-irc - - else - - VERSION_NAME="nightly" - - gulp changelog --standalone \ - --html=true \ - --subtitle="(changes since $OLD_VERSION)" \ - --dest="$IONIC_BUILD_DIR/CHANGELOG.html" \ - --from="$(git tag | grep $OLD_VERSION)" - fi - - ./scripts/site/publish.sh \ - --action="docs" \ - --version-name="$VERSION_NAME" - - ./scripts/cdn/publish.sh \ - --version=$VERSION \ - --version-name="$VERSION_NAME" - - ./scripts/bower/publish.sh \ - --version="$VERSION" \ - --codename="$CODENAME" - - ./scripts/demo/publish.sh \ - --version-name="$VERSION_NAME" - - - if [[ "$IS_RELEASE" == "true" ]]; then - echo "################################################" - echo "# Complete! v$VERSION \"$CODENAME\" published! #" - echo "################################################" - else - echo "##########################" - echo "# Running cloud tests... #" - echo "##########################" - - # Do sauce unit tests and e2e tests with all browsers (takes longer) - # gulp cloudtest - - echo "##########################################" - echo "# Complete! v$VERSION nightly published! #" - echo "##########################################" - fi -} - -source $(dirname $0)/../utils.inc diff --git a/scripts/travis/release-new-version.sh b/scripts/travis/release-new-version.sh deleted file mode 100755 index c8d521e744..0000000000 --- a/scripts/travis/release-new-version.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -ARG_DEFS=( - "--version=(.*)" - "[--old-version=(.*)]" -) - -function init { - PUSH_DIR=$IONIC_DIST_DIR/ionic - - echo "-- Cloning ionic master ..." - - rm -rf $PUSH_DIR - mkdir -p $PUSH_DIR - git clone https://driftyco:$GH_TOKEN@github.com/driftyco/ionic.git \ - $PUSH_DIR \ - --depth=1 -} - -function run { - - echo "##############################" - echo "# Pushing release $VERSION #" - echo "##############################" - - cd $PUSH_DIR - - # Get first codename in list - CODENAME=$(readJsonProp "$IONIC_DIR/package.json" "codename") - - replaceJsonProp "package.json" "version" "$VERSION" - replaceJsonProp "bower.json" "version" "$VERSION" - replaceJsonProp "component.json" "version" "$VERSION" - - echo "-- Putting built files into release folder" - - rm -rf release - mkdir -p release - cp -Rf $IONIC_BUILD_DIR/* release - - git add -A - git commit -m "finalize-release: v$VERSION \"$CODENAME\"" - git tag -f -m "v$VERSION" v$VERSION - - git push -q origin master - git push -q origin v$VERSION - - echo "-- v$VERSION \"$CODENAME\" pushed to origin/master successfully!" -} - -function tweetAndIrc { - cd $IONIC_DIR - gulp release-tweet release-irc -} - -source $(dirname $0)/../utils.inc