| 1 |
name: deploy |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
inputs: |
| 6 |
version: |
| 7 |
description: 'Release version' |
| 8 |
required: true |
| 9 |
default: '1.2.3' |
| 10 |
|
| 11 |
|
| 12 |
# Set permissions at the job level. |
| 13 |
permissions: {} |
| 14 |
|
| 15 |
jobs: |
| 16 |
package: |
| 17 |
runs-on: ubuntu-latest |
| 18 |
env: |
| 19 |
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }} |
| 20 |
timeout-minutes: 10 |
| 21 |
|
| 22 |
# Required by attest-build-provenance-github. |
| 23 |
permissions: |
| 24 |
id-token: write |
| 25 |
attestations: write |
| 26 |
|
| 27 |
steps: |
| 28 |
- uses: actions/checkout@v4 |
| 29 |
with: |
| 30 |
fetch-depth: 0 |
| 31 |
persist-credentials: false |
| 32 |
|
| 33 |
- name: Build and Check Package |
| 34 |
uses: hynek/[email protected] |
| 35 |
with: |
| 36 |
attest-build-provenance-github: 'true' |
| 37 |
|
| 38 |
deploy: |
| 39 |
if: github.repository == 'pytest-dev/pytest' |
| 40 |
needs: [package] |
| 41 |
runs-on: ubuntu-latest |
| 42 |
environment: deploy |
| 43 |
timeout-minutes: 30 |
| 44 |
permissions: |
| 45 |
id-token: write |
| 46 |
contents: write |
| 47 |
steps: |
| 48 |
- uses: actions/checkout@v4 |
| 49 |
|
| 50 |
- name: Download Package |
| 51 |
uses: actions/download-artifact@v4 |
| 52 |
with: |
| 53 |
name: Packages |
| 54 |
path: dist |
| 55 |
|
| 56 |
- name: Publish package to PyPI |
| 57 |
uses: pypa/[email protected] |
| 58 |
|
| 59 |
- name: Push tag |
| 60 |
run: | |
| 61 |
git config user.name "pytest bot" |
| 62 |
git config user.email "[email protected]" |
| 63 |
git tag --annotate --message=v${{ github.event.inputs.version }} ${{ github.event.inputs.version }} ${{ github.sha }} |
| 64 |
git push origin ${{ github.event.inputs.version }} |
| 65 |
|
| 66 |
release-notes: |
| 67 |
|
| 68 |
# todo: generate the content in the build job |
| 69 |
# the goal being of using a github action script to push the release data |
| 70 |
# after success instead of creating a complete python/tox env |
| 71 |
needs: [deploy] |
| 72 |
runs-on: ubuntu-latest |
| 73 |
timeout-minutes: 30 |
| 74 |
permissions: |
| 75 |
contents: write |
| 76 |
steps: |
| 77 |
- uses: actions/checkout@v4 |
| 78 |
with: |
| 79 |
fetch-depth: 0 |
| 80 |
persist-credentials: false |
| 81 |
|
| 82 |
- name: Download Package |
| 83 |
uses: actions/download-artifact@v4 |
| 84 |
with: |
| 85 |
name: Packages |
| 86 |
path: dist |
| 87 |
|
| 88 |
- name: Set up Python |
| 89 |
uses: actions/setup-python@v5 |
| 90 |
with: |
| 91 |
python-version: "3.11" |
| 92 |
|
| 93 |
- name: Install tox |
| 94 |
run: | |
| 95 |
python -m pip install --upgrade pip |
| 96 |
pip install --upgrade tox |
| 97 |
|
| 98 |
- name: Generate release notes |
| 99 |
run: | |
| 100 |
sudo apt-get install pandoc |
| 101 |
tox -e generate-gh-release-notes -- ${{ github.event.inputs.version }} scripts/latest-release-notes.md |
| 102 |
|
| 103 |
- name: Publish GitHub Release |
| 104 |
uses: softprops/action-gh-release@v2 |
| 105 |
with: |
| 106 |
body_path: scripts/latest-release-notes.md |
| 107 |
files: dist/* |
| 108 |
tag_name: ${{ github.event.inputs.version }} |