csvquerytool / deploy.sh

#!/bin/bash

set -e
set -o pipefail

VERSION_FILE="VERSION.txt"

if [ -f "$VERSION_FILE" ]; then
    deployed_version=$(cat "$VERSION_FILE")
else
    deployed_version=""
fi
latest_version=$(hg tags | head -2 | tail -1 | awk '{print $1}')
if [ "$deployed_version" = "$latest_version" ]; then
    echo "Nothing to do (latest version $deployed_version already deployed)"
else
    echo "Deploying version $latest_version to production"
    package_version=$(python setup.py --version)
    if [ "$package_version" = "$latest_version" ]; then
        echo "Releasing new production version: $latest_version"
        distutils_output=$(python setup.py sdist upload 2>&1)
        echo "$distutils_output"
        if echo "$distutils_output" | grep "^Upload failed" >/dev/null; then
            # setup.py returns an exit status of 0 even if the upload fails, so need to check the output
            # see distutils issue #245: https://bitbucket.org/tarek/distribute/issue/245/python-setuppy-should-return-a-non-zero
            echo "Error: pypi upload failed (if you manually upload the file, remember to update $VERSION_FILE)" >&2
            exit 1
        fi
        echo "$latest_version" > $VERSION_FILE
    else
        echo "Error: package version ($package_version) != SCM tag ($latest_version); did you update setup.py and .hgtags?" >&2
        exit 1
    fi
fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.