-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·63 lines (51 loc) · 1.29 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/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 cp2influxdb "$BUILD_DIR"/cp2influxdb
cp setup.py "$BUILD_DIR"/
cp requirements.txt "$BUILD_DIR"/
cp LICENSE "$BUILD_DIR"/
cp *.md "$BUILD_DIR"/
cd "$BUILD_DIR"
fi
ls -lha
set_version cp2influxdb/__init__.py
set_version setup.py
python3 setup.py sdist