From 54ea390a9053bfc0acc7e08b9fabfd184dd98113 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 3 Dec 2016 01:06:22 -0500 Subject: [PATCH] Modified Travis to use build scripts from patternfly-release repo. --- .travis.yml | 9 +- package.json | 3 +- scripts/build.sh | 81 --------- scripts/publish.sh | 85 ---------- scripts/release/README.md | 43 ----- scripts/release/build.sh | 123 -------------- scripts/release/common.sh | 87 ---------- scripts/release/env.sh | 25 --- scripts/release/notify.sh | 102 ------------ scripts/release/publish.sh | 141 ---------------- scripts/release/release-all.sh | 105 ------------ scripts/release/release.sh | 291 --------------------------------- 12 files changed, 8 insertions(+), 1087 deletions(-) delete mode 100755 scripts/build.sh delete mode 100755 scripts/publish.sh delete mode 100644 scripts/release/README.md delete mode 100755 scripts/release/build.sh delete mode 100644 scripts/release/common.sh delete mode 100755 scripts/release/env.sh delete mode 100755 scripts/release/notify.sh delete mode 100755 scripts/release/publish.sh delete mode 100755 scripts/release/release-all.sh delete mode 100755 scripts/release/release.sh diff --git a/.travis.yml b/.travis.yml index 05e817953..4002bde61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,14 @@ env: - TRIGGER_REPO_BRANCH: "master" before_install: - - 'git checkout -B $TRAVIS_BRANCH' # Reconcile detached HEAD - - 'npm install -g bower grunt-cli' + - if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi + - npm install -g bower grunt-cli + - npm install patternfly-eng-release + +install: true script: - - sh -x ./scripts/build.sh + - sh -x ./node_modules/patternfly-eng-release/scripts/_build.sh -a after_success: - ./scripts/publish-ghpages.sh -t docs diff --git a/package.json b/package.json index 3f6fc0339..fb9bfc65e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "karma-ng-html2js-preprocessor": "~0.1", "karma-phantomjs-launcher": "^1.0.0", "matchdep": "0.3.0", - "nsp": "^2.6.1" + "nsp": "^2.6.1", + "patternfly-eng-release": "~3.15.0" }, "scripts": { "test": "grunt test" diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 46066a41e..000000000 --- a/scripts/build.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -default() -{ - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/release/env.sh - . $SCRIPT_DIR/release/common.sh - - PTNFLY_DIR=`cd $SCRIPT_DIR/..; pwd` -} - -# Publish to dist branch -# -publish() -{ - echo "*** Publishing" - cd $PTNFLY_DIR - - sh -x $SCRIPT_DIR/publish.sh - check $? "Publish failure" -} - -usage() -{ -cat <<- EEOOFF - - This script will build, publish, and release the repo. - - Note: Intended for use with Travis only. - - sh [-x] $SCRIPT [-h] - - Example: sh $SCRIPT - - OPTIONS: - h Display this message (default) - -EEOOFF -} - -# main() -{ - default - - while getopts h c; do - case $c in - h) usage; exit 0;; - \?) usage; exit 1;; - esac - done - - echo "This build is running against $TRAVIS_REPO_SLUG" - - if [ -n "$TRAVIS_TAG" ]; then - echo "This build is running against $TRAVIS_TAG" - - # Get version from tag - case "$TRAVIS_TAG" in - $BUMP_TAG_PREFIX* ) RELEASE=1;; - *) echo "$TRAVIS_TAG is not a recognized format. Do not release!";; - esac - fi - - if [ -n "$RELEASE" ]; then - sh -x $SCRIPT_DIR/release/build.sh - check $? "Release failure" - else - git_setup - build_install - build - build_test - - # Skip publish for pull requests - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then - publish - fi - fi -} diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100755 index 0e3e31cc8..000000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -default() -{ - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/release/env.sh - . $SCRIPT_DIR/release/common.sh - - PTNFLY_DIR=`cd $SCRIPT_DIR/..; pwd` -} - -# Push generated files to dist branch -# -push_dist() -{ - echo "*** Pushing to $TRAVIS_BRANCH-dist" - cd $PTNFLY_DIR - - # Commit generated files - git add dist --force - git commit -m "Added files generated by Travis build" - check $? "git commit failure" - - # Push to dist branch - EXISTING=`git ls-remote --heads https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH-dist` - - if [ -n "$EXISTING" ]; then - git fetch upstream $TRAVIS_BRANCH-dist:$TRAVIS_BRANCH-dist # : - git checkout $TRAVIS_BRANCH-dist - git merge -Xtheirs $TRAVIS_BRANCH-local --no-edit --ff - check $? "git merge failure" - - git push upstream $TRAVIS_BRANCH-dist --force -v - else - git push upstream $TRAVIS_BRANCH-local:$TRAVIS_BRANCH-dist --force -v - fi - check $? "git push failure" -} - -usage() -{ -cat <<- EEOOFF - - This script will publish generated files to GitHub. - - Note: Intended for use with Travis only. - - sh [-x] $SCRIPT [-h] - - Example: sh $SCRIPT - - OPTIONS: - h Display this message (default) - -EEOOFF -} - -# main() -{ - default - - while getopts h c; do - case $c in - h) usage; exit 0;; - \?) usage; exit 1;; - esac - done - - # Avoid creating a dist equivalent for all branches in the main repo - if [ "$TRAVIS_REPO_SLUG" = "$PTNFLY_REPO_SLUG" -a "$TRAVIS_BRANCH" != "master" ]; then - echo "This commit was made against $TRAVIS_BRANCH and not the master or tag! Do not deploy!" - exit 0 - fi - - # Ensure dist branch is not redeployed. - case "$TRAVIS_BRANCH" in - *-dist ) echo "This commit was made against the dist branch. Do not deploy!"; exit 0;; - esac - - git_setup - push_dist -} diff --git a/scripts/release/README.md b/scripts/release/README.md deleted file mode 100644 index 95bbe9c75..000000000 --- a/scripts/release/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Patternfly Release Process - -At periodic intervals PatternFly, and all repos which utilize PF, must be versioned. Below is a summary of all the steps involved. For more information on each repo, please see [PatternFly Documentation](https://depot-uxd.itos.redhat.com/uxd-team/uxd-dev-team/#docs). - -Note that many of the release steps have been automated by scripts, named release.sh and release-all.sh. Where applicable to each repo, these scripts will clone a new repo from GitHub, bump the npm/bower version and website home page version numbers. The scripts will also clean the npm/bower cache, run npm install, bower install, grunt build, grunt ngdocs:publish, npm shrinkwrap, npm publish, npm test, nsp shrinkwrap audit, and will verify npm/bower installs. - -### release.sh - -This script will bump version numbers, build, shrinkwrap, test, install, push to GitHub, and publish to npm. These changes are added to a branch that must be merged with a PR on GitHub. - -Although many release steps have been automated, this is a manual release process. Creating a PR, release notes, and community email are still tasks which must be performed manually. - -This is useful when debugging build issues or publishing individual releases. In fact, release-all.sh uses this script to automate the release process. - -1. Choose version using [semantic versioning](https://docs.npmjs.com/getting-started/semantic-versioning) ([details](https://github.com/patternfly/patternfly/blob/master/README.md#release)) -2. Bump the version number, build, etc. - - Run sh ./scripts/release/release.sh -v -f -3. Review ngDoc pages, verify latest changes - - cd /tmp/patternfly-releases/angular-patternfly - - Run grunt server -4. PR reviewed & merged (no dist files should be checked in) -5. NPM Publish - - Create an NPM account and become a collaborator for https://www.npmjs.com/package/angular-patternfly - - Run sh ./scripts/release/release.sh -p -6. Release Notes Published (via GitHub) - - Tag “master-dist” branch commit with updated version -7. Community email sent (angular-patternfly@redhat.com) - -### release-all.sh - -This script is used to automate and chain releases together. When the Patternfly release is complete, the release processes for Angular Patternfly and RCUE are kicked off. When the Angular Patternfly release is complete, Patternfly Org will be released as well. - -The script kicks off the release by creating a custom Git tag. When Travis sees this custom tag, it will run the appropriate scripts to automatically bump version numbers, build, shrinkwrap, test, install, and publish the release. - -Although there is no PR to deal with here, creating release notes is still a task which must be performed manually via GitHub. - -Note: Builds can only be stopped via the Travis CI. - -1. Choose version using [semantic versioning](https://docs.npmjs.com/getting-started/semantic-versioning) ([details](https://github.com/patternfly/patternfly/blob/master/README.md#release)) -2. Run sh ./scripts/release/release-all.sh -v -3. Release Notes Published (via GitHub) - - Tag “master-dist” branch commit with updated version -4. Run sh ./scripts/release/notify.sh -v diff --git a/scripts/release/build.sh b/scripts/release/build.sh deleted file mode 100755 index dddf2e75e..000000000 --- a/scripts/release/build.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh - -default() -{ - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/env.sh - . $SCRIPT_DIR/common.sh - - PTNFLY_DIR=`cd $SCRIPT_DIR/../..; pwd` -} - -# Add tag to kick off Patternfly Org version bump -# -add_pfo_tag() -{ - echo "*** Adding Patternfly Org tag" - cd $PTNFLY_DIR - - # Add tag to kick off version bump - git fetch pfo master:master-pfo # : - git checkout master-pfo - git tag $BUMP_TAG_PREFIX$VERSION -f - git push pfo tag $BUMP_TAG_PREFIX$VERSION - check $? "add pfo tag failure" -} - -# Add release tag -# -add_release_tag() -{ - echo "*** Adding release tag" - cd $PTNFLY_DIR - - # Add release tag - git tag $RELEASE_TAG_PREFIX$VERSION - check $? "add tag failure" - git push upstream tag $RELEASE_TAG_PREFIX$VERSION - check $? "git push tag failure" -} - -# Delete tag used to kick off version bump -# -delete_bump_tag() -{ - echo "*** Deleting bump tag" - cd $PTNFLY_DIR - - # Remove bump tag - git tag -d $BUMP_TAG_PREFIX$VERSION - git push upstream :refs/tags/$BUMP_TAG_PREFIX$VERSION - check $? "delete tag failure" -} - -usage() -{ -cat <<- EEOOFF - - This script will build, publish, and release the repo. - - If a custom Git tag has been created to publish a release, the Git tag will first be deleted, version numbers will - be bumped, and the repo published. - - Note: Intended for use with Travis only. - - sh [-x] $SCRIPT [-h] - - Example: sh $SCRIPT - - OPTIONS: - h Display this message (default) - -EEOOFF -} - -# main() -{ - default - - while getopts h c; do - case $c in - h) usage; exit 0;; - \?) usage; exit 1;; - esac - done - - echo "This build is running against $TRAVIS_REPO_SLUG" - - if [ -n "$TRAVIS_TAG" ]; then - echo "This build is running against $TRAVIS_TAG" - - # Get version from tag - case "$TRAVIS_TAG" in - $BUMP_TAG_PREFIX* ) VERSION=`echo "$TRAVIS_TAG" | cut -c $BUMP_TAG_PREFIX_COUNT-`;; - *) check 1 "$TRAVIS_TAG is not a recognized format. Do not release!";; - esac - fi - - # Ensure release runs for main repo only - if [ "$TRAVIS_REPO_SLUG" != "$PTNFLY_REPO_SLUG" ]; then - check 1 echo "Release must be performed on $PTNFLY_REPO_SLUG only!" - fi - - git_setup - delete_bump_tag - - git tag | grep "^$RELEASE_TAG_PREFIX$VERSION" - if [ $? -eq 0 ]; then - check 1 "Tag $RELEASE_TAG_PREFIX$VERSION exists. Do not release!" - fi - - # Note: This script must remove the shrinkwrap prior to install so we may build new - sh -x $SCRIPT_DIR/release.sh -v $VERSION - check $? "bump version failure" - - sh -x $SCRIPT_DIR/publish.sh - check $? "Publish failure" - - add_release_tag # Add release tag to master-dist - add_pfo_tag # Kick off Patternfly Org version bump -} diff --git a/scripts/release/common.sh b/scripts/release/common.sh deleted file mode 100644 index 6bad1034d..000000000 --- a/scripts/release/common.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# Build repo -# -build() -{ - echo "*** Building `pwd`" - cd $PTNFLY_DIR - - grunt build - check $? "grunt build failure" - - echo "*** Building ngDocs: `pwd`" - grunt ngdocs:publish - check $? "ngDocs build failure" -} - -# Install build dependencies -# -build_install() -{ - echo "*** Intsalling build dependencies" - cd $PTNFLY_DIR - - npm install - check $? "npm install failure" - - bower install - check $? "bower install failure" -} - -# Test build -build_test() -{ - echo "*** Testing build" - cd $PTNFLY_DIR - - node node_modules/nsp/bin/nsp --shrinkwrap npm-shrinkwrap.json check --output summary - check $? "shrinkwrap vulnerability found" warn -} - -# Check errors -# -# $1: Exit status -# $2: Error message -# $3: Show warning -check() -{ - if [ "$1" != 0 ]; then - if [ "$3" = "warn" ]; then - echo "*** Warning: $2" - else - echo "*** Error: $2" - exit $1 - fi - fi -} - -# Setup env for use with GitHub -# -git_setup() -{ - echo "*** Setting up Git env" - cd $PTNFLY_DIR - - git config user.name $GIT_USER_NAME - git config user.email $GIT_USER_EMAIL - git config --global push.default simple - - # Add upstream as a remote - git remote rm upstream - git remote add upstream https://$AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git - check $? "git add remote failure" - - # Add Patternfly Org as a remote - git remote rm pfo - git remote add pfo https://$AUTH_TOKEN@github.com/$PFO_REPO_SLUG.git - check $? "git add remote failure" - - # Reconcile detached HEAD -- name must not be ambiguous with tags - git checkout -B $TRAVIS_BRANCH-local - check $? "git checkout failure" - - # Fetch to test if tag exists - git fetch --tags - check $? "Fetch tags failure" -} diff --git a/scripts/release/env.sh b/scripts/release/env.sh deleted file mode 100755 index e0858884b..000000000 --- a/scripts/release/env.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Git properties -GIT_USER_NAME=patternfly-build -GIT_USER_EMAIL=patternfly-build@redhat.com - -# Repo slugs -PFO_REPO_SLUG=patternfly/patternfly-org -PTNFLY_REPO_SLUG=patternfly/angular-patternfly - -# Email used to notify users release is available -NOTIFY_EMAIL=patternfly-angular@redhat.com - -# Prefix used to tag version bump (e.g., _bump-v3.15.0) -BUMP_TAG_PREFIX=_bump-v -BUMP_TAG_PREFIX_COUNT=`echo $BUMP_TAG_PREFIX | wc -c` - -# Prefix used to tag release (e.g., v3.15.0) -RELEASE_TAG_PREFIX=v - -# Bower packages not tagged in main repo (for testing with fork) -#PTNFLY_PKG_REPO=git+https://github.com//patternfly.git#v - -# Skip npm publish (for testing with fork) -#SKIP_NPM_PUBLISH=1 diff --git a/scripts/release/notify.sh b/scripts/release/notify.sh deleted file mode 100755 index 450d4ae69..000000000 --- a/scripts/release/notify.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh - -default() -{ - PATH=/bin:/usr/bin:/usr/local/bin:$PATH - export PATH - - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/env.sh - . $SCRIPT_DIR/common.sh - - TMP_DIR=/tmp/$SCRIPT.$$ - TMP_FILE=notify.txt -} - -# Send email notifying users a new release is available -# -email() -{ - echo "*** Email notice" - mkdir -p $TMP_DIR - -cat > $TMP_DIR/$TMP_FILE <<- EEOOFF -The UXD team is proud to announce the $VERSION release of Angular PatternFly. This release includes the following changes. - -$RELEASE_NOTES - -Check out the Angular PatternfFly $VERSION Release Notes for more details: -https://github.com/$PTNFLY_REPO_SLUG/releases/tag/$RELEASE_TAG_PREFIX$VERSION - -Thanks to everyone who participated in this release (both directly and indirectly) - your contributions are what keeps pushing PatternFly forward! - -- the PatternFly team -EEOOFF - - SUBJECT="The Patternfly $VERSION release is now available" - cat $TMP_DIR/$TMP_FILE | mail -s "$SUBJECT" "$NOTIFY_EMAIL" - rm -rf $TMP_DIR -} - -# Fetch release notes from GitHub release -# -fetch_notes() -{ - echo "*** Fetch notes" - - RELEASE_NOTES=`curl -s https://api.github.com/repos/$PTNFLY_REPO_SLUG/releases/tags/$RELEASE_TAG_PREFIX$VERSION | - node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).body"` - check $? "fetch notes failure" - - if [ "$RELEASE_NOTES" = "undefined" ]; then - check 1 "Could not retrieve release notes.\nEnsure release has been published via GitHub." - fi -} - -usage() -{ -cat <<- EEOOFF - This script will send a release notice to the Angular Patternfly mailling list. - - Note: You must configure your system to tell it where to send email. If you haven't done so, see: - http://codana.me/2014/11/23/sending-gmail-from-os-x-yosemite-terminal - - sh [-x] $SCRIPT [-h|v] - - Example: sh $SCRIPT -v 3.15.0 - - OPTIONS: - h Display this message (default) - v The version number (e.g., 3.15.0) - -EEOOFF -} - -# main() -{ - default - - if [ "$#" -eq 0 ]; then - usage - exit 1 - fi - - while getopts hv c; do - case $c in - h) usage; exit 0;; - v) VERSION=$2; shift;; - \?) usage; exit 1;; - esac - done - - if [ -z "$VERSION" ]; then - usage - exit 1 - fi - - fetch_notes - email -} diff --git a/scripts/release/publish.sh b/scripts/release/publish.sh deleted file mode 100755 index 4bd6e0841..000000000 --- a/scripts/release/publish.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh - -default() -{ - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/env.sh - . $SCRIPT_DIR/common.sh - - PTNFLY_DIR=`cd $SCRIPT_DIR/../..; pwd` - TMP_DIR=/tmp/patternfly - - BUMP_TAG_PREFIX_COUNT=`echo $BUMP_TAG_PREFIX | wc -c` -} - -# Publish to npm -# -publish_npm() -{ - # Skip npm publish - if [ -n "$SKIP_NPM_PUBLISH" ]; then - return - fi - - echo "*** Publishing npm" - cd $PTNFLY_DIR - - # Log into npm - printf "$NPM_USER\n$NPM_PWD\n$NPM_USER@redhat.com" | npm login - check $? "npm login failure" - - sh -x $SCRIPT_DIR/release.sh -p - check $? "npm publish failure" -} - -# Push version bump changes to master branch -# -push_master() -{ - echo "*** Pushing to master" - cd $PTNFLY_DIR - - # Note: Changes are committed by release script prior to bower install verification - - # Merge master branch - git fetch upstream master:master # : - git checkout master - git merge -Xtheirs $TRAVIS_BRANCH-local --no-edit --ff - check $? "git merge failure" - - # Push to master - git push upstream master:master - check $? "git push failure" -} - -# Push version bump and generated files to master-dist for tagging release -# -# Note: When run against a tag, TRAVIS_BRANCH won't equal "master", but the tag name. To ensure we push to master-dist, -# don't use TRAVIS_BRANCH here. -# -push_master_dist() -{ - echo "*** Pushing to master-dist" - cd $PTNFLY_DIR - - git checkout $TRAVIS_BRANCH-local - - # Commit generated files - git add dist --force - git commit -m "Added files generated by Travis build" - check $? "git commit failure" - - # Push to dist branch - EXISTING=`git ls-remote --heads https://github.com/$TRAVIS_REPO_SLUG.git master-dist` - - if [ -n "$EXISTING" ]; then - git fetch upstream master-dist:master-dist # : - git checkout master-dist - git merge -Xtheirs $TRAVIS_BRANCH-local --no-edit --ff - check $? "git merge failure" - - git push upstream master-dist --force -v - else - git push upstream $TRAVIS_BRANCH-local:master-dist --force -v - fi - check $? "git push failure" -} - -usage() -{ -cat <<- EEOOFF - - This script will publish generated files to GitHub. - - Note: Intended for use with Travis only. - - sh [-x] $SCRIPT [-h] - - Example: sh $SCRIPT - - OPTIONS: - h Display this message (default) - -EEOOFF -} - -# main() -{ - default - - while getopts hbd c; do - case $c in - h) usage; exit 0;; - \?) usage; exit 1;; - esac - done - - echo "This publish is running against $TRAVIS_REPO_SLUG" - - if [ -n "$TRAVIS_TAG" ]; then - echo "This publish is running against $TRAVIS_TAG" - - # Get version from tag - case "$TRAVIS_TAG" in - $BUMP_TAG_PREFIX* ) VERSION=`echo "$TRAVIS_TAG" | cut -c $BUMP_TAG_PREFIX_COUNT-`;; - *) check 1 "$TRAVIS_TAG is not a recognized format. Do not publish!";; - esac - fi - - # Ensure release runs for main repo only - if [ "$TRAVIS_REPO_SLUG" != "$PTNFLY_REPO_SLUG" ]; then - check 1 echo "Publish must be performed on $PTNFLY_REPO_SLUG only!" - fi - - git_setup - push_master # Push version bump to master - push_master_dist # Push version bump and generated files to master-dist for tagging release - publish_npm # Publish to npm -} diff --git a/scripts/release/release-all.sh b/scripts/release/release-all.sh deleted file mode 100755 index 4052dbd06..000000000 --- a/scripts/release/release-all.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -default() -{ - PATH=/bin:/usr/bin:/usr/local/bin:$PATH - export PATH - - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/env.sh - . $SCRIPT_DIR/common.sh - - TMP_DIR="/tmp/$SCRIPT.$$" - PTNFLY_DIR="$TMP_DIR/angular-patternfly" -} - -# Add tag to kick off version bump -# -add_bump_tag() -{ - echo "*** Adding version bump tag" - cd $PTNFLY_DIR - - git tag $BUMP_TAG_PREFIX$VERSION - check $? "git tag failure" - - git push origin tag $BUMP_TAG_PREFIX$VERSION - check $? "git push failure" -} - -# Setup local repo -# -setup_repo() { - echo "*** Setting up local repo $PTNFLY_DIR" - mkdir -p $TMP_DIR - cd $TMP_DIR - - git clone https://github.com/$PTNFLY_REPO_SLUG.git - check $? "git clone failure" - cd $PTNFLY_DIR - - git checkout master - check $? "git checkout failure" -} - -usage() -{ -cat <<- EEOOFF - - This script will release the repo by creating a custom Git tag. Travis will run the appropriate scripts to - automatically bump version numbers, build, shrinkwrap, test, install, and publish the release. - - When the release is complete, the custom Git tag is removed from GitHub. The custom tag is created using a clone so - it won't persist in your local repo. - - If the release is successful, Patternfly Org will be released as well. This is done by creating a Git tag for the - next repo to be built. - - If 3.15.0 is provided as a version number; for example, the release will be tagged as v3.15.0. - - Release notes must be added via GitHub. - - Note: Builds can only be stopped via the Travis UI: https://travis-ci.org/$PTNFLY_REPO_SLUG/builds - - sh [-x] $SCRIPT [-h] -v - - Example: sh $SCRIPT -v 3.15.0 - - OPTIONS: - h Display this message (default) - v The version number (e.g., 3.15.0) - -EEOOFF -} - -# main() -{ - default - - if [ "$#" -eq 0 ]; then - usage - exit 1 - fi - - while getopts hfpsv c; do - case $c in - h) usage; exit 0;; - v) VERSION=$2; shift;; - \?) usage; exit 1;; - esac - done - - if [ -z "$VERSION" ]; then - usage - exit 1 - fi - - setup_repo - add_bump_tag - rm -rf $TMP_DIR - - echo "*** Travis build history: https://travis-ci.org/$PTNFLY_REPO_SLUG/builds" -} diff --git a/scripts/release/release.sh b/scripts/release/release.sh deleted file mode 100755 index 417649d28..000000000 --- a/scripts/release/release.sh +++ /dev/null @@ -1,291 +0,0 @@ -#!/bin/sh - -default() -{ - # Add paths to env (non-Travis build) - if [ -z "$TRAVIS" ]; then - PATH=/bin:/usr/bin:/usr/local/bin:$PATH - export PATH - fi - - SCRIPT=`basename $0` - SCRIPT_DIR=`dirname $0` - SCRIPT_DIR=`cd $SCRIPT_DIR; pwd` - - . $SCRIPT_DIR/env.sh - . $SCRIPT_DIR/common.sh - - BOWER_JSON=bower.json - PACKAGE_JSON=package.json - SHRINKWRAP_JSON=npm-shrinkwrap.json - - TMP_DIR="/tmp/patternfly-releases" - PTNFLY_DIR="$TMP_DIR/angular-patternfly" - VERIFY_DIR="$TMP_DIR/angular-patternfly-verify" - - # For Travis, build the current repo instead of using a clone. - if [ -n "$TRAVIS" ]; then - PTNFLY_DIR=`cd $SCRIPT_DIR/../..; pwd` - fi -} - -# Bump version number in bower.json -# -bump_bower() -{ - echo "*** Bumping version in $BOWER_JSON to $VERSION" - cd $PTNFLY_DIR - - PKG_VERSION=get_pkg_version - - sed "s|\"version\":.*|\"version\": \"$VERSION\",|" $BOWER_JSON | \ - sed "s|\"patternfly\":.*|\"patternfly\": \"$PTNFLY_PKG_REPO$VERSION\"|" > $BOWER_JSON.tmp - check $? "Version bump failure" - - mv $BOWER_JSON.tmp $BOWER_JSON -} - -# Bump version number in package.json -# -bump_package() -{ - echo "*** Bumping version in $PACKAGE_JSON to $VERSION" - cd $PTNFLY_DIR - - PKG_VERSION=get_pkg_version - - sed "s|\"version\":.*|\"version\": \"$VERSION\",|" $PACKAGE_JSON | \ - sed "s|\"patternfly\":.*|\"patternfly\": \"$PTNFLY_PKG_REPO$VERSION\"|" > $PACKAGE_JSON.tmp - check $? "Version bump failure" - - mv $PACKAGE_JSON.tmp $PACKAGE_JSON -} - -# Clean dependencies -# -clean() -{ - echo "*** Cleaning dependencies" - cd $PTNFLY_DIR - - if [ -z "$TRAVIS" ]; then - # Clean npm and bower installs (non-Travis build) - npm cache clean - bower cache clean - - # Remove for repo rebuild - if [ -d node_modules ]; then - rm -rf node_modules - fi - if [ -d lib ]; then - rm -rf lib - fi - fi - - # shrinkwrap - if [ -s $SHRINKWRAP_JSON ]; then - rm -f $SHRINKWRAP_JSON - fi -} - -# Commit changes prior to bower verify step -# -commit() -{ - echo "*** Committing changes" - cd $PTNFLY_DIR - - git add -u - git commit -m "Bumped version number to $VERSION" -} - -# Test prerequisites -# -prereqs() -{ - JUNK=`which npm` - check $? "Cannot find npm in path" - - JUNK=`which bower` - check $? "Cannot find bower in path" - - JUNK=`which grunt` - check $? "Cannot find grunt in path" -} - -# Publish to npm -# -publish_npm() -{ - echo "*** Publishing npm" - cd $PTNFLY_DIR - - npm publish - check $? "npm publish failure" -} - -# Push changes to remote repo (non-Travis build) -# -push() -{ - if [ -n "$TRAVIS" ]; then - return - fi - - echo "*** Pushing changes to $PTNFLY_REPO_SLUG" - cd $PTNFLY_DIR - - git push --set-upstream origin $BRANCH --force - check $? "git push failure" - - echo "*** Changes pushed to the $BRANCH branch of $PTNFLY_REPO_SLUG" - echo "*** Review changes and create a PR via GitHub" -} - -# Setup local repo (non-Travis build) -# -setup_repo() { - if [ -n "$TRAVIS" ]; then - return - fi - - echo "*** Setting up local repo $PTNFLY_DIR" - rm -rf $PTNFLY_DIR - - mkdir -p $TMP_DIR - cd $TMP_DIR - - git clone https://github.com/$PTNFLY_REPO_SLUG.git - check $? "git clone failure" - - cd $PTNFLY_DIR - git checkout $BRANCH - if [ "$?" -ne 0 ]; then - git checkout -B $BRANCH - fi - check $? "git checkout failure" -} - -# Shrink wrap npm and run vulnerability test -# -shrinkwrap() -{ - echo "*** Shrink wrapping $SHRINKWRAP_JSON" - cd $PTNFLY_DIR - - # Don't shrinkwrap dev dependencies - npm prune -production - - npm shrinkwrap - check $? "npm shrinkwrap failure" - - # Restore for testing - npm install -} - -usage() -{ -cat <<- EEOOFF - - This script will bump repo version numbers, build, shrinkwrap, test, install, push to GitHub, and publish to npm. - - Success depends on the version number matching a release of Pattenrfly. - - Note: After changes are pushed, a PR will need to be created via GitHub. - - sh [-x] $SCRIPT [-h|p|f|s] -v - - Example: sh $SCRIPT -v 3.15.0 -f - - OPTIONS: - h Display this message (default) - f Force push new branch to GitHub (e.g., bump-v3.15.0) - p Publish to npm (not valid with -s or -v) - s Skip new clone, clean, and install to rebuild previously created repo - v The version number (e.g., 3.15.0) - -EEOOFF -} - -# Verify npm and bower installs prior to publish step -# -verify() -{ - echo "*** Verifying install" - rm -rf $VERIFY_DIR - - mkdir -p $VERIFY_DIR - cd $VERIFY_DIR - - npm install $PTNFLY_DIR - check $? "npm install failure" - - bower install $PTNFLY_DIR/bower.json - check $? "bower install failure" -} - -# main() -{ - default - - if [ "$#" -eq 0 ]; then - usage - exit 1 - fi - - while getopts hfpsv c; do - case $c in - h) usage; exit 0;; - f) PUSH=1;; - p) PUBLISH=1 - BRANCH=master-dist;; - s) SKIP_SETUP=1;; - v) VERSION=$2; shift - BRANCH=bump-v$VERSION;; - \?) usage; exit 1;; - esac - done - - if [ -z "$VERSION" -a -z "$PUBLISH" -o -n "$VERSION" -a -n "$PUBLISH" ]; then - usage - exit 1 - fi - - prereqs - - if [ -z "$PUBLISH" ]; then - if [ -z "$SKIP_SETUP" ]; then - setup_repo - fi - - bump_bower - bump_package - - if [ -z "$SKIP_SETUP" ]; then - clean - build_install - fi - - build - shrinkwrap - build_test - commit - verify - - # Push changes to remote branch - if [ -n "$PUSH" ]; then - push - fi - if [ -z "$TRAVIS" ]; then - echo "*** Run $SCRIPT -p to publish npm after PR has been merged" - fi - else - # Publish from the latest repo clone -- don't skip setup step - setup_repo - publish_npm - fi - - if [ -z "$TRAVIS" ]; then - echo "*** Remove $TMP_DIR directory manually after testing" - fi -}