From 2a96a936f5abab4bb86de7db79dd6a909e76a336 Mon Sep 17 00:00:00 2001 From: Karel Blavka Date: Fri, 5 Oct 2018 16:48:57 +0200 Subject: [PATCH] Add build --- .travis.yml | 14 +++++++++++++ build.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .travis.yml create mode 100755 build.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4169c15 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: false +language: python +python: 3.4 +script: +- "./test.sh" +- "./build.sh" +deploy: + provider: pypi + skip_cleanup: true + user: hardwario + on: + tags: true + password: + secure: x3fJa4rUA4B2Ui7NgNAyxhyv/kJhgfoFZ9hePaEsXnjS9gp1FpzZ8XScDDNBoIfJk6trnGkT92EVLbxdPG4kjbSXX9Z06QKGVvyiaSGoQQBYMZhLUdZsqXF7VfJRK0mrGaBMXN3Bsw1nJRsPEMgY0lC0W5MHFISH40Pa9+5sLRzR6MMdtc/bTjJVlua1YrWciYXKYQpf0Ab4c0rxeCvHyQAXChb5PESGgAAj1M/6LuBxm7SpQYpzOdWUwfY96cuZvfBA8iWk24QPcSAANGf1wxhM/hxyUdfxmIMmWaik5nno1k5+5kBasCAv6/q8QjlElS8f4PjzChQh55H3PpYlF9YuOTOyzVQF4YYqzt/L/QN6HubxJRmaDEOm3v+CE+CVXhJmY9HOUrwb0es3XqM9rzOQFUZw8m2bVyfcOwVMv5rTzbRkNMKnIAV9WEy1JK5JpnS3PodeRiMtQajAlTHi7S3GkeX5kKdAdXRW24O/pGuiMv/DQ9zKpnm2UDdCsFpYzoNJ+iBSR7sjRFLl3rlCGR/Iv8SdpXEC665I8SzH3nxT5OBdB4OkZbU7/5z5NgfZUfSLjQ+hTEM8TNDHgQcu6NGAYI+H7J84z9sPvROPOV82/j5A82ohVgTab14Ak8gRdnw/UfqGOhXKRj8iUOLiFCnYHsBPB+8H9YQS3RaZ6pM= diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cc17d8e --- /dev/null +++ b/build.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# vim: set ts=4: +set -eu + +VENV_DIR="$(pwd)/.venv" + +die() { + printf '\033[1;31mERROR:\033[0m %s\n' "$1" >&2 + shift + printf ' %s\n' "$@" + exit 2 +} + +einfo() { + printf '\033[1;36m> %s\033[0m\n' "$@" >&2 +} + +if [ "$(id -u)" -eq 0 ] && [ "$ALLOW_ROOT" != 'yes' ]; then + die 'Do not run this script as root!' +fi + +pkgver_from_git() { + local desc + if desc="$(git describe --tags --exact-match --match 'v*' 2>/dev/null)"; then + echo "${desc#v}" | sed 's/[_-]/~/g' + elif desc="$(git describe --tags --match 'v*' 2>/dev/null)"; then + echo "$desc" | sed -En 's/^v([^-]+).*/\1~dev/p' + else + return 1 + fi +} + +set_version() { + local ver="$(echo $PKG_VERSION | tr '~' '-')" + sed -r -i'' "s/@@VERSION@@/$ver/g" "$1" +} + +if [ -z "${PKG_VERSION:-}" ]; then + PKG_VERSION="$(pkgver_from_git)" || + die '$PKG_VERSION is not set and could not determine version from git!' +fi + +export PATH="$VENV_DIR/bin:$PATH" +unset PYTHONHOME + +if [ -z "${TRAVIS_BUILD_DIR:-}" ]; then + BUILD_DIR="$(pwd)/build" + echo "$BUILD_DIR" + mkdir -p "$BUILD_DIR" + cp -r cpctl "$BUILD_DIR"/cpctl + cp setup.py "$BUILD_DIR"/ + cd "$BUILD_DIR" +fi + +ls -lha + +set_version cpctl/cli.py +set_version setup.py + +python3 setup.py sdist