Use jinja templating for the release notes

This commit is contained in:
Megan Wilhite 2023-04-04 09:49:23 -06:00 committed by Gareth J. Greenaway
parent eb81faea5b
commit 747db3eb60
2 changed files with 82 additions and 5 deletions

View file

@ -0,0 +1,59 @@
(release-3006.0)=
# Salt 3006.0 release notes - Codename Sulfur
## Onedir packaging
Going forward from the 3006.0 release, the Salt Project will only provide onedir
packages to install or upgrade Salt. The classic, non-onedir packages will not
be provided for supported operating systems. See [Upgrade to onedir](https://docs.saltproject.io/salt/install-guide/en/latest/topics/upgrade-to-onedir.html)
in the [Salt Install Guide](https://docs.saltproject.io/salt/install-guide/en/latest) for information about upgrading from the classic packages to the onedir
packages.
## Dropping support for Python 3.5 and 3.6
Python 3.5 and 3.6 will no longer be supported by Salt since they
are end of life. Going forward our policy will be to align with Python's
supported versions. See [Salt support for Python versions](https://docs.saltproject.io/salt/install-guide/en/latest/topics/salt-python-version-support.html)
for more information.
## All salt-api functionality disabled by default
All netapi clients, which provide the functionality to ``salt-api``, will now
be disabled by default as a security precaution. If you use ``salt-api``, you
must add the new ``netapi_enable_clients`` option to your salt master config.
This is a breaking change and the ``salt-api`` will not function without this
new configuration option. See [Enabling netapi client interfaces](https://docs.saltproject.io/en/3006.0/topics/netapi/netapi-enable-clients.html#netapi-enable-clients)
for more information.
## How do I migrate to the onedir packages?
The migration path from the classic, non-onedir packages to the onedir packages
will include:
* Repo File: You need to update your repo file to point to the new repo paths
for your platform. After the repo file is updated, upgrade your Salt packages.
* Pip packages: You need to ensure any 3rd party pip packages are installed in
the correct onedir path. This can be accomplished in two ways:
* ``salt-pip install <package name>``
* Using the ``pip.installed`` Salt state.
To install python packages into the system python environment, user's must now
provide the ``pip_bin`` or ``bin_env`` to the pip state module.
For example:
```yaml
lib-foo:
pip.installed:
- pip_bin: /usr/bin/pip3
lib-bar:
pip.installed:
- bin_env: /usr/bin/python3
```
## Changelog
{{ changelog }}

View file

@ -12,6 +12,7 @@ import re
import sys
import textwrap
from jinja2 import Environment, FileSystemLoader
from ptscripts import Context, command_group
from tools.utils import REPO_ROOT, Version
@ -309,17 +310,26 @@ def update_release_notes(
versions = {}
for fpath in pathlib.Path("doc/topics/releases").glob("*.md"):
versions[(Version(fpath.stem))] = fpath
release_notes_path = versions[sorted(versions)[-1]]
latest_version = sorted(versions)[-1]
release_notes_path = versions[latest_version]
version = ".".join(str(part) for part in latest_version.release)
else:
version = ".".join(str(part) for part in salt_version.release)
release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format(
".".join(str(part) for part in salt_version.release)
version
)
if not release_notes_path.exists():
release_notes_path.write_text(
template_release_path = (
release_notes_path.parent / "templates" / f"{version}.md.template"
)
if not template_release_path.exists():
template_release_path.write_text(
textwrap.dedent(
f"""\
(release-{salt_version})=
# Salt {salt_version} release notes - UNRELEASED
## Changelog
{{{{ changelog }}}}
"""
)
)
@ -334,7 +344,15 @@ def update_release_notes(
tmp_release_notes_path = (
release_notes_path.parent / f"{release_notes_path.name}.tmp"
)
tmp_release_notes_path.write_text(f"{existing}\n## Changelog\n{changes}")
# render the release notes jinja template
environment = Environment(loader=FileSystemLoader(template_release_path.parent))
template = environment.get_template(template_release_path.name)
content = template.render(
{"changelog": changes},
)
tmp_release_notes_path.write_text(content)
try:
contents = tmp_release_notes_path.read_text().strip()
if draft: