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 Python π distribution π¦ to PyPI and TestPyPI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| types: [opened, reopened] | |
| jobs: | |
| build: | |
| name: Build distribution π¦ | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Install pypa/build | |
| run: >- | |
| python3 -m pip install build --user | |
| - name: Build a binary wheel and a source tarball | |
| run: python3 -m build | |
| working-directory: pyjsonparser | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| test: | |
| name: Test distribution π¦ | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Install dependencies | |
| run: pip install pytest | |
| working-directory: pyjsonparser | |
| - name: Run tests | |
| run: pytest | |
| working-directory: pyjsonparser | |
| publish-to-pypi: | |
| name: Publish Python π distribution π¦ to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: | |
| - build | |
| - test | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pyjsonparser | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution π¦ to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| publish-to-testpypi: | |
| name: Publish Python π distribution π¦ to TestPyPI | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| needs: | |
| - build | |
| - test | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/pyjsonparser | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution π¦ to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ |