4 COREFILE
='Source/Core/Core.js'
5 PKGFILES
='package.json bower.json'
7 DIST
='node_modules/.bin/grunt'
12 COREFILE
="$DIR/$COREFILE"
13 TAG
=`echo "$1" | cut -d'.' -f-$TAGLENGTH`
14 SUFFIX
="`echo "$2" | tr '[A-Z]' '[a-z]'`"
15 BUILD
=`sh -c "cd '$DIR' && git rev-parse HEAD"`
16 CUTLENGTH
=`echo "$TAGLENGTH - 1" | bc`
19 moo
"Usage: $0 <tag> [suffix]
21 suffix: alpha, beta or rc*"
30 NUMBER
=`echo "$1" | sed 's/^[a-z]*[ ]*\([0-9]*\).*/\1/'`
31 [ -n "$NUMBER" ] && echo "$NUMBER" ||
echo "1"
34 [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] && usage
35 [ -z "$BUILD" ] && moo
'Unable to determine build.'
36 [ -z "$DIST" -o -x "$DIR/$DIST" ] || moo
"Cannot execute '$DIST', did you npm install?"
38 until [ -n "`echo "$TAG.
" | cut -d'.' -f$TAGLENGTH`" ]; do
43 '') RELEASE
=''; SUFFIX
='';;
44 a
*) NUMBER
="`get_suffixnumber $SUFFIX`"; RELEASE
=" Alpha $NUMBER"; SUFFIX
="-a$NUMBER";;
45 b
*) NUMBER
="`get_suffixnumber $SUFFIX`"; RELEASE
=" Beta $NUMBER"; SUFFIX
="-b$NUMBER";;
46 rc
*) NUMBER
="`get_suffixnumber $SUFFIX`"; RELEASE
=" Release Candidate $NUMBER"; SUFFIX
="-rc$NUMBER";;
47 *) moo
'Invalid suffix specified.';;
50 if [ "$TAG" != "$1" ]; then
51 echo -n "Did you mean $TAG$SUFFIX? (y/n): "
53 [ "$FIXTAG" = "y" ] || moo
"Invalid tag specified, this project's tags consist of $TAGLENGTH parts."
56 sh
-c "cd '$DIR' && git show-ref --quiet --tags '$TAG$SUFFIX'" && moo
"Tag $TAG$SUFFIX already exists."
58 if [ -z "$SUFFIX" ]; then
59 MINOR
=`echo "$TAG" | cut -d'.' -f$TAGLENGTH-`
60 [ -z "$MINOR" ] && MINOR
='0'
61 NEXTTAG
="`echo "$TAG" | cut -d'.' -f-$CUTLENGTH`.`echo "$MINOR + 1" | bc`-dev"
66 if [ -n "$DIST" -a -d "$DIR/$DIST_DIR" ]; then
67 echo -n "The '$DIST_DIR' directory already exists. Overwrite it? (y/n): "
69 if [ "$DELETEDIST" = "y" ]; then
70 sh
-c "cd '$DIR' && git rm -r '$DIR/$DIST_DIR'"
72 moo
"Aborting, will not overwrite '$DIST_DIR'."
76 # Replace build and version strings.
77 sed -i".$BUILD" -e "s/\(version:[ ]*\)'[0-9.]*-dev'/\1'$TAG$SUFFIX'/" -e "s/\(build:[ ]*\)'%build%'/\1'$BUILD'/" "$COREFILE" || moo
"Error setting version and build for $TAG$SUFFIX in $COREFILE."
78 sh
-c "cd '$DIR' && git add '$COREFILE'" || moo
"Error adding changed $COREFILE for $TAG$SUFFIX to repository."
79 for PKGFILE
in $PKGFILES; do
80 PKGFILE
="$DIR/$PKGFILE"
81 sed -i".$BUILD" -e "s/^\([ ]*\"version\":[ ]*\)\"[0-9.]*-dev\"/\1\"$TAG$SUFFIX\"/" "$PKGFILE" || moo
"Error setting version for $TAG$SUFFIX in $PKGFILE."
82 sh
-c "cd '$DIR' && git add '$PKGFILE'" || moo
"Error adding changed $PKGFILE for $TAG$SUFFIX to repository."
86 if [ -n "$DIST" ]; then
87 echo "Building '$DIST_DIR' files." >&2
88 sh
-c "cd '$DIR' && $DIST $DIST_ARGS" || moo
"Error building '$DIST_DIR' files."
89 sh
-c "cd '$DIR' && git add -f '$DIR/$DIST_DIR'" || moo
"Error adding '$DIST_DIR' files to repository."
90 echo "Succesfully built '$DIST_DIR' files." >&2
93 # Make the new release final.
94 sh
-c "cd '$DIR' && git commit -qm 'Welcome $TAG$SUFFIX.'" || moo
"Error committing $TAG$SUFFIX."
95 sh
-c "cd '$DIR' && git tag -am '$TAG$RELEASE.' '$TAG$SUFFIX'" || moo
"Error tagging $TAG$SUFFIX."
96 echo "Tagged $TAG$SUFFIX." >&2
98 # Revert to old corefile and pkgfiles.
99 mv "$COREFILE.$BUILD" "$COREFILE" || moo
"Error reverting version and build in $COREFILE."
100 for PKGFILE
in $PKGFILES; do
101 PKGFILE
="$DIR/$PKGFILE"
102 mv "$PKGFILE.$BUILD" "$PKGFILE" || moo
"Error reverting version in $PKFILE."
105 # Replace build and version strings.
106 sed -i".$BUILD" -e "s/\(version:[ ]*\)'[0-9.]*-dev'/\1'$NEXTTAG'/" "$COREFILE" || moo
"Error setting version $NEXTTAG in $COREFILE."
107 sh
-c "cd '$DIR' && git add '$COREFILE'" || moo
"Error adding changed $COREFILE for $NEXTTAG to repository."
108 for PKGFILE
in $PKGFILES; do
109 PKGFILE
="$DIR/$PKGFILE"
110 sed -i".$BUILD" -e "s/^\([ ]*\"version\":[ ]*\)\"[0-9.]*-dev\"/\1\"$NEXTTAG\"/" "$PKGFILE" || moo
"Error setting version for $NEXTTAG in $PKGFILE."
111 sh
-c "cd '$DIR' && git add '$PKGFILE'" || moo
"Error adding changed $PKGFILE for $NEXTTAG to repository."
114 # Clean up temporary and dist files.
115 rm "$COREFILE.$BUILD" || moo
"Error cleaning up $COREFILE.$BUILD."
116 for PKGFILE
in $PKGFILES; do
117 PKGFILE
="$DIR/$PKGFILE"
118 rm "$PKGFILE.$BUILD" || moo
"Error cleaning up $PKGFILE.$BUILD."
120 if [ -n "$DIST" ]; then
121 sh
-c "cd '$DIR' && git rm -qr '$DIR/$DIST_DIR'" || moo
"Error cleaning up '$DIST_DIR' files."
124 # Make the new dev version final.
125 sh
-c "cd '$DIR' && git commit -qm 'Hello $NEXTTAG.'" || moo
"Error committing $NEXTTAG."
126 echo "Committed $NEXTTAG." >&2