-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build-release-artifacts.sh
executable file
·65 lines (58 loc) · 1.9 KB
/
build-release-artifacts.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
#!/usr/bin/env bash
###############################################################################
# Build release artifacts for the YAMLPath project.
###############################################################################
# Clean up old releases
[ -e dist ] && rm -rf dist
# Require successful tests
if [ ! -x run-tests.sh ]; then
echo "ERROR: run-tests.sh script must exist and be executable in the present directory!" >&2
exit 2
fi
./run-tests.sh $@ || exit $?
# Create a dedicated virtual Python enviroment for this
envName=venv-build-release-artifacts-$(date +%Y%m%dT%H%M%S)
if [ 0 -ne $? ]; then
echo "ERROR: Unable to identify the build virtual environment! Is date a command?" >&2
exit 3
fi
echo "Building virtual environment for $(python3 --version): ${envName}"
rm -rf "$envName"
python3 -m pip install --upgrade pip
python3 -m venv "$envName" || exit 86
source "$envName"/bin/activate || exit 87
# Update pip and install release tools
echo "Installing release tools..."
pip3 install ruamel.yaml wheel || exit $?
# Build release artifacts
echo "Building release artifacts..."
python3 setup.py sdist bdist_wheel || exit $?
# Generate a ZIP file for Windows users
echo "Building Windows ZIP file..."
pushd dist || exit 2
relname=$(basename $(ls -1 ./*.tar.gz) .tar.gz)
mkdir win \
&& cp "${relname}.tar.gz" win/ \
&& pushd win/ \
&& tar xvzf ./*.tar.gz \
&& rm -f ./*.gz \
&& zip --recurse-paths --test --verbose "${relname}.zip" "${relname}"/ \
&& mv ./*.zip .. \
&& popd \
&& rm -rf win
popd
# Clean up
echo "Cleaning up..."
deactivate
if ! rm -rf "$envName"; then
echo "WARNING: Unable to remove temporary build environment: ${envName}!"
fi
if ! rm -rf build; then
echo "WARNING: Unable to remove build directory!"
fi
if ! rm -rf yamlpath.egg-info; then
echo "WARNING: Unable to remove EGG information directory!"
fi
# Show the final release artifacts
echo -e "\nRelease artifacts:"
ls -1 ./dist/*