Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 
      3 function help_and_exit() {
      4     echo "Usage: $0 [-go] [-verbose] [-force]"
      5     echo
      6     echo "Moves minified CSS and JS to distribution directories and"
      7     echo "creates a branch in SVN."
      8     echo
      9     echo "  -go:       Run commands instead of just echoing them."
     10     echo "  -verbose:  More verbose logging."
     11     echo "  -force:    Ignore sanity checks for testing."
     12     echo "             Incompatible with -go."
     13     echo "  -nobranch: Don't create a new release branch."
     14     exit "$1"
     15 }
     16 
     17 # 1 for verbose logging
     18 export VERBOSE="0"
     19 # 1 if commands that have side-effects should actually be run instead of logged
     20 export EFFECT="0"
     21 
     22 for var in "$@"; do
     23   case "$var" in
     24       -verbose)
     25           VERBOSE="1"
     26           ;;
     27       -go)
     28           EFFECT="1"
     29           ;;
     30       -h)
     31           help_and_exit 0
     32           ;;
     33       *)
     34           echo "Unrecognized argument $var"
     35           help_and_exit -1
     36           ;;
     37   esac
     38 done
     39 
     40 
     41 function panic() {
     42     echo "PANIC: $*"
     43 
     44     if ! (( $NO_PANIC )); then
     45         exit -1
     46     fi
     47 }
     48 
     49 function command() {
     50     if (( $VERBOSE )) || ! (( $EFFECT )); then
     51         echo '$' "$*"
     52     fi
     53     if (( $EFFECT )); then
     54         "$@" || panic "command failed: $@"
     55     fi
     56 }
     57 
     58 export VERSION_BASE="$(
     59   pushd "$(dirname "$0")/../.." > /dev/null; pwd; popd > /dev/null)"
     60 
     61 if ! [ -d "$VERSION_BASE/trunk/tools" ]; then
     62     panic "missing trunk/tools in $VERSION_BASE"
     63 fi
     64 
     65 VERSION="$(svn info | perl -ne 'print $1 if m/^Revision: (\d+)$/')"
     66 
     67 DOWNLOADS_ZIP="$VERSION_BASE/trunk/out/owasp-java-html-sanitizer.zip"
     68 VERSIONED_ZIP="$VERSION_BASE/trunk/out/owasp-java-html-sanitizer-r$VERSION.zip"
     69 
     70 pushd "$VERSION_BASE/trunk" > /dev/null
     71 command make download
     72 popd > /dev/null
     73 
     74 if ! [ -f "$DOWNLOADS_ZIP" ]; then
     75     panic "$DOWNLOADS_ZIP is not up-to-date"
     76 fi
     77 
     78 command cp "$DOWNLOADS_ZIP" "$VERSIONED_ZIP"
     79 
     80 command "$VERSION_BASE/trunk/tools/googlecode_upload.py" \
     81     --summary="JARs, source JAR, and documentation for version $VERSION." \
     82     -p owasp-java-html-sanitizer -u mikesamuel \
     83     --labels='Type-Archive,OpSys-All,Featured' \
     84     "$VERSIONED_ZIP"
     85 
     86 if (( $EFFECT )); then
     87     echo "Don't forget to mark any old ones deprecated at"
     88     echo "https://code.google.com/p/owasp-java-html-sanitizer/downloads/list"
     89 else
     90     echo
     91     echo "Rerun with -go to actually run these commands."
     92 fi
     93