| 1 | |
| 2 | name: Publish to PyPI |
| 3 | |
| 4 | on: |
| 5 | pull_request: |
| 6 | push: |
| 7 | branches: |
| 8 | - main |
| 9 | release: |
| 10 | types: |
| 11 | - published |
| 12 | |
| 13 | defaults: |
| 14 | run: |
| 15 | shell: bash |
| 16 | |
| 17 | jobs: |
| 18 | packages: |
| 19 | runs-on: ubuntu-latest |
| 20 | steps: |
| 21 | - uses: actions/checkout@v3 |
| 22 | |
| 23 | - name: Set up Python |
| 24 | uses: actions/setup-python@v4 |
| 25 | with: |
| 26 | python-version: "3.x" |
| 27 | |
| 28 | - name: Get tags |
| 29 | run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 30 | |
| 31 | - name: Install build tools |
| 32 | run: | |
| 33 | python -m pip install --upgrade pip build wheel twine check-manifest |
| 34 | |
| 35 | - name: Build binary wheel |
| 36 | run: python -m build --sdist --wheel . --outdir dist |
| 37 | |
| 38 | - name: CheckFiles |
| 39 | run: | |
| 40 | check-manifest --verbose |
| 41 | ls dist |
| 42 | |
| 43 | - name: Test wheels |
| 44 | run: | |
| 45 | cd dist && python -m pip install branca*.whl |
| 46 | python -m twine check * |
| 47 | |
| 48 | - name: Publish a Python distribution to PyPI |
| 49 | if: success() && github.event_name == 'release' |
| 50 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 51 | with: |
| 52 | user: __token__ |
| 53 | password: ${{ secrets.PYPI_PASSWORD }} |