Allow announce script to work for base and older (#69768)
Change:
- Generalize the announce script changes from 4dd0f4127
Test Plan:
Harcoded 'hashes' to [] and then:
- Ran with --version 2.9.9 --version 2.10.0.dev1
- Ran with --version 2.9.9
- Ran with --version 2.10.1
Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
61a1fe1d7d
commit
3ec18ccb77
1 changed files with 66 additions and 20 deletions
|
@ -18,11 +18,11 @@ from jinja2 import Environment, DictLoader
|
||||||
VERSION_FRAGMENT = """
|
VERSION_FRAGMENT = """
|
||||||
{%- if versions | length > 1 %}
|
{%- if versions | length > 1 %}
|
||||||
{% for version in versions %}
|
{% for version in versions %}
|
||||||
{% if loop.last %}and {{ version }}{% else %}
|
{% if loop.last %}and {{ pretty_version(version) }}{% else %}
|
||||||
{% if versions | length == 2 %}{{ version }} {% else %}{{ version }}, {% endif -%}
|
{% if versions | length == 2 %}{{ pretty_version(version) }} {% else %}{{ pretty_version(version) }}, {% endif -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{%- else %}{{ versions[0] }}{% endif -%}
|
{%- else %}{{ pretty_version(versions[0]) }}{% endif -%}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LONG_TEMPLATE = """
|
LONG_TEMPLATE = """
|
||||||
|
@ -30,19 +30,19 @@ LONG_TEMPLATE = """
|
||||||
{% set latest_ver = (versions | sort(attribute='ver_obj'))[-1] %}
|
{% set latest_ver = (versions | sort(attribute='ver_obj'))[-1] %}
|
||||||
|
|
||||||
To: ansible-devel@googlegroups.com, ansible-project@googlegroups.com, ansible-announce@googlegroups.com
|
To: ansible-devel@googlegroups.com, ansible-project@googlegroups.com, ansible-announce@googlegroups.com
|
||||||
Subject: New ansible-base release{% if plural %}s{% endif %} {{ version_str }}
|
Subject: New release{% if plural %}s{% endif %}: {{ version_str }}
|
||||||
|
|
||||||
{% filter wordwrap %}
|
{% filter wordwrap %}
|
||||||
Hi all- we're happy to announce that the general release of ansible-base {{ version_str }}{% if plural %} are{%- else %} is{%- endif %} now available!
|
Hi all- we're happy to announce that the general release of {{ version_str }}{% if plural %} are{%- else %} is{%- endif %} now available!
|
||||||
{% endfilter %}
|
{% endfilter %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
How do you get it?
|
How to get it
|
||||||
------------------
|
-------------
|
||||||
|
|
||||||
{% for version in versions %}
|
{% for version in versions %}
|
||||||
$ pip install ansible-base=={{ version }} --user
|
$ pip install ansible{% if is_ansible_base(version) %}-base{% endif %}=={{ version }} --user
|
||||||
{% if not loop.last %}
|
{% if not loop.last %}
|
||||||
or
|
or
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -51,8 +51,12 @@ or
|
||||||
The tar.gz of the release{% if plural %}s{% endif %} can be found here:
|
The tar.gz of the release{% if plural %}s{% endif %} can be found here:
|
||||||
|
|
||||||
{% for version in versions %}
|
{% for version in versions %}
|
||||||
* {{ version }}
|
* {{ pretty_version(version) }}
|
||||||
https://releases.ansible.com/ansible-base/ansible-base-{{ version }}.tar.gz
|
{% if is_ansible_base(version) %}
|
||||||
|
https://pypi.python.org/packages/source/a/ansible-base/ansible-base-{{ version }}.tar.gz
|
||||||
|
{% else %}
|
||||||
|
https://pypi.python.org/packages/source/a/ansible/ansible-{{ version }}.tar.gz
|
||||||
|
{% endif %}
|
||||||
SHA256: {{ hashes[version] }}
|
SHA256: {{ hashes[version] }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ If you discover any errors or if any of your working playbooks break when you up
|
||||||
https://github.com/ansible/ansible/issues/new/choose
|
https://github.com/ansible/ansible/issues/new/choose
|
||||||
|
|
||||||
{% filter wordwrap %}
|
{% filter wordwrap %}
|
||||||
In your issue, be sure to mention the ansible-base version that works and the one that doesn't.
|
In your issue, be sure to mention the version that works and the one that doesn't.
|
||||||
{% endfilter %}
|
{% endfilter %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +116,7 @@ Thanks!
|
||||||
|
|
||||||
SHORT_TEMPLATE = """
|
SHORT_TEMPLATE = """
|
||||||
{% set plural = False if versions | length == 1 else True %}
|
{% set plural = False if versions | length == 1 else True %}
|
||||||
|
{% set version = (versions|sort(attribute='ver_obj'))[-1] %}
|
||||||
@ansible
|
@ansible
|
||||||
{{ version_str }}
|
{{ version_str }}
|
||||||
{% if plural %}
|
{% if plural %}
|
||||||
|
@ -125,8 +130,8 @@ them
|
||||||
{% else %}
|
{% else %}
|
||||||
it
|
it
|
||||||
{% endif %}
|
{% endif %}
|
||||||
on PyPI: pip install ansible-base=={{ (versions|sort(attribute='ver_obj'))[-1] }},
|
on PyPI: pip install ansible{% if is_ansible_base(version) %}-base{% endif %}=={{ version }},
|
||||||
https://releases.ansible.com/ansible-base/, the Ansible PPA on Launchpad, or GitHub. Happy automating!
|
the Ansible PPA on Launchpad, or GitHub. Happy automating!
|
||||||
""" # noqa for E501 (line length).
|
""" # noqa for E501 (line length).
|
||||||
# jinja2 is horrid about getting rid of extra newlines so we have to have a single per paragraph for
|
# jinja2 is horrid about getting rid of extra newlines so we have to have a single per paragraph for
|
||||||
# proper wrapping to occur
|
# proper wrapping to occur
|
||||||
|
@ -143,7 +148,7 @@ JINJA_ENV = Environment(
|
||||||
|
|
||||||
|
|
||||||
async def calculate_hash_from_tarball(session, version):
|
async def calculate_hash_from_tarball(session, version):
|
||||||
tar_url = f'https://releases.ansible.com/ansible-base/ansible-base-{version}.tar.gz'
|
tar_url = f'https://pypi.python.org/packages/source/a/ansible-base/ansible-base-{version}.tar.gz'
|
||||||
tar_task = asyncio.create_task(session.get(tar_url))
|
tar_task = asyncio.create_task(session.get(tar_url))
|
||||||
tar_response = await tar_task
|
tar_response = await tar_task
|
||||||
|
|
||||||
|
@ -177,7 +182,7 @@ async def get_hash(session, version):
|
||||||
|
|
||||||
if calculated_hash != precreated_hash:
|
if calculated_hash != precreated_hash:
|
||||||
raise ValueError(f'Hash in file ansible-base-{version}.tar.gz.sha {precreated_hash} does not'
|
raise ValueError(f'Hash in file ansible-base-{version}.tar.gz.sha {precreated_hash} does not'
|
||||||
f' match hash of tarball {calculated_hash}')
|
f' match hash of tarball from pypi {calculated_hash}')
|
||||||
|
|
||||||
return calculated_hash
|
return calculated_hash
|
||||||
|
|
||||||
|
@ -220,25 +225,66 @@ def next_release_date(weeks=3):
|
||||||
return next_release
|
return next_release
|
||||||
|
|
||||||
|
|
||||||
|
def is_ansible_base(version):
|
||||||
|
'''
|
||||||
|
Determines if a version is an ansible-base version or not, by checking
|
||||||
|
if it is >= 2.10.0. Stops comparing when it gets to the first non-numeric
|
||||||
|
component to allow for .dev and .beta suffixes.
|
||||||
|
'''
|
||||||
|
# Ignore .beta/.dev suffixes
|
||||||
|
ver_split = []
|
||||||
|
for component in version.split('.'):
|
||||||
|
if not component.isdigit():
|
||||||
|
# Take everything up until the first non-numeric component
|
||||||
|
break
|
||||||
|
ver_split.append(int(component))
|
||||||
|
return tuple(ver_split) >= (2, 10, 0)
|
||||||
|
|
||||||
|
|
||||||
|
# Currently only use with a single element list, but left general for later
|
||||||
|
# in case we need to refer to the releases collectively.
|
||||||
|
def release_variants(versions):
|
||||||
|
if all(is_ansible_base(v) for v in versions):
|
||||||
|
return 'ansible-base'
|
||||||
|
|
||||||
|
if all(not is_ansible_base(v) for v in versions):
|
||||||
|
return 'Ansible'
|
||||||
|
|
||||||
|
return 'Ansible and ansible-base'
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_version(version):
|
||||||
|
return '{0} {1}'.format(
|
||||||
|
release_variants([version]),
|
||||||
|
version,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_long_message(versions, name):
|
def create_long_message(versions, name):
|
||||||
hashes = asyncio.run(get_hashes(versions))
|
hashes = asyncio.run(get_hashes(versions))
|
||||||
|
|
||||||
version_template = JINJA_ENV.get_template('version_string')
|
version_template = JINJA_ENV.get_template('version_string')
|
||||||
version_str = version_template.render(versions=versions).strip()
|
version_str = version_template.render(versions=versions,
|
||||||
|
pretty_version=pretty_version).strip()
|
||||||
|
|
||||||
next_release = next_release_date()
|
next_release = next_release_date()
|
||||||
|
|
||||||
template = JINJA_ENV.get_template('long')
|
template = JINJA_ENV.get_template('long')
|
||||||
message = template.render(versions=versions, version_str=version_str,
|
message = template.render(versions=versions, version_str=version_str,
|
||||||
name=name, hashes=hashes, next_release=next_release)
|
name=name, hashes=hashes, next_release=next_release,
|
||||||
|
is_ansible_base=is_ansible_base,
|
||||||
|
pretty_version=pretty_version)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
def create_short_message(versions):
|
def create_short_message(versions):
|
||||||
version_template = JINJA_ENV.get_template('version_string')
|
version_template = JINJA_ENV.get_template('version_string')
|
||||||
version_str = version_template.render(versions=versions).strip()
|
version_str = version_template.render(versions=versions,
|
||||||
|
pretty_version=pretty_version).strip()
|
||||||
|
|
||||||
template = JINJA_ENV.get_template('short')
|
template = JINJA_ENV.get_template('short')
|
||||||
message = template.render(versions=versions, version_str=version_str)
|
message = template.render(versions=versions, version_str=version_str,
|
||||||
|
is_ansible_base=is_ansible_base,
|
||||||
|
pretty_version=pretty_version)
|
||||||
message = ' '.join(message.split()) + '\n'
|
message = ' '.join(message.split()) + '\n'
|
||||||
return message
|
return message
|
||||||
|
|
Loading…
Reference in a new issue