Skip to content

Commit 9a81ef9

Browse files
committed
ci: include release notes on release page
1 parent 9ea7fdb commit 9a81ef9

File tree

4 files changed

+103
-2
lines changed

4 files changed

+103
-2
lines changed

.github/common/body.md.jinja

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
MODFLOW 6 development build, {{ date }}.
2+
3+
{% for section_key, section_items in items|groupby("section") %}
4+
{% set section = sections[section_key]|title %}
5+
## {{ section }}
6+
7+
{% for subsection_key, subsection_items in section_items|groupby("subsection") %}
8+
{% set subsection = subsections[subsection_key]|title %}
9+
{% if subsection|length > 0 %}
10+
### {{ subsection }}
11+
{% endif %}
12+
13+
{% for item in subsection_items %}
14+
- {{ item.description }}
15+
{% endfor %}
16+
17+
{% endfor %}
18+
{% endfor %}

.github/common/make_body.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This script converts the release notes TOML file
2+
# to markdown, which is added to the release page.
3+
import argparse
4+
import datetime
5+
import sys
6+
from pathlib import Path
7+
from warnings import warn
8+
9+
DATE = datetime.date.today().strftime("%b %d, %Y")
10+
TEMPLATE_PATH = Path(__file__).parent / "body.md.jinja"
11+
12+
13+
if __name__ == "__main__":
14+
parser = argparse.ArgumentParser()
15+
parser.add_argument("toml_path")
16+
parser.add_argument("md_path")
17+
args = parser.parse_args()
18+
toml_path = Path(args.toml_path).expanduser().absolute()
19+
md_path = Path(args.md_path).expanduser().absolute()
20+
if not toml_path.is_file():
21+
warn(f"Release notes TOML file not found: {toml_path}")
22+
sys.exit(0)
23+
24+
md_path.unlink(missing_ok=True)
25+
26+
import tomli
27+
from jinja2 import Environment, FileSystemLoader
28+
29+
loader = FileSystemLoader(Path(__file__).parent)
30+
env = Environment(
31+
loader=loader,
32+
trim_blocks=True,
33+
lstrip_blocks=True,
34+
line_statement_prefix="_",
35+
keep_trailing_newline=True,
36+
)
37+
template = env.get_template(TEMPLATE_PATH.name)
38+
with open(md_path, "w") as md_file:
39+
with open(toml_path, "rb") as toml_file:
40+
content = tomli.load(toml_file)
41+
sections = content.get("sections", [])
42+
subsections = content.get("subsections", [])
43+
items = content.get("items", [])
44+
# make sure each item has a subsection entry even if empty
45+
for item in items:
46+
if not item.get("subsection"):
47+
item["subsection"] = ""
48+
if not any(items):
49+
warn("No release notes found, aborting")
50+
sys.exit(0)
51+
md_file.write(
52+
template.render(
53+
sections=sections,
54+
subsections=subsections,
55+
items=items,
56+
date=DATE,
57+
)
58+
)

.github/workflows/nightly-build.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,25 @@ jobs:
9595
if: github.event_name != 'pull_request'
9696
steps:
9797

98+
- name: Checkout repo
99+
uses: actions/checkout@v4
100+
with:
101+
repository: MODFLOW-ORG/modflow6-nightly-build
102+
103+
- name: Checkout modflow6
104+
uses: actions/checkout@v4
105+
with:
106+
repository: MODFLOW-ORG/modflow6
107+
path: modflow6
108+
109+
- name: Setup Python
110+
uses: actions/setup-python@v5
111+
with:
112+
python-version: 3.9
113+
114+
- name: Install Python packages
115+
run: pip install -r requirements.txt
116+
98117
- name: Delete Older Releases
99118
uses: dev-drprasad/delete-older-releases@v0.3.4
100119
with:
@@ -138,12 +157,16 @@ jobs:
138157
F_TIME: "${{ steps.current-time.outputs.formattedTime }}"
139158
run: echo $TIME $F_TIME
140159

160+
- name: Make body
161+
id: make-body
162+
run: python .github/common/make_body.py modflow6/doc/ReleaseNotes/develop.toml body.md
163+
141164
- name: Create release
142165
uses: ncipollo/release-action@v1
143166
with:
144167
tag: ${{ steps.current-time.outputs.formattedTime }}
145168
name: ${{ steps.current-time.outputs.formattedTime }} development build
146-
body: "MODFLOW 6 development build."
169+
bodyFile: body.md
147170
draft: false
148171
allowUpdates: true
149172
token: ${{ secrets.GITHUB_TOKEN }}

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ https://github.com/MODFLOW-ORG/modflow-devtools/archive/develop.zip
33
flopy[test, optional]
44
meson!=0.63.0
55
mfpymake
6-
ninja
6+
ninja
7+
tomli
8+
Jinja2

0 commit comments

Comments
 (0)