Skip to content

Commit d9141b9

Browse files
Merge pull request #354 from dlabrecq/travis-release
Automate the Patternfly releases process via Travis
2 parents f831564 + 024c5d8 commit d9141b9

File tree

12 files changed

+903
-123
lines changed

12 files changed

+903
-123
lines changed

.travis.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ env:
99
- TRIGGER_REPO_SLUG: "patternfly/angular-patternfly"
1010
- TRIGGER_REPO_BRANCH: "master"
1111

12-
1312
before_install:
1413
- 'git checkout -B $TRAVIS_BRANCH' # Reconcile detached HEAD
1514
- 'npm install -g bower grunt-cli'
1615

1716
script:
18-
- 'npm install'
19-
- 'bower install'
20-
- 'grunt'
21-
- 'grunt ngdocs:publish'
17+
- sh -x ./scripts/build.sh
2218

2319
after_success:
24-
- sh -x ./scripts/publish.sh
2520
- ./scripts/publish-ghpages.sh -t docs
2621

2722
# OpenShift expects its deployment branch to be "master-dist". This can be changed using:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"karma-junit-reporter": "0.2.2",
4242
"karma-ng-html2js-preprocessor": "~0.1",
4343
"karma-phantomjs-launcher": "^1.0.0",
44-
"matchdep": "0.3.0"
44+
"matchdep": "0.3.0",
45+
"nsp": "^2.6.1"
4546
},
4647
"scripts": {
4748
"test": "grunt test"

scripts/build.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/sh
2+
3+
default()
4+
{
5+
SCRIPT=`basename $0`
6+
SCRIPT_DIR=`dirname $0`
7+
SCRIPT_DIR=`cd $SCRIPT_DIR; pwd`
8+
9+
. $SCRIPT_DIR/release/env.sh
10+
. $SCRIPT_DIR/release/common.sh
11+
12+
PTNFLY_DIR=`cd $SCRIPT_DIR/..; pwd`
13+
}
14+
15+
# Publish to dist branch
16+
#
17+
publish()
18+
{
19+
echo "*** Publishing"
20+
cd $PTNFLY_DIR
21+
22+
sh -x $SCRIPT_DIR/publish.sh
23+
check $? "Publish failure"
24+
}
25+
26+
usage()
27+
{
28+
cat <<- EEOOFF
29+
30+
This script will build, publish, and release the repo.
31+
32+
Note: Intended for use with Travis only.
33+
34+
sh [-x] $SCRIPT [-h]
35+
36+
Example: sh $SCRIPT
37+
38+
OPTIONS:
39+
h Display this message (default)
40+
41+
EEOOFF
42+
}
43+
44+
# main()
45+
{
46+
default
47+
48+
while getopts h c; do
49+
case $c in
50+
h) usage; exit 0;;
51+
\?) usage; exit 1;;
52+
esac
53+
done
54+
55+
echo "This build is running against $TRAVIS_REPO_SLUG"
56+
57+
if [ -n "$TRAVIS_TAG" ]; then
58+
echo "This build is running against $TRAVIS_TAG"
59+
60+
# Get version from tag
61+
case "$TRAVIS_TAG" in
62+
$BUMP_TAG_PREFIX* ) RELEASE=1;;
63+
*) echo "$TRAVIS_TAG is not a recognized format. Do not release!";;
64+
esac
65+
fi
66+
67+
if [ -n "$RELEASE" ]; then
68+
sh -x $SCRIPT_DIR/release/build.sh
69+
check $? "Release failure"
70+
else
71+
git_setup
72+
build_install
73+
build
74+
build_test
75+
76+
# Skip publish for pull requests
77+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
78+
publish
79+
fi
80+
fi
81+
}

