|
1 | 1 | name: Publish to PyPi |
2 | 2 |
|
3 | | -# This will build a package with a version set by versioneer from the most recent tag matching v____ |
4 | | -# It will publish to TestPyPi, and to real Pypi *if* run on master where head has a release tag |
5 | | -# For a live run, this should only need to be triggered by a newly published repo release. |
6 | | -# This can also be run manually for testing |
| 3 | +# Builds the package, checks wheel structure, publishes to TestPyPI, runs smoke |
| 4 | +# tests against TestPyPI, then publishes to real PyPI only if all prior steps pass. |
7 | 5 | on: |
8 | 6 | release: |
9 | 7 | types: [published] |
|
13 | 11 | - 'v*.*.*' |
14 | 12 |
|
15 | 13 | jobs: |
16 | | - build-n-publish: |
17 | | - name: Build dist files for PyPi |
| 14 | + build: |
| 15 | + name: Build and check wheel |
18 | 16 | runs-on: ubuntu-latest |
19 | 17 | steps: |
20 | 18 | - uses: actions/checkout@v4 |
21 | 19 | with: |
22 | 20 | fetch-depth: 0 |
23 | 21 | - uses: actions/setup-python@v5 |
24 | 22 | with: |
25 | | - python-version: 3.13 |
| 23 | + python-version: '3.13' |
26 | 24 | - name: Build dist files |
27 | 25 | run: | |
28 | 26 | python -m pip install --upgrade pip |
29 | 27 | python -m pip install -e .[test] build |
30 | 28 | python -m build |
31 | 29 | git describe --tag --dirty --always |
32 | | - |
33 | | - - name: Publish distribution 📦 to Test PyPI # always run |
| 30 | + - name: Check wheel structure |
| 31 | + run: python -m pytest test/test_packaging.py -m packaging -v |
| 32 | + - uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: dist |
| 35 | + path: dist/ |
| 36 | + |
| 37 | + publish-test-pypi: |
| 38 | + name: Publish to Test PyPI |
| 39 | + needs: build |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/download-artifact@v4 |
| 43 | + with: |
| 44 | + name: dist |
| 45 | + path: dist/ |
| 46 | + - name: Publish to Test PyPI |
34 | 47 | uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2 |
35 | 48 | with: |
36 | 49 | password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
37 | 50 | repository_url: https://test.pypi.org/legacy/ |
38 | | - |
39 | | - - name: Publish distribution 📦 to PyPI |
40 | | - if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} |
| 51 | + skip_existing: true |
| 52 | + |
| 53 | + smoke-test-pypi: |
| 54 | + name: Smoke test from Test PyPI |
| 55 | + needs: publish-test-pypi |
| 56 | + strategy: |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 60 | + python-version: ['3.x'] |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + steps: |
| 63 | + - uses: actions/setup-python@v5 |
| 64 | + with: |
| 65 | + python-version: ${{ matrix.python-version }} |
| 66 | + - name: Install from Test PyPI |
| 67 | + run: | |
| 68 | + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ tableauserverclient |
| 69 | + - name: Smoke test |
| 70 | + run: | |
| 71 | + python -c "import tableauserverclient as TSC; server = TSC.Server('http://example.com', use_server_version=False)" |
| 72 | +
|
| 73 | + publish-pypi: |
| 74 | + name: Publish to PyPI |
| 75 | + needs: smoke-test-pypi |
| 76 | + if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: dist |
| 82 | + path: dist/ |
| 83 | + - name: Publish to PyPI |
41 | 84 | uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2 |
42 | 85 | with: |
43 | 86 | password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments