Skip to content

Commit 2f7c6d5

Browse files
committed
ci: generate github release notes separately from creating github release
Since creating the github release is security sensitive, better to isolate the part of generating the markdown release notes in its own job, such that if e.g. pip/tox/pandoc is compromised it could not in turn compromise the release files.
1 parent d322dae commit 2f7c6d5

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

.github/workflows/deploy.yml

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,47 @@ jobs:
3535
with:
3636
attest-build-provenance-github: 'true'
3737

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@v5
46+
with:
47+
fetch-depth: 0
48+
persist-credentials: false
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v6
52+
with:
53+
python-version: "3.11"
54+
55+
- name: Install tox
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install --upgrade tox
59+
60+
- name: Generate release notes
61+
env:
62+
VERSION: ${{ github.event.inputs.version }}
63+
run: |
64+
sudo apt-get install pandoc
65+
tox -e generate-gh-release-notes -- "$VERSION" gh-release-notes.md
66+
67+
- name: Upload release notes
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: release-notes
71+
path: gh-release-notes.md
72+
retention-days: 1
73+
3874
deploy:
3975
if: github.repository == 'pytest-dev/pytest'
40-
needs: [package]
76+
# Need generate-gh-release-notes only for ordering.
77+
# Don't want to release to PyPI if generating GitHub release notes fails.
78+
needs: [package, generate-gh-release-notes]
4179
runs-on: ubuntu-latest
4280
environment: deploy
4381
timeout-minutes: 30
@@ -69,48 +107,28 @@ jobs:
69107
git tag --annotate --message=v"$VERSION" "$VERSION" ${{ github.sha }}
70108
git push origin "$VERSION"
71109
72-
release-notes:
73-
74-
# todo: generate the content in the build job
75-
# the goal being of using a github action script to push the release data
76-
# after success instead of creating a complete python/tox env
77-
needs: [deploy]
110+
create-github-release:
111+
needs: [generate-gh-release-notes, deploy]
78112
runs-on: ubuntu-latest
79-
timeout-minutes: 30
113+
timeout-minutes: 10
80114
permissions:
81115
contents: write
82116
steps:
83-
- uses: actions/checkout@v5
84-
with:
85-
fetch-depth: 0
86-
persist-credentials: false
87-
88117
- name: Download Package
89118
uses: actions/download-artifact@v6
90119
with:
91120
name: Packages
92121
path: dist
93122

94-
- name: Set up Python
95-
uses: actions/setup-python@v6
123+
- name: Download release notes
124+
uses: actions/download-artifact@v6
96125
with:
97-
python-version: "3.11"
98-
99-
- name: Install tox
100-
run: |
101-
python -m pip install --upgrade pip
102-
pip install --upgrade tox
103-
104-
- name: Generate release notes
105-
env:
106-
VERSION: ${{ github.event.inputs.version }}
107-
run: |
108-
sudo apt-get install pandoc
109-
tox -e generate-gh-release-notes -- "$VERSION" scripts/latest-release-notes.md
126+
name: release-notes
127+
path: .
110128

111129
- name: Publish GitHub Release
112130
env:
113131
VERSION: ${{ github.event.inputs.version }}
114132
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115133
run: |
116-
gh release create --notes-file scripts/latest-release-notes.md --verify-tag "$VERSION" dist/*
134+
gh release create --notes-file gh-release-notes.md --verify-tag "$VERSION" dist/*

0 commit comments

Comments
 (0)