|
| 1 | +# SPDX-FileCopyrightText: none |
| 2 | +# SPDX-License-Identifier: CC0-1.0 |
| 3 | + |
| 4 | +name: Publish Python distributions to PyPI and TestPyPI |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - master |
| 12 | + tags: |
| 13 | + - 0.* |
| 14 | + - 1.* |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-n-publish: |
| 18 | + name: Build and publish Python distributions to PyPI and TestPyPI |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@master |
| 22 | + |
| 23 | + - name: Get history and tags for SCM versioning to work |
| 24 | + run: | |
| 25 | + git fetch --prune --unshallow |
| 26 | + git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 27 | +
|
| 28 | + - name: Set up Python 3.10 |
| 29 | + uses: actions/setup-python@v3 |
| 30 | + with: |
| 31 | + python-version: "3.10" |
| 32 | + |
| 33 | + - name: Install pypa/build |
| 34 | + run: python -m pip install build twine --user |
| 35 | + |
| 36 | + - name: Build binary wheel and a source tarball |
| 37 | + run: python -m build --sdist --wheel --outdir dist/ . |
| 38 | + |
| 39 | + - name: Check wheels and source tarballs |
| 40 | + run: python -m twine check dist/* |
| 41 | + |
| 42 | +# The project name os blocked by an other test project |
| 43 | +# - name: Publish distribution to Test PyPI |
| 44 | +# if: >- |
| 45 | +# github.event_name == 'push' && |
| 46 | +# github.ref == 'refs/heads/main' |
| 47 | +# uses: pypa/gh-action-pypi-publish@release/v1 |
| 48 | +# with: |
| 49 | +# password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 50 | +# repository_url: https://test.pypi.org/legacy/ |
| 51 | +# skip-existing: true |
| 52 | +# |
| 53 | + - name: Publish distribution to PyPI |
| 54 | + if: >- |
| 55 | + github.event_name == 'push' && |
| 56 | + startsWith(github.ref, 'refs/tags') |
| 57 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 58 | + with: |
| 59 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments