Debian Codegraph @

.github/workflows/deploy.yml

raw
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_FOR_PYTEST: ${{ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29 with:
30 fetch-depth: 0
31 persist-credentials: false
32
33 - name: Build and Check Package
34 uses: hynek/build-and-inspect-python-package@d44ca7d91762de7a7d5436ddae667c6da6d1c3df
35 with:
36 attest-build-provenance-github: 'true'
37
38 generate-gh-release-notes:
39 needs: [package]
40 runs-on: ubuntu-latest
41 timeout-minutes: 30
42 permissions:
43 contents: read
44 steps:
45 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46 with:
47 fetch-depth: 0
48 persist-credentials: false
49
50 - name: Set up Python
51 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
52 with:
53 python-version: "3.13"
54
55 - name: Install tox
56 run: |
57 python -m pip install --upgrade pip
58 pip install tox
59
60 - name: Generate release notes
61 env:
62 VERSION: ${{ github.event.inputs.version }}
63 run: |
64 tox -e generate-gh-release-notes -- "$VERSION" gh-release-notes.md
65
66 - name: Upload release notes
67 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
68 with:
69 name: release-notes
70 path: gh-release-notes.md
71 retention-days: 1
72
73 publish-to-pypi:
74 if: github.repository == 'pytest-dev/pytest'
75 # Need generate-gh-release-notes only for ordering.
76 # Don't want to release to PyPI if generating GitHub release notes fails.
77 needs: [package, generate-gh-release-notes]
78 runs-on: ubuntu-latest
79 environment: deploy
80 timeout-minutes: 30
81 permissions:
82 id-token: write
83 steps:
84 - name: Download Package
85 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
86 with:
87 name: Packages
88 path: dist
89
90 - name: Publish package to PyPI
91 uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
92 with:
93 attestations: true
94
95 push-tag:
96 needs: [publish-to-pypi]
97 runs-on: ubuntu-latest
98 timeout-minutes: 10
99 permissions:
100 contents: write
101 steps:
102 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
103 with:
104 fetch-depth: 0
105 persist-credentials: true
106
107 - name: Push tag
108 env:
109 VERSION: ${{ github.event.inputs.version }}
110 run: |
111 git config user.name "pytest bot"
112 git config user.email "[email protected]"
113 git tag --annotate --message=v"$VERSION" "$VERSION" ${{ github.sha }}
114 git push origin "$VERSION"
115
116 create-github-release:
117 needs: [push-tag, generate-gh-release-notes]
118 runs-on: ubuntu-latest
119 timeout-minutes: 10
120 permissions:
121 contents: write
122 steps:
123 - name: Download Package
124 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
125 with:
126 name: Packages
127 path: dist
128
129 - name: Download release notes
130 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
131 with:
132 name: release-notes
133 path: .
134
135 - name: Publish GitHub Release
136 env:
137 VERSION: ${{ github.event.inputs.version }}
138 GH_REPO: ${{ github.repository }}
139 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140 run: |
141 gh release create --notes-file gh-release-notes.md --verify-tag "$VERSION" dist/*