-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.sh
executable file
·65 lines (53 loc) · 1.23 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
64
65
#!/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
echo 'v0.0.0'
fi
}
set_version() {
local ver="$(echo $PKG_VERSION | tr '~' '-' | tr -d v)"
sed -r -i'' "s/0\.0\.0/$ver/g" "$1"
}
if [ -z "${PKG_VERSION:-}" ]; then
PKG_VERSION="$(pkgver_from_git)"
fi
export PATH="$VENV_DIR/bin:$PATH"
unset PYTHONHOME
if [ -z "${TRAVIS_BUILD_DIR:-}" ]; then
BUILD_DIR="$(pwd)/build"
echo "$BUILD_DIR"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
rsync -av --delete --exclude .venv --exclude .git --exclude build . "$BUILD_DIR"
cd "$BUILD_DIR"
fi
ls -lha
einfo "Set version $PKG_VERSION"
for d in */ ; do
case $d in *.egg-info/)
continue
esac
set_version "${d}__init__.py"
done
einfo "Run sdist"
python3 setup.py sdist