| name: publish |
| on: |
| # on pull request, run build step to catch errors earlier, but do not publish |
| pull_request: |
| # on push to master without a version tag, publish to test PyPI registry |
| # ... with version tag, publish to production PyPI registry. |
| push: |
| branches: [master] |
| tags: ["v[0-9]*"] |
| jobs: |
| build: |
| # https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5 |
| if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }} |
| runs-on: ubuntu-latest |
| timeout-minutes: 5 |
| |
| steps: |
| - uses: actions/checkout@v3 |
| |
| - name: cache pip |
| uses: actions/cache@v4 |
| with: |
| path: ~/.cache/pip |
| key: ${{ runner.os }}-pip-publish |
| restore-keys: | |
| ${{ runner.os }}-pip- |
| ${{ runner.os }}- |
| |
| - name: setup python |
| uses: actions/setup-python@v3 |
| with: |
| python-version: 3.x |
| - name: install tools |
| run: pip install --upgrade build check-manifest setuptools twine wheel |
| |
| - name: build package |
| run: python -m build |
| - name: check manifest |
| run: check-manifest |
| - name: twine check |
| run: twine check dist/* |
| - name: script/test install_check_version |
| run: stages=check_version script/test |
| |
| - uses: actions/upload-artifact@v4 |
| with: |
| name: dist |
| path: dist/ |
| if-no-files-found: error |
| retention-days: 1 |
| |
| publish-prod: |
| if: ${{ github.event_name == 'push' && github.repository == 'httplib2/httplib2' && startsWith(github.ref, 'refs/tags/') }} |
| needs: [build] |
| environment: |
| name: pypi-public |
| url: https://pypi.org/p/httplib2 |
| permissions: |
| id-token: write # for trusted publishing |
| runs-on: ubuntu-latest |
| timeout-minutes: 5 |
| |
| steps: |
| - uses: actions/download-artifact@v4 |
| with: |
| name: dist |
| path: dist/ |
| |
| - name: publish to public PyPI |
| if: startsWith(github.ref, 'refs/tags/') |
| uses: pypa/gh-action-pypi-publish@release/v1 |
| with: |
| packages-dir: dist/ |
| |
| publish-test: |
| if: ${{ github.event_name == 'push' && github.repository == 'httplib2/httplib2' && github.ref == 'refs/heads/master' }} |
| needs: [build] |
| environment: |
| name: pypi-test |
| url: https://test.pypi.org/p/httplib2 |
| permissions: |
| id-token: write # for trusted publishing |
| runs-on: ubuntu-latest |
| timeout-minutes: 5 |
| |
| steps: |
| - uses: actions/download-artifact@v4 |
| with: |
| name: dist |
| path: dist/ |
| |
| - name: publish to test.PyPI |
| uses: pypa/gh-action-pypi-publish@release/v1 |
| with: |
| packages-dir: dist/ |
| repository-url: https://test.pypi.org/legacy/ |