| name: deploy | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version' | |
| required: true | |
| default: '1.2.3' | |
| # Set permissions at the job level. | |
| permissions: {} | |
| jobs: | |
| package: | |
| runs-on: ubuntu-latest | |
| env: | |
| SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST: ${{ github.event.inputs.version }} | |
| timeout-minutes: 10 | |
| # Required by attest-build-provenance-github. | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Build and Check Package | |
| uses: hynek/build-and-inspect-python-package@67230f7b8410ae0052b39c1efc89d89fff43ff10 # v3.0.2 | |
| with: | |
| attest-build-provenance-github: 'true' | |
| generate-gh-release-notes: | |
| needs: [package] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up tox | |
| uses: $/.github/actions/setup-tox | |
| with: | |
| python-version: "3.13" | |
| - name: Generate release notes | |
| env: | |
| VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| tox -e generate-gh-release-notes -- "$VERSION" gh-release-notes.md | |
| - name: Upload release notes | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: release-notes | |
| path: gh-release-notes.md | |
| retention-days: 1 | |
| publish-to-pypi: | |
| if: github.repository == 'pytest-dev/pytest' | |
| # Need generate-gh-release-notes only for ordering. | |
| # Don't want to release to PyPI if generating GitHub release notes fails. | |
| needs: [package, generate-gh-release-notes] | |
| runs-on: ubuntu-latest | |
| environment: deploy | |
| timeout-minutes: 30 | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download Package | |
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 | |
| with: | |
| attestations: true | |
| push-tag: | |
| needs: [publish-to-pypi] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Push tag | |
| env: | |
| VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| git config user.name "pytest bot" | |
| git config user.email "pytestbot@gmail.com" | |
| git tag --annotate --message=v"$VERSION" "$VERSION" ${{ github.sha }} | |
| git push origin "$VERSION" | |
| create-github-release: | |
| needs: [push-tag, generate-gh-release-notes] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download Package | |
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Download release notes | |
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| name: release-notes | |
| path: . | |
| - name: Publish GitHub Release | |
| env: | |
| VERSION: ${{ github.event.inputs.version }} | |
| GH_REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create --notes-file gh-release-notes.md --verify-tag "$VERSION" dist/* |