diff --git a/.travis.yml b/.travis.yml index 5c9be16..ad8c23c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,5 +31,16 @@ after_script: # run lintian after build - sudo apt-get install -qq --no-install-recommends lintian - lintian --info --display-info --display-experimental --pedantic --show-overrides ../*.deb && lintian --info --display-info --display-experimental --pedantic --show-overrides ../*.dsc + +env: + global: + # travis encrypt -r waja/ps-watcher GITHUBTOKEN=XXXXXX (https://help.github.com/articles/creating-an-access-token-for-command-line-use / http://docs.travis-ci.com/user/encryption-keys/) + secure: "Y4mgj75S6GAvPK1Xri4fPUZXipvwRIYzN4sVIaVbrZqJ1LxhR+91fNwRXxy9bsyI3Bje2H9ZK/W6anGUkqrk8rmjR4vvrbQtR2WBnS4Bt4CpdQKlg/SU1e6rSnJas92GqFf8JSv1C3T2rRcv0bLjhxs4GFUxuXltxmJwkAbWHhI=" + +after_success: + - mkdir -p debian/build/release/ + - for FILE in $(dcmd ../*.changes); do cp ../$(basename $FILE) debian/build/release/; done + - debian/bin/github-release.sh "$TRAVIS_REPO_SLUG" "debian/`head -1 debian/changelog | awk -F'[()]' '{print $2}' | awk -F'+' '{print $1}'`" debian/build/release/* + #notifications: # email: false diff --git a/debian/bin/github-release.sh b/debian/bin/github-release.sh new file mode 100755 index 0000000..2542112 --- /dev/null +++ b/debian/bin/github-release.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +# Copyright (c) 2014 Terry Burton +# +# https://github.com/terryburton/travis-github-release +# +# Permission is hereby granted, free of charge, to any +# person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the +# Software without restriction, including without +# limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software +# is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice +# shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +# This script provides a simple continuous deployment +# solution that allows Travis CI to publish a new GitHub +# release and upload assets to it whenever an annotated or +# signed tag is pushed (git tag -a/-s; git push --tags). +# +# It is created as a temporary solution whilst we wait for +# Travis DPL to support GitHub: +# +# https://github.com/travis-ci/dpl +# +# Place this script somewhere in your project repository (perhaps by forking +# the github-travis-release repo and adding your fork as a git submodule) then +# put something like this to your .travis.yml: +# +# after_success: .travis/github-release.sh "$TRAVIS_REPO_SLUG" "`head -1 src/VERSION`" build/release/* +# +# The first argument is your repository in the format +# "username/repository", which Travis provides in the +# TRAVIS_REPO_SLUG environment variable. +# +# The second argument is the release version which as a +# sanity check should match the tag that you are releasing. +# You could pass "`git describe`" to satisfy this check. +# +# The remaining arguments are a list of asset files that you +# want to publish along with the release. +# +# The script requires that you create a GitHub OAuth access +# token to facilitate the upload: +# +# https://help.github.com/articles/creating-an-access-token-for-command-line-use +# +# You must pass this securely in the GITHUBTOKEN environment +# variable: +# +# http://docs.travis-ci.com/user/encryption-keys/ +# +# For testing purposes you can create a local convenience +# file in the script directory called GITHUBTOKEN that sets +# the GITHUBTOKEN environment variable. If you do so you MUST +# ensure that this doesn't get pushed to your repository, +# perhaps by adding it to a .gitignore file. +# +# Should you get stuck then look at a working example. This +# code is being used by Barcode Writer in Pure PostScript +# for automated deployment: +# +# https://github.com/terryburton/postscriptbarcode + +set -e + +REPO=$1 && shift +RELEASE=$1 && shift +RELEASEFILES=$@ + +if ! TAG=`git describe --exact-match --all 2>/dev/null`; then + echo "This commit is not a tag so not creating a release" + exit 0 +fi + +if [ "$TRAVIS" = "true" ] && [ -z "$TRAVIS_TAG" ]; then + echo "This build is not for the tag so not creating a release" + exit 0 +fi + +if [ "$TRAVIS" = "true" ] && [ "$TRAVIS_TAG" != "$RELEASE" ]; then + echo "Error: TRAVIS_TAG ($TRAVIS_TAG) does not match the indicated release ($RELEASE)" + exit 1 +fi + +TAG=`echo "$TAG" | sed 's/^tags\///'` +if [ "$TAG" != "$RELEASE" ]; then + echo "Error: The tag ($TAG) does not match the indicated release ($RELEASE)" + exit 1 +fi + +if [[ -z "$RELEASEFILES" ]]; then + echo "Error: No release files provided" + exit 1 +fi + +SCRIPTDIR=`dirname $0` +[ -e "$SCRIPTDIR/GITHUBTOKEN" ] && . "$SCRIPTDIR/GITHUBTOKEN" +if [[ -z "$GITHUBTOKEN" ]]; then + echo "Error: GITHUBTOKEN is not set" + exit 1 +fi + +echo "Creating GitHub release for $RELEASE" + +echo -n "Create draft release... " +JSON=$(cat <