|
| 1 | +name: Publish sdist tarball to PyPi |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['main'] |
| 6 | + tags: ['[0-9]+.[0-9]+.[0-9]+'] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_sdist: |
| 11 | + name: Build source distribution |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + - name: Set up Python 3.12 |
| 16 | + uses: actions/setup-python@v4 |
| 17 | + with: |
| 18 | + python-version: 3.12 |
| 19 | + - name: Build a source tarball |
| 20 | + run: | |
| 21 | + python -m pip install build |
| 22 | + python -m build |
| 23 | + - name: Store sdist as artifact |
| 24 | + uses: actions/upload-artifact@v3 |
| 25 | + with: |
| 26 | + name: dist |
| 27 | + path: dist/*.tar.gz |
| 28 | + |
| 29 | + test_sdist: |
| 30 | + name: Test source distribution |
| 31 | + |
| 32 | + runs-on: ubuntu-latest |
| 33 | + needs: [build_sdist] |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + - name: Set up Python 3.12 |
| 38 | + uses: actions/setup-python@v4 |
| 39 | + with: |
| 40 | + python-version: 3.12 |
| 41 | + - name: Download artifacts produced during the build_wheels and build_sdist jobs |
| 42 | + uses: actions/download-artifact@v3 |
| 43 | + with: |
| 44 | + name: dist |
| 45 | + path: dist/ |
| 46 | + - name: Install package, clean local directory |
| 47 | + run: | |
| 48 | + rm -rf fz_td_recipe/ |
| 49 | + python -m pip install dist/* |
| 50 | + python -m pip install pytest |
| 51 | + - name: Run tests |
| 52 | + run: | |
| 53 | + pytest tests |
| 54 | +
|
| 55 | + publish: |
| 56 | + name: Publish package to PyPI |
| 57 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 58 | + |
| 59 | + runs-on: ubuntu-latest |
| 60 | + needs: [build_sdist, test_sdist] |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Download artifacts produced by the build_sdist job |
| 64 | + uses: actions/download-artifact@v3 |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist/ |
| 68 | + - name: Display structure of downloaded files |
| 69 | + run: ls -R |
| 70 | + working-directory: dist |
| 71 | + - name: Publish source distribution package to PyPI |
| 72 | + uses: pypa/gh-action-pypi-publish@master |
| 73 | + with: |
| 74 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 75 | + packages_dir: dist/ |
0 commit comments