Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use incremental to canonicalize versions for release #329

Merged
merged 3 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ Step-by-step
- Define the final release version you are preparing.

- towncrier uses `CalVer <https://calver.org/>`_ of the form ``YY.MM.micro`` with the micro version just incrementing.
- Normalize the version according to `PEP 440 <https://www.python.org/dev/peps/pep-0440/#normalization>`_.
- Normalize the version according to `incremental <https://github.com/twisted/incremental/>`_.

- This requires that ``towncrier[dev]`` extra is installed.
- ``venv/bin/python admin/canonicalize_version.py 19.09.00-rc1``
- Outputs ``19.9rc1`` which is the form to be used.
- Outputs ``19.9.0.rc1`` which is the form to be used.

- Create a release branch with a name of the form ``release-19.9`` starting from the ``master`` branch.
- Create a release branch with a name of the form ``release-19.9.0`` starting from the ``master`` branch.

- On the new release branch you will commit all tagged release candidate commits as well as the final tagged release commit.

- Update the version to the release candidate with the first being ``rc1`` (as opposed to 0).

- In ``src/towncrier/_version.py`` the version is set using ``incremental`` such as ``__version__ = Version('towncrier', 19, 9, release_candidate=1)``
- In ``src/towncrier/_version.py`` the version is set using ``incremental`` such as ``__version__ = Version('towncrier', 19, 9, 0, release_candidate=1)``

- Run ``venv/bin/towncrier build --yes`` to build the the newsfragments into the release notes document and to automatically remove the newsfragment files.

Expand All @@ -54,7 +54,7 @@ Step-by-step

- Request a review and address raised concerns until receiving an approval.

- Tag that commit such as ``19.9rc1`` and push the tag to the primary repository.
- Tag that commit such as ``19.9.0.rc1`` and push the tag to the primary repository.

- This will result in another build which will publish to PyPI.
- Confirm the presence of the release on PyPI.
Expand All @@ -73,7 +73,7 @@ Step-by-step

- If ready for a final release, remove the release candidate indicator from the version.

- Edit ``src/towncrier/_version.py`` such as ``__version__ = Version('towncrier', 19, 9)`` to remove the release candidate indication.
- Edit ``src/towncrier/_version.py`` such as ``__version__ = Version('towncrier', 19, 9, 0)`` to remove the release candidate indication.

- Return to the towncrier build step and continue.

Expand Down
23 changes: 20 additions & 3 deletions admin/canonicalize_version.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import click
import incremental
import packaging.utils


@click.command()
@click.argument("version")
def cli(version):
"""Canonicalizes the passed version according to PEP 517."""
canonicalized_version = packaging.utils.canonicalize_version(version)
"""Canonicalizes the passed version according to incremental."""

click.echo(canonicalized_version)
parsed_version = packaging.utils.Version(version)

release_candidate = None
if parsed_version.pre is not None:
if parsed_version.pre[0] == 'rc':
release_candidate = parsed_version.pre[1]

incremental_version = incremental.Version(
package="",
major=parsed_version.major,
minor=parsed_version.minor,
micro=parsed_version.micro,
release_candidate=release_candidate,
post=parsed_version.post,
dev=parsed_version.dev,
)

click.echo(incremental_version.public())


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/329.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@