summaryrefslogtreecommitdiff
path: root/tools/upload_jars_to_googlecode_downloads.sh
blob: bc1a4f8d7faa081548b983d82b12a127ae1fb7d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash

function help_and_exit() {
    echo "Usage: $0 [-go] [-verbose] [-force]"
    echo
    echo "Moves minified CSS and JS to distribution directories and"
    echo "creates a branch in SVN."
    echo
    echo "  -go:       Run commands instead of just echoing them."
    echo "  -verbose:  More verbose logging."
    echo "  -force:    Ignore sanity checks for testing."
    echo "             Incompatible with -go."
    echo "  -nobranch: Don't create a new release branch."
    exit "$1"
}

# 1 for verbose logging
export VERBOSE="0"
# 1 if commands that have side-effects should actually be run instead of logged
export EFFECT="0"

for var in "$@"; do
  case "$var" in
      -verbose)
          VERBOSE="1"
          ;;
      -go)
          EFFECT="1"
          ;;
      -h)
          help_and_exit 0
          ;;
      *)
          echo "Unrecognized argument $var"
          help_and_exit -1
          ;;
  esac
done


function panic() {
    echo "PANIC: $*"

    if ! (( $NO_PANIC )); then
        exit -1
    fi
}

function command() {
    if (( $VERBOSE )) || ! (( $EFFECT )); then
        echo '$' "$*"
    fi
    if (( $EFFECT )); then
        "$@" || panic "command failed: $@"
    fi
}

export VERSION_BASE="$(
  pushd "$(dirname "$0")/../.." > /dev/null; pwd; popd > /dev/null)"

if ! [ -d "$VERSION_BASE/trunk/tools" ]; then
    panic "missing trunk/tools in $VERSION_BASE"
fi

VERSION="$(svn info | perl -ne 'print $1 if m/^Revision: (\d+)$/')"

DOWNLOADS_ZIP="$VERSION_BASE/trunk/out/owasp-java-html-sanitizer.zip"
VERSIONED_ZIP="$VERSION_BASE/trunk/out/owasp-java-html-sanitizer-r$VERSION.zip"

pushd "$VERSION_BASE/trunk" > /dev/null
command make download
popd > /dev/null

if ! [ -f "$DOWNLOADS_ZIP" ]; then
    panic "$DOWNLOADS_ZIP is not up-to-date"
fi

command cp "$DOWNLOADS_ZIP" "$VERSIONED_ZIP"

command "$VERSION_BASE/trunk/tools/googlecode_upload.py" \
    --summary="JARs, source JAR, and documentation for version $VERSION." \
    -p owasp-java-html-sanitizer -u mikesamuel \
    --labels='Type-Archive,OpSys-All,Featured' \
    "$VERSIONED_ZIP"

if (( $EFFECT )); then
    echo "Don't forget to mark any old ones deprecated at"
    echo "https://code.google.com/p/owasp-java-html-sanitizer/downloads/list"
else
    echo
    echo "Rerun with -go to actually run these commands."
fi