Skip to content

Commit

Permalink
Add build
Browse files Browse the repository at this point in the history
  • Loading branch information
blavka committed Oct 5, 2018
1 parent ab2f593 commit 2a96a93
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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=
60 changes: 60 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2a96a93

Please sign in to comment.