From dd83933d5b4a48cfbb53f51a5af590baf48fc8c7 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 26 Dec 2017 14:41:30 +0100 Subject: Add release upload script --- .circleci/config.yml | 3 +++ .circleci/release.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 .circleci/release.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 47e30b8..3845c0e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,3 +32,6 @@ jobs: paths: - '~/.cabal' - '~/.ghc' + - run: + name: 'Upload release' + command: '.circleci/release.sh "$CIRCLE_TAG"' diff --git a/.circleci/release.sh b/.circleci/release.sh new file mode 100755 index 0000000..a47f027 --- /dev/null +++ b/.circleci/release.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -o nounset -o errexit -o pipefail + +TAG="$1" +SUFFIX="linux-$(uname -m)" +USER="jaspervdj" +REPOSITORY="$(basename "$(pwd)")" +BINARY="$REPOSITORY" + +echo "Tag: $TAG" +echo "Suffix: $SUFFIX" + +if [[ -z "$TAG" ]]; then + echo "Not a tagged build, skipping release..." + exit 0 +fi + +GHR_VERSION="v0.5.4" + +# Install ghr +wget --quiet \ + "https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/ghr_${GHR_VERSION}_linux_386.zip" +unzip ghr_${GHR_VERSION}_linux_386.zip + +# Create tarball +PACKAGE="$REPOSITORY-$TAG-$SUFFIX" +mkdir -p "$PACKAGE" +cp "$(which "$BINARY")" "$PACKAGE" +cp "README.*" "$PACKAGE" +tar -czf "$PACKAGE.tar.gz" "$PACKAGE" +rm -r "$PACKAGE" + +# Actually upload +./ghr -u "$USER" -r "$REPOSITORY" "$TAG" "$PACKAGE.tar.gz" -- cgit v1.2.3