scripts/publish.sh

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,85 @@
1-
#/bin/sh
2-
3-
set -o errexit -o nounset
4-
5-
# User info
6-
git config user.name "patternfly-build"
7-
git config user.email "[email protected]"
8-
git config --global push.default simple
9-
10-
# Add upstream authentication token
11-
git remote add upstream https://$AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
12-
13-
# Commit generated files
14-
git add dist --force
15-
git commit -m "Added files generated by Travis build"
16-
17-
# Must commit changes for pushing to OpenShift, but
18-
# only deploy to the dist branch for tags.
19-
if [ -z "$TRAVIS_TAG" -a "$TRAVIS_BRANCH" != "master" ]
20-
then
21-
echo "This commit was made against $TRAVIS_BRANCH and not the master or tag! Do not deploy!"
22-
exit 0
23-
fi
24-
25-
# Push to dist branch
26-
EXISTING=`git ls-remote --heads https://github.com/"$TRAVIS_REPO_SLUG".git "$TRAVIS_BRANCH"-dist`
27-
28-
if [ -z "$TRAVIS_TAG" ]
29-
then
30-
if [ -n "$EXISTING" ]
31-
then
32-
git fetch upstream $TRAVIS_BRANCH-dist:$TRAVIS_BRANCH-dist
1+
#!/bin/sh
2+
3+
default()
4+
{
5+
SCRIPT=`basename $0`
6+
SCRIPT_DIR=`dirname $0`
7+
SCRIPT_DIR=`cd $SCRIPT_DIR; pwd`
8+
9+
. $SCRIPT_DIR/release/env.sh
10+
. $SCRIPT_DIR/release/common.sh
11+
12+
PTNFLY_DIR=`cd $SCRIPT_DIR/..; pwd`
13+
}
14+
15+
# Push generated files to dist branch
16+
#
17+
push_dist()
18+
{
19+
echo "*** Pushing to $TRAVIS_BRANCH-dist"
20+
cd $PTNFLY_DIR
21+
22+
# Commit generated files
23+
git add dist --force
24+
git commit -m "Added files generated by Travis build"
25+
check $? "git commit failure"
26+
27+
# Push to dist branch
28+
EXISTING=`git ls-remote --heads https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH-dist`
29+
30+
if [ -n "$EXISTING" ]; then
31+
git fetch upstream $TRAVIS_BRANCH-dist:$TRAVIS_BRANCH-dist # <remote-branch>:<local-branch>
3332
git checkout $TRAVIS_BRANCH-dist
34-
git merge -Xtheirs $TRAVIS_BRANCH --no-edit --ff
33+
git merge -Xtheirs $TRAVIS_BRANCH-local --no-edit --ff
34+
check $? "git merge failure"
35+
3536
git push upstream $TRAVIS_BRANCH-dist --force -v
3637
else
37-
git push upstream $TRAVIS_BRANCH:$TRAVIS_BRANCH-dist --force -v
38+
git push upstream $TRAVIS_BRANCH-local:$TRAVIS_BRANCH-dist --force -v
3839
fi
39-
fi
40+
check $? "git push failure"
41+
}
42+
43+
usage()
44+
{
45+
cat <<- EEOOFF
46+
47+
This script will publish generated files to GitHub.
48+
49+
Note: Intended for use with Travis only.
50+
51+
sh [-x] $SCRIPT [-h]
52+
53+
Example: sh $SCRIPT
54+
55+
OPTIONS:
56+
h Display this message (default)
57+
58+
EEOOFF
59+
}
60+
61+
# main()
62+
{
63+
default
64+
65+
while getopts h c; do
66+
case $c in
67+
h) usage; exit 0;;
68+
\?) usage; exit 1;;
69+
esac
70+
done
71+
72+
# Avoid creating a dist equivalent for all branches in the main repo
73+
if [ "$TRAVIS_REPO_SLUG" = "$PTNFLY_REPO_SLUG" -a "$TRAVIS_BRANCH" != "master" ]; then
74+
echo "This commit was made against $TRAVIS_BRANCH and not the master or tag! Do not deploy!"
75+
exit 0
76+
fi
77+
78+
# Ensure dist branch is not redeployed.
79+
case "$TRAVIS_BRANCH" in
80+
*-dist ) echo "This commit was made against the dist branch. Do not deploy!"; exit 0;;
81+
esac
82+
83+
git_setup
84+
push_dist
85+
}

scripts/release/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Patternfly Release Process
2+
3+
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).
4+
5+
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.
6+
7+
### release.sh
8+
9+
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.
10+
11+
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.
12+
13+
This is useful when debugging build issues or publishing individual releases. In fact, release-all.sh uses this script to automate the release process.
14+
15+
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))
16+
2. Bump the version number, build, etc.
17+
- Run sh ./scripts/release/release.sh -v <version> -f
18+
3. Review ngDoc pages, verify latest changes
19+
- cd /tmp/patternfly-releases/angular-patternfly
20+
- Run grunt server
21+
4. PR reviewed & merged (no dist files should be checked in)
22+
5. NPM Publish
23+
- Create an NPM account and become a collaborator for https://www.npmjs.com/package/angular-patternfly
24+
- Run sh ./scripts/release/release.sh -p
25+
6. Release Notes Published (via GitHub)
26+
- Tag “master-dist” branch commit with updated version
27+
7. Community email sent ([email protected])
28+
29+
### release-all.sh
30+
31+
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.
32+
33+
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.
34+
35+
Although there is no PR to deal with here, creating release notes is still a task which must be performed manually via GitHub.
36+
37+
Note: Builds can only be stopped via the Travis CI.
38+
39+
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))
40+
2. Run sh ./scripts/release/release-all.sh -v <version>
41+
3. Release Notes Published (via GitHub)
42+
- Tag “master-dist” branch commit with updated version
43+
4. Run sh ./scripts/release/notify.sh -v <version>

0 commit comments

Comments
 (0)