openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
.github/workflows/publish-pypi.yml
59lines · modecode
| 1 | # workflow for re-running publishing to PyPI in case it fails for some reason |
| 2 | # you can run this workflow by navigating to https://www.github.com/openai/openai-python/actions/workflows/publish-pypi.yml |
| 3 | name: Publish PyPI |
| 4 | on: |
| 5 | workflow_dispatch: |
| 6 | |
| 7 | jobs: |
| 8 | build: |
| 9 | name: build |
| 10 | if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-python' |
| 11 | runs-on: ubuntu-latest |
| 12 | # Build distributions without OIDC access so package build code cannot mint |
| 13 | # a PyPI publishing token. The publish job handles only the upload. |
| 14 | permissions: |
| 15 | contents: read |
| 16 | |
| 17 | steps: |
| 18 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 19 | |
| 20 | - name: Set up Rye |
| 21 | uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8 |
| 22 | with: |
| 23 | version: '0.44.0' |
| 24 | enable-cache: true |
| 25 | |
| 26 | - name: Build package |
| 27 | run: | |
| 28 | mkdir -p dist |
| 29 | rye build --clean |
| 30 | |
| 31 | - name: Upload package distributions |
| 32 | uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 33 | with: |
| 34 | name: python-package-distributions |
| 35 | path: dist/ |
| 36 | if-no-files-found: error |
| 37 | retention-days: 1 |
| 38 | |
| 39 | publish: |
| 40 | name: publish |
| 41 | needs: build |
| 42 | if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-python' |
| 43 | runs-on: ubuntu-latest |
| 44 | environment: publish |
| 45 | # PyPI Trusted Publishing requires id-token: write. Keep it scoped to this |
| 46 | # minimal upload-only job rather than the build job. |
| 47 | permissions: |
| 48 | contents: read |
| 49 | id-token: write |
| 50 | |
| 51 | steps: |
| 52 | - name: Download package distributions |
| 53 | uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 54 | with: |
| 55 | name: python-package-distributions |
| 56 | path: dist/ |
| 57 | |
| 58 | - name: Publish to PyPI |
| 59 | uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 60 | |