Skip to content

Commit

Permalink
Merge pull request #1854 from apache/tristan/release-versioning
Browse files Browse the repository at this point in the history
Follow semver more strictly
  • Loading branch information
gtristan authored Aug 17, 2023
2 parents d7e22af + 082a629 commit 3da45a5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 77 deletions.
10 changes: 5 additions & 5 deletions .github/compose/ci.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,24 @@ services:
wheels-manylinux_2_28-cp37:
<<: *tests-template
image: quay.io/pypa/manylinux_2_28_x86_64
command: .github/wheel-helpers/test-wheel-manylinux.sh cp37-cp37m-manylinux_2_28_x86_64 /opt/python/cp37-cp37m/bin/python3
command: .github/wheel-helpers/test-wheel-manylinux.sh cp37 /opt/python/cp37-cp37m/bin/python3

wheels-manylinux_2_28-cp38:
<<: *tests-template
image: quay.io/pypa/manylinux_2_28_x86_64
command: .github/wheel-helpers/test-wheel-manylinux.sh cp38-cp38-manylinux_2_28_x86_64 /opt/python/cp38-cp38/bin/python3
command: .github/wheel-helpers/test-wheel-manylinux.sh cp38 /opt/python/cp38-cp38/bin/python3

wheels-manylinux_2_28-cp39:
<<: *tests-template
image: quay.io/pypa/manylinux_2_28_x86_64
command: .github/wheel-helpers/test-wheel-manylinux.sh cp39-cp39-manylinux_2_28_x86_64 /opt/python/cp39-cp39/bin/python3
command: .github/wheel-helpers/test-wheel-manylinux.sh cp39 /opt/python/cp39-cp39/bin/python3

wheels-manylinux_2_28-cp310:
<<: *tests-template
image: quay.io/pypa/manylinux_2_28_x86_64
command: .github/wheel-helpers/test-wheel-manylinux.sh cp310-cp310-manylinux_2_28_x86_64 /opt/python/cp310-cp310/bin/python3
command: .github/wheel-helpers/test-wheel-manylinux.sh cp310 /opt/python/cp310-cp310/bin/python3

wheels-manylinux_2_28-cp311:
<<: *tests-template
image: quay.io/pypa/manylinux_2_28_x86_64
command: .github/wheel-helpers/test-wheel-manylinux.sh cp311-cp311-manylinux_2_28_x86_64 /opt/python/cp311-cp311/bin/python3
command: .github/wheel-helpers/test-wheel-manylinux.sh cp311 /opt/python/cp311-cp311/bin/python3
2 changes: 1 addition & 1 deletion .github/wheel-helpers/test-wheel-manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PYTHON=$2
dnf install -y bubblewrap

"$PYTHON" -m venv /tmp/venv
/tmp/venv/bin/pip3 install ./wheelhouse/BuildStream-*-$COMPATIBILITY_TAGS.whl buildstream-plugins
/tmp/venv/bin/pip3 install ./wheelhouse/BuildStream-*-$COMPATIBILITY_TAGS-*.whl buildstream-plugins

cd doc/examples/autotools
/tmp/venv/bin/bst build hello.bst
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ About
.. image:: https://docs.buildstream.build/master/_static/release.svg
:target: https://docs.buildstream.build/master/_static/release.html

.. image:: https://docs.buildstream.build/master/_static/snapshot.svg
:target: https://docs.buildstream.build/master/_static/snapshot.html

.. image:: https://img.shields.io/github/workflow/status/apache/buildstream/Merge%20actions
:alt: GitHub Workflow Status
:target: https://github.com/apache/buildstream/actions/workflows/merge.yml
Expand Down
6 changes: 2 additions & 4 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ badges-clean:

badges:
mkdir -p source/badges
$(CURDIR)/badges.py > source/badges/snapshot.svg
$(CURDIR)/badges.py --release > source/badges/release.svg
$(CURDIR)/badges.py --redirect > source/badges/snapshot.html
$(CURDIR)/badges.py --redirect --release > source/badges/release.html
$(CURDIR)/badges.py > source/badges/release.svg
$(CURDIR)/badges.py --redirect > source/badges/release.html


############################################################
Expand Down
31 changes: 7 additions & 24 deletions doc/badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
"""

# The redirect template is for a static html page hosted in the
# latest docs which always redirects you to the latest snapshot
# or release on github.
# latest docs which always redirects you to the latest release on github.
#
REDIRECT_TEMPLATE = """
<!DOCTYPE html>
Expand All @@ -83,7 +82,6 @@

URL_FORMAT = 'https://github.com/apache/buildstream/releases/tag/{version}'
RELEASE_COLOR = '#0040FF'
SNAPSHOT_COLOR = '#FF8000'
VERSION_TAG_MATCH = r'([0-9]*)\.([0-9]*)\.([0-9]*)'


Expand All @@ -107,7 +105,7 @@ def parse_tag(tag):
# Call out to git and guess the latest version,
# this will just return (0, 0, 0) in case of any error.
#
def guess_version(release):
def guess_version():
try:
tags_output = subprocess.check_output(['git', 'tag'])
except subprocess.CalledProcessError:
Expand All @@ -118,38 +116,23 @@ def guess_version(release):
all_tags = tags_output.splitlines()
all_versions = [parse_tag(tag) for tag in all_tags]

# Filter the list by the minor point version, if
# we are checking for the latest "release" version, then
# only pickup even number minor points.
#
filtered_versions = [
version for version in all_versions
if (version[1] % 2) == (not release)
]

# Make sure they are sorted, and take the last one
sorted_versions = sorted(filtered_versions)
sorted_versions = sorted(all_versions)
latest_version = sorted_versions[-1]

return latest_version


@click.command(short_help="Generate the version badges")
@click.option('--release', is_flag=True, default=False,
help="Whether to generate the badge for the release version")
@click.option('--redirect', is_flag=True, default=False,
help="Whether to generate the redirect html file")
def generate_badges(release, redirect):
def generate_badges(redirect):
"""Generate the version badge svg files
"""
major, minor, micro = guess_version(release)
major, minor, micro = guess_version()

if release:
badge_name = 'release'
color = RELEASE_COLOR
else:
badge_name = 'snapshot'
color = SNAPSHOT_COLOR
badge_name = 'release'
color = RELEASE_COLOR

version = '{major}.{minor}.{micro}'.format(major=major, minor=minor, micro=micro)
url_target = URL_FORMAT.format(version=version)
Expand Down
40 changes: 0 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import re
import sys

import packaging.version


###################################
# Ensure we have a version number #
Expand All @@ -32,44 +30,6 @@
sys.path.append(os.path.dirname(__file__))
import versioneer # pylint: disable=wrong-import-position


def mark_unstable_version(version_string):
# When publishing to PyPI we must be sure that unstable releases are
# marked as such, so `pip install` doesn't install them by default.

v = packaging.version.parse(version_string)

# BuildStream version scheme: if MINOR version is odd, then
# this is an unstable release.
is_unstable_release = v.minor % 2 != 0

# Python PEP440 version scheme: use an explicit postfix to mark development
# and prereleases.
if is_unstable_release:
if v.local or v.is_devrelease or v.is_prerelease:
# PyPI will ignore these without us marking them.
return version_string
else:
return version_string + ".dev0"

return version_string


# Extend versioneer to support our custom version style.
_render = versioneer.render


def render_version(pieces, style):
if style == "pep440_buildstream":
result = _render(pieces, "pep440")
result["version"] = mark_unstable_version(result["version"])
else:
result = _render(pieces, style)
return result


versioneer.render = render_version

version = versioneer.get_version()

if version.startswith("0+untagged"):
Expand Down

0 comments on commit 3da45a5

Please sign in to comment.