Skip to content

Commit d2c8708

Browse files
committed
Autogenerate Markdown file with release checklist links
GitHub removed the feature allowing Markdown issue templates without front matter to be used in the `template` query argument. Adding front matter would cause the template to appear in the user-facing issue template chooser, degrading the issue UX a bit. However, we can still autofill the issue body by including it inline in the `body` query argument. Move maintainer templates to a separate directory and autogenerate a README.md that embeds them. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 51e28fa commit d2c8708

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

.github/maintainer/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- Generated by mkmaintainer.py; do not edit -->
2+
3+
## Maintainer issue templates
4+
5+
- [Release checklist](https://github.com/openslide/openslide-python/issues/new?title=Release+X.Y.Z&body=%23+OpenSlide+Python+release+process%0A%0A-+%5B+%5D+Update+%60CHANGELOG.md%60+and+version+in+%60openslide%2F_version.py%60%0A-+%5B+%5D+Create+and+push+signed+tag%0A-+%5B+%5D+Find+the+%5Bworkflow+run%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Factions%2Fworkflows%2Fpython.yml%29+for+the+tag%0A++-+%5B+%5D+Once+the+build+finishes%2C+approve+deployment+to+PyPI%0A++-+%5B+%5D+Download+the+docs+artifact%0A-+%5B+%5D+Verify+that+the+workflow+created+a+%5BPyPI+release%5D%28https%3A%2F%2Fpypi.org%2Fp%2Fopenslide-python%29+with+a+description%2C+source+tarball%2C+and+wheels%0A-+%5B+%5D+Verify+that+the+workflow+created+a+%5BGitHub+release%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Freleases%29+with+release+notes%2C+source+tarballs%2C+and+wheels%0A-+%5B+%5D+%60cd%60+into+website+checkout%3B+%60rm+-r+api%2Fpython+%26%26+unzip+%2Fpath%2Fto%2Fdownloaded%2Fopenslide-python-docs.zip+%26%26+mv+openslide-python-docs-%2A+api%2Fpython%60%0A-+%5B+%5D+Update+website%3A+%60_data%2Freleases.yaml%60%2C+%60_includes%2Fnews.md%60%0A-+%5B+%5D+Start+a+%5BCI+build%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide.github.io%2Factions%2Fworkflows%2Fretile.yml%29+of+the+demo+site%0A-+%5B+%5D+Update+Ubuntu+PPA%0A-+%5B+%5D+Update+Fedora+and+possibly+EPEL+packages%0A-+%5B+%5D+Check+that+%5BCopr+package%5D%28https%3A%2F%2Fcopr.fedorainfracloud.org%2Fcoprs%2Fg%2Fopenslide%2Fopenslide%2Fbuilds%2F%29+built+successfully%0A-+%5B+%5D+Send+mail+to+-announce+and+-users%0A-+%5B+%5D+Post+to+%5Bforum.image.sc%5D%28https%3A%2F%2Fforum.image.sc%2Fc%2Fannouncements%2F10%29%0A-+%5B+%5D+Update+MacPorts+package&labels=release)
6+
- [Update checklist for a Python minor release](https://github.com/openslide/openslide-python/issues/new?title=Add+Python+X.Y&body=%23+Adding+a+new+Python+release%0A%0A-+Update+Git+main%0A++-+%5B+%5D+%60git+checkout+main%60%0A++-+%5B+%5D+In+%60pyproject.toml%60%2C+add+classifier+for+new+Python+version+and+update+%60tool.black.target-version%60%0A++-+%5B+%5D+In+%60.github%2Fworkflows%2Fpython.yml%60%2C+update+hardcoded+Python+versions+and+add+new+version+to+lists%0A++-+%5B+%5D+Commit+and+open+a+PR%0A++-+%5B+%5D+Merge+the+PR+when+CI+passes%0A++-+%5B+%5D+Add+new+Python+jobs+to+%5Bbranch+protection+required+checks%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Fsettings%2Fbranches%29%0A-+%5B+%5D+Update+MacPorts+package%0A-+%5B+%5D+Update+website%3A+Python+3+versions+in+%60download%2Findex.md%60&labels=release)

.github/maintainer/mkmaintainer.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python
2+
3+
from __future__ import annotations
4+
5+
from pathlib import Path
6+
from urllib.parse import urlencode
7+
8+
import yaml
9+
10+
dir = Path(__file__).parent
11+
with open(dir / 'README.md', 'w') as fh:
12+
fh.write('<!-- Generated by mkmaintainer.py; do not edit -->\n\n')
13+
fh.write('## Maintainer issue templates\n\n')
14+
for path in sorted(dir.iterdir()):
15+
if path.name == 'README.md' or path.suffix != '.md':
16+
continue
17+
_, front, body = path.read_text().split('---\n', 2)
18+
info = yaml.safe_load(front)
19+
args = urlencode(
20+
{
21+
'title': info['title'],
22+
'body': body.strip(),
23+
'labels': ','.join(info.get('labels', [])),
24+
}
25+
)
26+
url = f"https://github.com/{info['repo']}/issues/new?{args}"
27+
fh.write(f"- [{info['link-text']}]({url})\n")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
---
2+
link-text: Release checklist
3+
repo: openslide/openslide-python
4+
title: Release X.Y.Z
5+
labels: [release]
6+
---
7+
18
# OpenSlide Python release process
29

310
- [ ] Update `CHANGELOG.md` and version in `openslide/_version.py`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
---
2+
link-text: Update checklist for a Python minor release
3+
repo: openslide/openslide-python
4+
title: Add Python X.Y
5+
labels: [release]
6+
---
7+
18
# Adding a new Python release
29

310
- Update Git main

.pre-commit-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
hooks:
5959
- id: mypy
6060
name: Check Python types
61-
additional_dependencies: [flask, openslide-bin, pillow, types-setuptools]
61+
additional_dependencies: [flask, openslide-bin, pillow, types-PyYAML, types-setuptools]
6262

6363
- repo: https://github.com/rstcheck/rstcheck
6464
rev: v6.2.5
@@ -82,6 +82,13 @@ repos:
8282

8383
- repo: local
8484
hooks:
85+
- id: mkmaintainer
86+
name: Sync maintainer issue templates
87+
entry: .github/maintainer/mkmaintainer.py
88+
files: .github/maintainer/
89+
language: python
90+
additional_dependencies: [PyYAML]
91+
8592
- id: annotations
8693
name: Require "from __future__ import annotations"
8794
language: pygrep

0 commit comments

Comments
 (0)