Skip to content

Commit

Permalink
Added support for development releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Jul 18, 2024
1 parent 8d71e2d commit 6116168
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 20 deletions.
4 changes: 4 additions & 0 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ Once installed, VUnit may be updated to new versions via a similar method:
> pip install -U vunit_hdl
Occasionally, pre-releases and development versions are available via `pip <https://pip.pypa.io/en/stable/>`__.
These give early access to updates before the next planned release has been fully completed. These are installed
by adding the ``--pre`` option to the ``pip install`` command.

.. _installing_master:

Using the Development Version
Expand Down
87 changes: 68 additions & 19 deletions tools/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"""
Create and validates new tagged release commits
The release process is described in the Contributing section of the web page
Note that the releases are tagged using Semantic Versioning which differs from
Python module versioning when creating pre-releases.
"""

import argparse
Expand All @@ -27,22 +29,49 @@ def main():
args = parse_args()

if args.cmd == "create":
version = args.version[0]
major, minor, patch = parse_version(version)

print(f"Attempting to create new release {version!s}")
set_version(version)
validate_new_release(version, pre_tag=True)
make_release_commit(version)

new_version = f"{major:d}.{minor:d}.{patch + 1:d}-dev"
set_version(new_version)
make_next_pre_release_commit(new_version)
major, minor, patch, development = parse_version(args.version[0])
create_release(major, minor, patch, development)

elif args.cmd == "validate":
version = get_local_version()
validate_new_release(version, pre_tag=False)
print(f"Release {version!s} is validated for publishing")
print(f"Release {version} is validated for publishing")

elif args.cmd == "development":
major, minor, patch, development = parse_version(get_local_version())
create_release(major, minor, patch, development)


def to_python_version(major, minor, patch, development):
version = f"{major}.{minor}.{patch}"
if development:
version += f".dev{development}"

return version


def to_semver_version(major, minor, patch, development):
version = f"{major}.{minor}.{patch}"
if development:
version += f"-dev.{development}"

return version


def create_release(major, minor, patch, development):
version = to_python_version(major, minor, patch, development)

print(f"Attempting to create new release {version}")
set_version(version)
validate_new_release(version, pre_tag=True)
make_release_commit(major, minor, patch, development)

if development:
new_version = to_python_version(major, minor, patch, development + 1)
else:
new_version = to_python_version(major, minor, patch + 1, 1)
set_version(new_version)
make_next_pre_release_commit(new_version)


def parse_args():
Expand All @@ -60,17 +89,27 @@ def parse_args():
validate = subparsers.add_parser("validate")
validate.set_defaults(cmd="validate")

development = subparsers.add_parser("development")
development.set_defaults(cmd="development")

return parser.parse_args()


def make_release_commit(version):
def make_release_commit(major, minor, patch, development):
"""
Add release notes and make the release commit
Add release notes and make the release commit.
Tags are named according to Semantic Versioning which means that
a development version X.Y.Z.devN is tagged vX.Y.Z-dev.N
"""
run(["git", "add", str(release_note_file_name(version))])
python_version = to_python_version(major, minor, patch, development)

run(["git", "add", str(release_note_file_name(python_version))])
run(["git", "add", str(ABOUT_PY)])
run(["git", "commit", "-m", f"Release {version!s}"])
run(["git", "tag", f"v{version!s}", "-a", "-m", f"release {version!s}"])
run(["git", "commit", "-m", f"Release {python_version}"])

semver_version = to_semver_version(major, minor, patch, development)
run(["git", "tag", f"v{semver_version}", "-a", "-m", f"Release {python_version}"])


def make_next_pre_release_commit(version):
Expand Down Expand Up @@ -114,9 +153,19 @@ def validate_new_release(version, pre_tag):

def parse_version(version_str):
"""
Create a 3-element tuple with the major,minor,patch version
Create a 4-element tuple with the major,minor,patch, development version
"""
return tuple((int(elem) for elem in version_str.split(".")))
elements = version_str.split(".")
version = [int(elem) for elem in elements[0:3]]
if len(elements) == 4:
assert elements[3].startswith("dev")
development_version = int(elements[3][3:])
assert development_version > 0
version += [development_version]
else:
version += [None]

return tuple(version)


def set_version(version):
Expand Down
2 changes: 1 addition & 1 deletion vunit/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ def version():
return VERSION


VERSION = "5.0.0-dev"
VERSION = "5.0.0.dev1"

0 comments on commit 6116168

Please sign in to comment.