openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
.github/workflows/create-releases.yml
78lines · modecode
| 1 | name: Create releases |
| 2 | on: |
| 3 | push: |
| 4 | branches: |
| 5 | - main |
| 6 | |
| 7 | jobs: |
| 8 | release: |
| 9 | name: release |
| 10 | if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-python' |
| 11 | runs-on: ubuntu-latest |
| 12 | environment: publish |
| 13 | outputs: |
| 14 | releases_created: ${{ steps.release.outputs.releases_created }} |
| 15 | permissions: |
| 16 | contents: write |
| 17 | |
| 18 | steps: |
| 19 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 20 | |
| 21 | - uses: stainless-api/trigger-release-please@bb6677c5a04578eec1ccfd9e1913b5b78ed64c61 # v1.4.0 |
| 22 | id: release |
| 23 | with: |
| 24 | repo: ${{ github.event.repository.full_name }} |
| 25 | stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} |
| 26 | |
| 27 | build: |
| 28 | name: build |
| 29 | needs: release |
| 30 | if: ${{ needs.release.outputs.releases_created == 'true' }} |
| 31 | runs-on: ubuntu-latest |
| 32 | # Build distributions without OIDC access so package build code cannot mint |
| 33 | # a PyPI publishing token. The publish job handles only the upload. |
| 34 | permissions: |
| 35 | contents: read |
| 36 | |
| 37 | steps: |
| 38 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 39 | |
| 40 | - name: Set up Rye |
| 41 | uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8 |
| 42 | with: |
| 43 | version: '0.44.0' |
| 44 | enable-cache: true |
| 45 | |
| 46 | - name: Build package |
| 47 | run: | |
| 48 | mkdir -p dist |
| 49 | rye build --clean |
| 50 | |
| 51 | - name: Upload package distributions |
| 52 | uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 53 | with: |
| 54 | name: python-package-distributions |
| 55 | path: dist/ |
| 56 | if-no-files-found: error |
| 57 | retention-days: 1 |
| 58 | |
| 59 | publish: |
| 60 | name: publish |
| 61 | needs: build |
| 62 | runs-on: ubuntu-latest |
| 63 | environment: publish |
| 64 | # PyPI Trusted Publishing requires id-token: write. Keep it scoped to this |
| 65 | # minimal upload-only job rather than the build job. |
| 66 | permissions: |
| 67 | contents: read |
| 68 | id-token: write |
| 69 | |
| 70 | steps: |
| 71 | - name: Download package distributions |
| 72 | uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 73 | with: |
| 74 | name: python-package-distributions |
| 75 | path: dist/ |
| 76 | |
| 77 | - name: Publish to PyPI |
| 78 | uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |