commit 8810b35fc0f5863d98805f730517d058903055d9 Author: JustAnotherArchivist Date: Sat Mar 25 23:29:10 2023 +0000 Initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c3158e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3-alpine +RUN apk add --no-cache git +RUN pip install --no-cache-dir build twine +WORKDIR /src +ENTRYPOINT git clone "$0" . \ + && python3 -m build --outdir /dist \ + && sha256sum /dist/* \ + && read -p 'Upload these files? [y/N] ' upload \ + && [ "${upload}" = y -o "${upload}" = Y ] \ + && TWINE_USERNAME=__token__ twine upload /dist/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..6650329 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +A tiny Docker image to build a Python package and upload it to PyPI. + +Usage: + + docker build -t python-package-build-upload:latest . + docker run -v mypkg-dist:/dist --rm -ti -e TWINE_PASSWORD=token python-package-build-upload:latest https://example.org/mypkg.git + +What it does: + +1. Clones the repo. +2. Runs `python3 -m build --outdir /dist` on it. Mounting a volume to `/dist` is optional but recommended if you'd like to keep the original files. +3. Calculates SHA-256 hashes of the dists. +4. Asks you to verify that they should be uploaded to PyPI. +5. Uploads, if confirmed. + +The `TWINE_PASSWORD` value must be an API token valid for the project. Username/password authentication is not supported.