Skip to content

Commit d30bf8b

Browse files
committed
Add publish script
1 parent 08cafca commit d30bf8b

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
"postCreateCommand": "pip3 install --user -r requirements.txt -r requirements_test.txt",
1919

2020
// Priviledged mode is necessary to get access to usb
21-
"runArgs": ["--privileged"]
21+
"runArgs": ["--privileged"],
2222

2323
// Configure tool-specific properties.
2424
// "customizations": {},
2525

2626
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
2727
//"remoteUser": "root"
28+
29+
// Access local .pypi api keys
30+
"mounts": [
31+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.pypirc,target=/home/vscode/.pypirc,type=bind,consistency=cached"
32+
]
2833
}

scripts/publish_to_pypi.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Script to automate publishing to pypi
3+
# Dave T 2023-12-21
4+
pypi_config_file=~/.pypirc
5+
6+
pip install twine
7+
8+
if [ ! -f dist/*.tar.gz ]; then
9+
echo "No releases found. Please run python3 -m setup.py sdist"
10+
exit
11+
fi
12+
twine check dist/*
13+
14+
echo "Ready to publish."
15+
echo "Default is publishing to testpypi."
16+
read -r -p "If you are fully ready, please publish to pypi by typing 'thisisnotatest'<enter>: " response
17+
echo "response=$response"
18+
if [ "$response" = "thisisnotatest" ]; then
19+
repository=pypi
20+
else
21+
repository=testpypi
22+
fi
23+
24+
if [ -f $pypi_config_file ]; then
25+
echo "Using $pypi_config_file for API keys"
26+
else
27+
echo "$pypi_config_file not found, please paste pypi API token below:"
28+
read twine_api_key
29+
export TWINE_USERNAME=__token__
30+
export TWINE_PASSWORD=$twine_api_key
31+
fi
32+
echo "Publishing to $repository..."
33+
twine upload --repository $repository dist/*
34+
echo "Publishing complete!"
35+
echo
36+
echo "Don't forget to tag this release!"

0 commit comments

Comments
 (0)