chore(build): more ci server automation

This commit is contained in:
Andy Joslin
2014-02-04 22:11:13 -05:00
parent 738ace8969
commit 456dc2b9f2
76 changed files with 26833 additions and 2989 deletions

65
scripts/bower/publish.sh Executable file
View File

@@ -0,0 +1,65 @@
# adapted from Angular's bower script
# Script for updating the Ionic bower repos from current build
echo "#################################"
echo "#### Update bower ###############"
echo "#################################"
ARG_DEFS=(
)
function init {
TMP_DIR=$SCRIPT_DIR/../../tmp
BUILD_DIR=$SCRIPT_DIR/../../dist
PROJECT_DIR=$SCRIPT_DIR/../..
BOWER_DIR=$TMP_DIR/bower-ionic
}
function run {
VERSION=$(readJsonProp "$PROJECT_DIR/package.json" "version")
CODENAME=$(readJsonProp "$PROJECT_DIR/package.json" "codename")
rm -rf $BOWER_DIR
mkdir -p $BOWER_DIR
echo "-- Cloning bower-ionic..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/bower-ionic.git $BOWER_DIR
# move the files from the build
echo "-- Putting build files in bower-ionic..."
cd $BOWER_DIR
cp -Rf $BUILD_DIR/* $BOWER_DIR
# Angular dependencies are managed by bower, don't include them
rm -rf $BOWER_DIR/js/angular*
# update bower.json
# tag each repo
echo "-- Updating version in bower-ionic to $VERSION"
replaceJsonProp "bower.json" "version" "$VERSION"
echo "-- Updating codename in bower-ionic to $CODENAME"
replaceJsonProp "bower.json" "codename" "$CODENAME"
echo "-- Committing and tagging bower-ionic"
git add -A
git commit -m "release: v$VERSION"
git tag v$VERSION
echo "-- Pushing bower-ionic"
cd $BOWER_DIR
git push -q origin master
git push -q origin v$VERSION
echo "-- Published bower-ionic to v$VERSION successfully!"
# Go back to the script to make things 'safe'
cd $SCRIPT_DIR
}
source $(dirname $0)/../utils.inc

55
scripts/cdn/publish.sh Executable file
View File

@@ -0,0 +1,55 @@
echo "#################################"
echo "#### Update CDN #################"
echo "#################################"
# Version label is "nightly" or a version number
ARG_DEFS=(
"--version-label=(.*)"
)
function init {
PROJECT_DIR=$SCRIPT_DIR/../..
BUILD_DIR=$SCRIPT_DIR/../../dist
IONIC_CODE_DIR=$SCRIPT_DIR/../../tmp/ionic-code
rm -rf $IONIC_CODE_DIR
mkdir -p $IONIC_CODE_DIR
}
function run {
VERSION=$(readJsonProp "$PROJECT_DIR/package.json" "version")
CODENAME=$(readJsonProp "$PROJECT_DIR/package.json" "codename")
echo "-- Cloning ionic-code..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-code.git $IONIC_CODE_DIR
VERSION_DIR=$IONIC_CODE_DIR/$VERSION_LABEL
rm -rf $VERSION_DIR
mkdir -p $VERSION_DIR
cd $VERSION_DIR
cp -R $BUILD_DIR/* $VERSION_DIR
# Create a version.txt file with the version and codename
echo "$VERSION $CODENAME" > version.txt
echo "-- Zipping build files..."
cd $IONIC_CODE_DIR
zip -r -q $VERSION_DIR/ionic-$VERSION_LABEL.zip $VERSION_DIR
echo "-- Generating versions.json..."
cd $IONIC_CODE_DIR/builder
python ./generate.py > /dev/null
cd $IONIC_CODE_DIR
git add -A
git commit -am "release: $VERSION ($VERSION_LABEL)"
git push -q origin gh-pages
echo "-- Published ionic-code to v$VERSION successfully!"
}
source $(dirname $0)/../utils.inc

View File

@@ -2,7 +2,9 @@
# Inspired by AngularJS's finalize-version script
# force user to deifne git-push-dryrun so he has to think!
ARG_DEFS=(
"--git-push-dryrun=(true|false)"
"--action=(prepare|publish)"
)
@@ -10,15 +12,22 @@ function prepare {
cd ../..
# Remove suffix
replaceJsonProp "package.json" "version" "(.*)?-[a-zA-Z]+" "\2"
OLD_VERSION=$(readJsonProp "package.json" "version")
VERSION=$(echo $OLD_VERSION | sed 's/-.*//')
replaceJsonProp "package.json" "version" "$VERSION"
VERSION=$(readJsonProp "package.json" "version")
CODENAME=$(readJsonProp "package.json" "codename")
replaceJsonProp "bower.json" "version" ".*" "$VERSION"
replaceJsonProp "component.json" "version" ".*" "$VERSION"
replaceJsonProp "bower.json" "version" "$VERSION"
replaceJsonProp "component.json" "version" "$VERSION"
git add package.json bower.json component.json
echo "-- Building and putting files in release folder"
grunt build
mkdir -p release
cp -Rf dist/* release
git add package.json bower.json component.json release
git commit -m "chore(release): v$VERSION"
git tag -m "v$VERSION" v$VERSION
@@ -33,10 +42,11 @@ function publish {
cd ../..
VERSION=$(readJsonProp "package.json" "version")
BRANCH=$(git rev-parse --abbrev-ref HEAD)
git push origin $BRANCH
git push origin v$VERSION
git push -q origin master
git push -q origin v$VERSION
echo "-- Version published as v$VERSION successfully!"
cd $SCRIPT_DIR
}

View File

@@ -6,7 +6,9 @@ echo "#########################################################"
echo "## Increment version, add suffix, and set version name ##"
echo "#########################################################"
# force user to define git-push-dryrun so he has to think!
ARG_DEFS=(
"--git-push-dryrun=(true|false)"
"--version-type=(patch|minor|major)"
"--version-name=(.+)"
"--version-suffix=(.+)"
@@ -16,15 +18,19 @@ function run {
cd ../..
grunt bump:$VERSION_TYPE
replaceJsonProp "package.json" "version" "(.*)" "\2-"$VERSION_SUFFIX
replaceJsonProp "package.json" "codename" ".*" "$VERSION_NAME"
VERSION=$(readJsonProp "package.json" "version")
replaceJsonProp "package.json" "version" "$VERSION-$VERSION_SUFFIX"
replaceJsonProp "package.json" "codename" "$VERSION_NAME"
VERSION=$(readJsonProp "package.json" "version")
git add package.json
git commit -m "chore(release): start v$VERSION"
git commit -m "chore(post-release): start v$VERSION"
git push origin master
git push -q origin master
echo "Version initialized & published as v$VERSION successfully!"
}
source $(dirname $0)/../utils.inc

34
scripts/seed/publish.sh Executable file
View File

@@ -0,0 +1,34 @@
ARG_DEFS=(
)
function init {
TMP_DIR=$SCRIPT_DIR/../../tmp
BUILD_DIR=$SCRIPT_DIR/../../dist
SEED_DIR=$TMP_DIR/seed
rm -rf $SEED_DIR
mkdir -p $SEED_DIR
}
function run {
cd ../..
VERSION=$(readJsonProp "package.json" "version")
echo "-- Cloning ionic-angular-cordova-seed..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-angular-cordova-seed.git $SEED_DIR
cd $SEED_DIR
echo "-- Updating files..."
cp -Rf $BUILD_DIR/* $SEED_DIR/www/lib/
git add -A
git commit -am "chore(release): update ionic to v$VERSION"
git push -q origin master
echo "-- ionic-angular-cordova-seed files update to v$VERSION successfully!"
}
source $(dirname $0)/../utils.inc

View File

@@ -0,0 +1,32 @@
echo "###########################################"
echo "# Writing nightly version in package.json #"
echo "###########################################"
ARG_DEFS=(
)
function run {
cd ../..
echo $PWD
VERSION=$(readJsonProp "package.json" "version")
# If no travis build number (if this is a test-run on local machine),
# just generate a test number
if [ -z "$TRAVIS_BUILD_NUMBER" ]; then
TRAVIS_BUILD_NUMBER=1
fi
# 7-byte sha for this commit
SHA=$(git rev-parse HEAD | head -c 7)
NEW_VERSION="$VERSION-$TRAVIS_BUILD_NUMBER-$SHA"
replaceJsonProp "package.json" "version" "$NEW_VERSION"
echo "-- Build version is $NEW_VERSION."
}
source $(dirname $0)/../utils.inc

View File

@@ -5,29 +5,77 @@
ARG_DEFS=(
)
# function init {
# for pushing docs/cdn
# git config --global user.name 'Ionic Roboman'
# git config --global user.email ionic.roboman@drifty.com
# }
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
fi
}
function run {
function run {
cd ../..
# Build / JSHint
grunt jshint
# TODO Check for things like iit / ddescribe / merge conflicts / leftover console.log
# Do a cursory test with PhantomJS
# just so we can quickly fail if some tests fail
# for testing, use your fork as GH_ORG to push to
export GH_ORG=driftyco
if [[ "$TRAVIS" != "true" ]]; then
export TRAVIS_BRANCH=master
fi
echo "-- Building on branch $TRAVIS_BRANCH for organization $GH_ORG"
# Jshint & check for stupid mistakes
grunt jshint ddescribe-iit merge-conflict
# Run simple quick tests on Phantom to be sure any tests pass
grunt karma:single --browsers=PhantomJS --reporters=dots
# Build
grunt build
# Do sauce test with all browsers (takes longer)
# Saucelabs settings need more tweaking before it becomes stable (sometimes it fails)
# TODO Saucelabs settings need more tweaking before it becomes stable (sometimes it fails to connect)
# grunt karma:sauce --reporters=dots
# TODO Build docs
# TODO Push to CDN
if [[ "$TRAVIS_BRANCH" != "master" ]]; then
echo "-- Building on branch $TRAVIS_BRANCH (not master); will not push build out."
exit 0
fi
if [[ "$TRAVIS_PULL_REQUEST" == "true" ]]; then
echo "-- This is a pull request build; will not push build out."
exit 0
fi
# if the latest tag points to this commit, then treat
# this as a release
LATEST_TAG_COMMIT=$(git rev-list --tags --max-count=1)
HEAD_COMMIT=$(git rev-parse HEAD)
if [ "$LATEST_TAG_COMMIT" == "$HEAD_COMMIT" ]; then
IS_RELEASE=true
echo "-- Pushing out a new full release."
else
echo "-- Pushing out a new nightly build."
./scripts/travis/bump-nightly-version.sh
fi
# Version label used on the CDN: nightly or the version name
if [[ $IS_RELEASE == "true" ]]; then
VERSION_LABEL=$(readJsonProp "package.json" "version")
else
VERSION_LABEL="nightly"
fi
./scripts/cdn/publish.sh --version-label="$VERSION_LABEL"
./scripts/bower/publish.sh
if [[ $IS_RELEASE == "true" ]]; then
./scripts/seed/publish.sh
fi
echo "--- Build Complete! ----"
}
source $(dirname $0)/../utils.inc

View File

@@ -202,17 +202,17 @@ function readJsonProp {
echo $(sed -En 's/.*"'$2'"[ ]*:[ ]*"(.*)".*/\1/p' $1)
}
# replaceJsonProp(jsonFile, propertyRegex, valueRegex, replacePattern)
# replaceJsonProp(jsonFile, property, newValue)
# - note: propertyRegex will be automatically placed into a
# capturing group! -> all other groups start at index 2!
function replaceJsonProp {
replaceInFile $1 '"('$2')"[ ]*:[ ]*"'$3'"' '"\1": "'$4'"'
local VALUE=$(readJsonProp $1 $2)
replaceInFile $1 $VALUE $3
}
# replaceInFile(file, findPattern, replacePattern)
function replaceInFile {
sed -i .tmp -E "s/$2/$3/" $1
rm $1.tmp
perl -pi -e "s/$2/$3/g;" $1
}
# resolveDir(relativeDir)