| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
# Test the currently built release of Colorama from the dist/ dir. |
| 4 |
# Run this before making a release. |
| 5 |
# |
| 6 |
# This should be run on Windows, because Colorama is mostly a no-op elsewhere. |
| 7 |
# Hmmm, this script should probably be a .bat file then? Nah, WSL FTW. |
| 8 |
# |
| 9 |
# Uploads package from the dist/ directory to the *test* PyPI. |
| 10 |
# Create a fresh virtualenvironment and install colorama from test PyPI. |
| 11 |
# Import Colorama and make trivial use of it. |
| 12 |
|
| 13 |
# Exit on error |
| 14 |
set -eu -o pipefail |
| 15 |
|
| 16 |
syspython=python3 |
| 17 |
bin="$HOME/.virtualenvs/colorama/bin" |
| 18 |
sandbox=test-release-playground |
| 19 |
|
| 20 |
# Upload to the test PyPI. |
| 21 |
$bin/twine upload --repository testpypi dist/colorama-* \ |
| 22 |
|| echo " > Expect a 400 if package was already uploaded." |
| 23 |
|
| 24 |
# cd elsewhere so we cannot import from local source. |
| 25 |
mkdir -p $sandbox |
| 26 |
( |
| 27 |
# Create a temporary disposable virtualenv. |
| 28 |
$syspython -m venv --clear $sandbox/venv |
| 29 |
|
| 30 |
# voodoo sleep. I saw the following install fail, due to expected version |
| 31 |
# not being listed at test.pypi.org, but then a few seconds later, re-run |
| 32 |
# manually, it worked fine. |
| 33 |
sleep 5 |
| 34 |
|
| 35 |
version=$(grep __version__ colorama/__init__.py | cut -d' ' -f3 | tr -d "'") |
| 36 |
|
| 37 |
cd $sandbox |
| 38 |
|
| 39 |
# Install the package we just uploaded. |
| 40 |
# (--extra-index-url for this project's requirements) |
| 41 |
venv/bin/python -m pip --quiet install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple colorama==$version |
| 42 |
|
| 43 |
# Import and use Colorama from the temp virtualenv. |
| 44 |
venv/bin/python -c "import colorama; colorama.init(); print(colorama.Fore.GREEN + \"OK: Colorama\", colorama.__version__, \"from test pypi install.\")" |
| 45 |
) |
| 46 |
|
| 47 |
# Tidy up |
| 48 |
rm -rf $sandbox |