Publish to PyPi #71
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPi | |
| # Builds the package, checks wheel structure, publishes to TestPyPI, runs smoke | |
| # tests against TestPyPI, then publishes to real PyPI only if all prior steps pass. | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| jobs: | |
| build: | |
| name: Build and check wheel | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Build dist files | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e .[test] build | |
| python -m build | |
| git describe --tag --dirty --always | |
| - name: Check wheel structure | |
| run: python -m pytest test/test_packaging.py -m packaging -v | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| publish-test-pypi: | |
| name: Publish to Test PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to Test PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2 | |
| with: | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| repository_url: https://test.pypi.org/legacy/ | |
| skip_existing: true | |
| smoke-test-pypi: | |
| name: Smoke test from Test PyPI | |
| needs: publish-test-pypi | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.x'] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install from Test PyPI | |
| run: | | |
| pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ tableauserverclient | |
| - name: Smoke test | |
| run: | | |
| python -c "import tableauserverclient as TSC; server = TSC.Server('http://example.com', use_server_version=False)" | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: smoke-test-pypi | |
| if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |