Make the release action upload to real PyPI (#70)

* Run `build` and `twine check` in regular CI

Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
This commit is contained in:
David Robertson 2021-12-01 17:28:02 +00:00 committed by GitHub
parent acd45b4aec
commit f821cff55e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 11 deletions

View file

@ -30,6 +30,29 @@ jobs:
- name: "Run tox lint targets for ${{ matrix.python-version }}" - name: "Run tox lint targets for ${{ matrix.python-version }}"
run: "python -m tox -e check_isort,pep8,packaging" run: "python -m tox -e check_isort,pep8,packaging"
build:
# This is similar to the job in `release.yml`, but it does NOT upload to PyPI.
# We include it here to reduce the likelihood of someone publishing a release
# which doesn't build.
name: "Build and check Python package"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "3.6"
- name: "Install packaging tools"
run: "python -m pip install --upgrade build twine"
- name: "Build dist package"
run: "python -m build"
- name: "Run twine checks"
run: "python -m twine check dist/*"
tests: tests:
needs: lint needs: lint
name: "Python ${{ matrix.python-version }}" name: "Python ${{ matrix.python-version }}"
@ -55,3 +78,4 @@ jobs:
python -m pip install --upgrade tox python -m pip install --upgrade tox
- name: "Run tox targets for ${{ matrix.python-version }}" - name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox -e py" run: "python -m tox -e py"

View file

@ -20,7 +20,7 @@ jobs:
run: "python -m build" run: "python -m build"
- name: "Upload to PyPI" - name: "Upload to PyPI"
run: "python -m twine upload --repository testpypi dist/*" run: "python -m twine upload dist/*"
env: env:
TWINE_USERNAME: "__token__" TWINE_USERNAME: "__token__"
TWINE_PASSWORD: "${{ secrets.TESTPYPI_API_TOKEN }}" TWINE_PASSWORD: "${{ secrets.PYPI_API_TOKEN }}"

View file

@ -77,16 +77,12 @@ Updated 0 as deleted
# prepare to wait a long time # prepare to wait a long time
``` ```
Packaging Packaging and release
--------- ---------
For maintainers: For maintainers:
1. Update the `__version__` in setup.py. 1. Update the `__version__` in setup.py. Commit. Push.
2. Build, check and upload to PyPI as follows: 2. Create a release on GitHub for this version.
3. When published, a [GitHub action workflow](https://github.com/matrix-org/synapse-s3-storage-provider/actions/workflows/release.yml) will build the package and upload to [PyPI](https://pypi.org/project/synapse-s3-storage-provider/).
```shell
python -m build
twine check dist/*
twine upload dist/*
```

View file

@ -1,6 +1,6 @@
from setuptools import setup from setuptools import setup
__version__ = "1.1.1-test" __version__ = "1.1" # Bump to a 3-part semver for next version, i.e. 1.1.1
with open("README.md") as f: with open("README.md") as f:
long_description = f.read() long_description = f.read()