Skip to content
This repository
Newer
Older
100755 173 lines (131 sloc) 6.072 kb
de31e5ba » fmpwizard
2012-08-21 * Added build script
1 #!/bin/bash
2 #It is called unsafe so most people stay away from this
3 #But this script is safe to use if you are trying to publish Lift Framework to sonatype
4 #as a release version (including Milestones and RC's
5
6
7 ## This scripts runs on mac's bash terminal
8
9 # Exit on any errors and on unbound vars to be safe
10 set -o errexit
11 set -o nounset
12
13
14 BUILDLOG=/tmp/Lift-do-release-`date "+%Y%m%d-%H%M%S"`.log
15
16 # This script is an attempt to automate the Lift release process
17 #
18 # From Indrajit, the steps on each module (superbuild, framework, examples) are:
19 #
20 # 1. git checkout -b <version>
21 # 2. ./liftsh 'set project.version <version>'
22 # 3. Edit project/plugins/Plugins.scala to change the version of lift-sbt
23 # 4. git commit -v -a -m "Prepare for <version>"
24 # 5. git push origin <version>
25 # 6. git tag <version>-release
26 # 7. git push origin <version>-release
bdffe181 » fmpwizard
2013-11-07 the latest pgp plugin does not sign jars with publish, now you have t…
27 # 8. LIFTSH_OPTS="-Dpublish.remote=true -Dsbt.log.noformat=true" ./liftsh clean-cache clean-plugins reload +clean-lib +update +clean +publish-signed
de31e5ba » fmpwizard
2012-08-21 * Added build script
28 # 9. Wait for happiness
29
30 SCRIPTVERSION=0.1
31
32 ##### Utility functions (break these out into an include?) #####
33 # Basically yes/no confirmation with customized messages
34 # Usage: confirm "prompt"
35 # Returns 0 for yes, 1 for no
36 function confirm {
37 while read -p "$1 [yes/no] " CONFIRM; do
38 case "`echo $CONFIRM | tr [:upper:] [:lower:]`" in
39 yes)
40 return 0
41 ;;
42 no)
43 return 1
44 ;;
45 *)
46 echo "Please enter yes or no"
47 ;;
48 esac
49 done
50 }
51
52 function debug {
53 #echo $@
54 echo -n ""
55 }
56
57 function die {
58 echo $@
59 exit 1
60 }
61
62 # Locate our base directory (taken from http://blog.eitchnet.ch/?p=242)
63 SCRIPT_NAME="${PWD##*/}"
64 SCRIPT_DIR="${PWD%/*}"
65
66 # if the script was started from the base directory, then the
67 # expansion returns a period
68 if test "$SCRIPT_DIR" == "." ; then
69 SCRIPT_DIR="$PWD"
70 # if the script was not called with an absolute path, then we need to add the
71 # current working directory to the relative path of the script
72 elif test "${SCRIPT_DIR:0:1}" != "/" ; then
73 SCRIPT_DIR="$PWD/$SCRIPT_DIR"
74 fi
75
76 echo -e "\n*********************************************************************"
77 echo -e "SCRIPT_DIR is ${SCRIPT_DIR}"
78 echo -e "\n*********************************************************************"
79
80 ##### End Utility Functions #####
81
82
83 echo -e "\n*********************************************************************"
84 printf "* Lift Full Release build script version %-26s *\n" "$SCRIPTVERSION"
85 #echo "* Default choices for prompts are marked in capitals *"
86 printf "*********************************************************************\n\n"
87
88 echo -e "Build output logged to $BUILDLOG\n"
89
90
91 # CouchDB will blow up with HTTP proxy set because it doesn't correctly interpret the return codes
92 set +o nounset
93 if [ ! -z "${http_proxy}" -o ! -z "${HTTP_PROXY}" ]; then
94 echo -e "CouchDB tests will fail with http_proxy set! Please unset and re-run.\n"
95 exit
96 fi
97 set -o nounset
98
99 # First, let's confirm that we really want to release...
100 confirm "Are you certain you want a release build?" || die "Cancelling release build."
101
102 echo -e "\nProceeding...\n"
103
104 # Now we need to know what version we're releasing
105 read -p "Please enter the version of the release: " RELEASE_VERSION
106
107 # Sanity check on the release version
108 if ! echo $RELEASE_VERSION | egrep -x '[0-9]+\.[0-9]+(-(M|RC)[0-9]+)?' > /dev/null; then
109 confirm "$RELEASE_VERSION does not appear to be a valid version. Are you sure?" ||
110 die "Cencelling release build!"
111 fi
112
113 # Perform a sanity check on the modules first
114 for MODULE in framework ; do
115 cd ${SCRIPT_DIR}/${MODULE}
116
117 echo "We cd'ed into `pwd`"
118
119 # ensure that we're on master, and that we're up-to-date
120 CURRENT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
121 debug "Current branch for $MODULE is $CURRENT_BRANCH"
122
123 if [ "${CURRENT_BRANCH}" != "master" ]; then
124 echo "Currently releases can only be built from master. $MODULE is on branch $CURRENT_BRANCH. Aborting build."
125 exit
126 fi
127
128 # ensure that we don't have any outstanding changes
129 if git status | grep -q "Changes not staged for commit" ; then
130 die "There are outstanding changes in $MODULE. Aborting build."
131 else
132 echo "All changes are committed, moving on"
133 fi
134
135 done
136
137 echo -e "\nPre-build tests passed. Initiating release build of LiftWeb version $RELEASE_VERSION\n"
138
139 # For the remaining modules, we follow indrajit's steps outlined above
140 for MODULE in framework ; do
141 echo -e "\nStarting build on $MODULE module"
142 cd ${SCRIPT_DIR}/${MODULE} || die "Could not change to $MODULE directory!"
143
144 git checkout -b ${RELEASE_VERSION} >> ${BUILDLOG} || die "Error creating work branch!"
145
146
147 ./liftsh ";set version in ThisBuild := \"${RELEASE_VERSION}\" ; session save " >> ${BUILDLOG} || die "Could not update project version in SBT!"
148
149 git commit -v -a -m "Prepare for ${RELEASE_VERSION}" >> ${BUILDLOG} || die "Could not commit project version change!"
150
151 #git push origin ${RELEASE_VERSION} >> ${BUILDLOG} || die "Could not push project version change!"
152
153 git tag ${RELEASE_VERSION}-release >> ${BUILDLOG} || die "Could not tag release!"
154
155 #git push origin ${RELEASE_VERSION}-release >> ${BUILDLOG} || die "Could not push release tag!"
156
157 # Do a separate build for each configured Scala version so we don't blow the heap
158 for SCALA_VERSION in $(grep crossScalaVersions build.sbt | cut -d '(' -f 2 | sed s/[,\)\"]//g ); do
159 echo -n " Building against Scala ${SCALA_VERSION}..."
f0f02cd6 » fmpwizard
2014-06-17 updated unsafePublish to using sbt 0.13.x
160 if ! ./liftsh ++${SCALA_VERSION} clean update test publishSigned >> ${BUILDLOG} ; then
de31e5ba » fmpwizard
2012-08-21 * Added build script
161 echo "failed! See build log for details"
162 exit
163 fi
164 echo "complete"
165 done
166
167 echo "Build complete for module ${MODULE}"
168
169 done
170
171 echo -e "\n\nRelease complete!"
f0f02cd6 » fmpwizard
2014-06-17 updated unsafePublish to using sbt 0.13.x
172 echo -e "\n\nPlease update the lift_sbt_2.6 templates!"
de31e5ba » fmpwizard
2012-08-21 * Added build script
173 echo -e "\n\nand write something about this release on the liftweb.net site."
174
175
176
Something went wrong with that request. Please try again.