-
Notifications
You must be signed in to change notification settings - Fork 8
Setup release process #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,79 @@ | ||
#!/bin/bash | ||
set -x -e | ||
|
||
BASE_VERSION=1.0.0 | ||
|
||
if [ "$TRAVIS" != "true" ] ; then | ||
echo "Not running on travis, not supported at the moment" | ||
exit 1 | ||
fi | ||
|
||
if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then | ||
if [ "$TRAVIS_BRANCH" != "master" ] ; then | ||
BRANCH_FRAGMENT="-${TRAVIS_BRANCH////-}" | ||
else | ||
BRANCH_FRAGMENT="" | ||
cp .travis.settings.xml $HOME/.m2/settings.xml | ||
|
||
if [[ "$TRAVIS_BRANCH" =~ ^release/ ]] ; then | ||
RELEASE_VERSION=$(echo "$TRAVIS_BRANCH" | sed -e "s/release[/]//") | ||
|
||
if ! [[ "${RELEASE_VERSION}" =~ [0-9]+[.][0-9]+[.][0-9]+ ]] ; then | ||
echo "Invalid branch name: $TRAVIS_BRANCH" | ||
exit 1 | ||
fi | ||
|
||
POM_VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }'` | ||
|
||
if [ "${RELEASE_VERSION}-SNAPSHOT" != "${POM_VERSION}" ] ; then | ||
echo "Branch version ${RELEASE_VERSION} is not a SNAPSHOT or does not match POM version ${POM_VERSION}, assuming release was already done" | ||
exit 0 | ||
fi | ||
else | ||
BRANCH_FRAGMENT="-pr${TRAVIS_PULL_REQUEST}" | ||
fi | ||
|
||
SNAPSHOT_FRAGMENT="-SNAPSHOT" # TODO suppress on a release tag | ||
# MANIFEST.MF files might have been modified during previous steps, so we need to revert | ||
# these changes before release:prepare | ||
git stash save | ||
|
||
cd com.btc.serviceidl.plainjava && mvn versions:set -DnewVersion=${BASE_VERSION}${BRANCH_FRAGMENT}${SNAPSHOT_FRAGMENT} | ||
# Unshallow local repo to allow mvn release to work | ||
git fetch --unshallow | ||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" | ||
git fetch origin | ||
|
||
mvn deploy -DskipTests | ||
# Checkout branch (travis-ci has checked out the commit hash) | ||
# Note: if the branch has been updated in between, this will use a newer | ||
# revision than before, but for making the release this should not usually | ||
# happen, and should not matter anyway, since the newer revision would be | ||
# used by a subsequent build and overwrite the tag | ||
git checkout $TRAVIS_BRANCH | ||
|
||
DEVELOPMENT_VERSION=$(python -c 'version = tuple(map(int, ("'${RELEASE_VERSION}'".split(".")))); print("%i.%i.%i" % (version[0], version[1]+1, 0))') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you use python here when you you sed in all other places? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My sed knowledge is quite limited. I copied the sed expression from somewhere, but I wrote this myself ;) In addition, I think incrementing a number is not straight-forward with sed. |
||
|
||
mvn -B release:prepare -DreleaseVersion=${RELEASE_VERSION} -DdevelopmentVersion=${DEVELOPMENT_VERSION}-SNAPSHOT | ||
|
||
git config remote.origin.url https://sigiesec:${GITHUB_TOKEN}@github.com/btc-ag/service-idl.git | ||
git push origin v${RELEASE_VERSION} | ||
git push | ||
|
||
curl --fail -u sigiesec:${GITHUB_TOKEN} -X POST -d '{"title":"Start next development iteration after '${RELEASE_VERSION}' release", "base":"master", "head":"'${TRAVIS_BRANCH}'"}' https://api.github.com/repos/btc-ag/service-idl/pulls | ||
elif [ "$TRAVIS_TAG" == "" ] ; then | ||
SNAPSHOT_FRAGMENT="-SNAPSHOT" | ||
BASE_VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }' | sed -e 's/-SNAPSHOT//'` | ||
|
||
if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this checked here? |
||
if [ "$TRAVIS_BRANCH" != "master" ] ; then | ||
BRANCH_FRAGMENT="-${TRAVIS_BRANCH////-}" | ||
else | ||
BRANCH_FRAGMENT="" | ||
fi | ||
else | ||
BRANCH_FRAGMENT="-pr${TRAVIS_PULL_REQUEST}" | ||
fi | ||
|
||
cd com.btc.serviceidl.plainjava && mvn versions:set -DnewVersion=${BASE_VERSION}${BRANCH_FRAGMENT}${SNAPSHOT_FRAGMENT} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you build the new version from multiple fragments? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not changed as part of this PR, it was only moved into the if and the indentation was changed. RELEASE_VERSION and DEVELOPMENT_VERSION are not set at all in this block. |
||
|
||
mvn deploy -DskipTests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if release:perform is not used, this could be done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will leave it at is it for now. Maybe #181 will change this again. |
||
else | ||
# TODO alternatively, release:perform could be executed, but this would check out the same version that we are building right now; | ||
# or, we could run this in the branch build job, and do nothing in the tag build job; the latter would allow us to only push the branch changes if the release was successful | ||
|
||
## write release.properties file, since the tag cannot be specified on the command line | ||
#echo scm.url=scm:git:https://github.com/btc-ag/service-idl.git >release.properties | ||
#echo scm.tag=${TRAVIS_TAG} >>release.properties | ||
#rm .meta/p2-artifacts.properties | ||
#mvn -B release:perform | ||
|
||
mvn deploy -DskipTests | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
TRAVIS_BRANCH
set if building a PR?If not you can skip the check in line 55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is set for PR builds: "for builds triggered by a pull request this is the name of the branch targeted by the pull request."