summaryrefslogtreecommitdiffstats
path: root/packaging/release
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/release')
-rw-r--r--packaging/release/release.yml210
-rw-r--r--packaging/release/templates/RELEASES.tmpl16
-rw-r--r--packaging/release/tests/__init__.py0
-rw-r--r--packaging/release/tests/version_helper_test.py42
-rw-r--r--packaging/release/vars/versions.yml167
-rw-r--r--packaging/release/versionhelper/__init__.py0
-rw-r--r--packaging/release/versionhelper/version_helper.py182
7 files changed, 224 insertions, 393 deletions
diff --git a/packaging/release/release.yml b/packaging/release/release.yml
deleted file mode 100644
index 2f00f03d68..0000000000
--- a/packaging/release/release.yml
+++ /dev/null
@@ -1,210 +0,0 @@
-- hosts: localhost
- gather_facts: no
- vars_files:
- - vars/versions.yml
- vars:
- release_dir: "./ansible_release"
- release_date: "{{lookup('pipe', 'date +\"%m-%d-%Y\"')}}"
- rpm_spec_line: |
-
- * {{lookup('pipe', 'date +"%a %b %d %Y"')}} Ansible, Inc. <info@ansible.com> - {{ansible_release_version}}-{{ansible_release_string}}
- - Release {{ansible_release_version}}-{{ansible_release_string}}
- deb_changelog_line: |
-
- ansible ({{ansible_release_version}}) unstable; urgency=low
-
- * {{ansible_release_version}}
-
- -- Ansible, Inc. <info@ansible.com> {{lookup('pipe', 'date -R')}}
-
- vars_prompt:
- - name: ansible_release_branch
- prompt: "Enter the release branch"
- private: no
- - name: ansible_release_version
- prompt: "Enter the release version"
- private: no
- - name: ansible_release_string
- prompt: "Enter the release string (ie. 0.1.beta1, or just 1 for final releases)"
- private: no
- #- name: ansible_release_codename
- # prompt: "Enter the release code name (only used if doing a final release)"
- # default: ""
- # private: no
- - name: has_submodules
- prompt: "Does this branch have git submodules?"
- default: "no"
- private: no
- - name: is_final
- prompt: "Is this a final release (not a beta/rc)?"
- default: "no"
- private: no
- - name: do_push
- prompt: "Push repositories upstream when done?"
- default: "no"
- private: no
- tasks:
- - pause:
- prompt: "Has the CHANGELOG.md, versions.yml, release_and_maintenance.rst, and any other files been updated and are ready to go?"
- when: is_final|bool
-
- - name: create a combined version string from the specified values
- set_fact:
- new_version: "v{{ansible_release_version}}-{{ansible_release_string}}"
-
- - name: assert certain variables are defined
- assert:
- that:
- - ansible_release_branch is defined
- - ansible_release_version is defined
- - ansible_release_string is defined
-
- - name: Remove ansible_release (if it exists)
- file:
- path: "{{release_dir}}/"
- state: absent
-
- - name: Clone the official repo
- git:
- #repo: "git@github.com:ansible/ansible.git"
- repo: "https://github.com/ansible/ansible.git"
- dest: "{{release_dir}}"
- version: "{{ansible_release_branch}}"
- recursive: yes
-
- - name: get the latest version
- shell:
- _raw_params: git tag | tail -1
- chdir: "{{release_dir}}"
- register: latest_version
-
- - name: "assert the specified version ({{new_version}}) is greater than the latest version ({{latest_version.stdout}})"
- assert:
- that:
- - new_version is version(latest_version.stdout, "gt")
- ignore_errors: yes
-
- - name: Update the VERSION file for the main repo
- copy:
- dest: "{{release_dir}}/VERSION"
- content: "{{ansible_release_version}} {{ansible_release_string}}\n"
-
- - name: Update the library version
- lineinfile:
- dest: "{{release_dir}}/lib/ansible/release.py"
- regexp: "^__version__ ="
- line: "__version__ = '{{ansible_release_version}}'"
-
- - block:
- - name: Update the spec file release list
- lineinfile:
- dest: "{{release_dir}}/packaging/rpm/ansible.spec"
- regexp: "^- Release {{ansible_release_version}}-{{ansible_release_string}}"
- line: "{{rpm_spec_line.rstrip()}}"
- insertafter: "^%changelog"
- - name: Update the deb changelog file
- lineinfile:
- dest: "{{release_dir}}/packaging/debian/changelog"
- regexp: "^ansible ({{ansible_release_version}})"
- line: "{{deb_changelog_line}}"
- insertafter: "-- Ansible, Inc. <info@ansible.com> %DATE%"
- - name: Update RELEASES.txt
- template:
- dest: "{{release_dir}}/RELEASES.txt"
- src: "templates/RELEASES.tmpl"
- when: is_final|bool
-
- - name: "Make sure modules are checked out to {{ansible_release_branch}}"
- shell:
- _raw_params: "git checkout {{ansible_release_branch}}"
- chdir: "{{release_dir}}/lib/ansible/modules/{{item}}/"
- with_items:
- - core
- - extras
- when: has_submodules|bool
-
- - name: Update the VERSION file for the modules
- copy:
- dest: "{{release_dir}}/lib/ansible/modules/{{item}}/VERSION"
- content: "{{ansible_release_version}} {{ansible_release_string}}\n"
- with_items:
- - core
- - extras
- when: has_submodules|bool
-
- - name: Add and commit the updated files for the core modules
- shell:
- _raw_params: "git add ./ && git commit -m 'New release {{new_version}}'"
- chdir: "{{release_dir}}/lib/ansible/modules/{{item}}/"
- with_items:
- - core
- - extras
- when: has_submodules|bool
-
- - name: Add and commit the updated files for the main repo
- shell:
- _raw_params: "git add ./ && git commit -m 'New release {{new_version}}'"
- chdir: "{{release_dir}}/"
-
- - name: Tag the release
- shell:
- _raw_params: "git tag -fa {{new_version}} -m 'New release {{new_version}}'"
- chdir: "{{release_dir}}/"
-
- - name: update git config for the main repo
- lineinfile:
- dest: "{{release_dir}}/.git/config"
- regexp: "upstream"
- line: |
- [remote "upstream"]
- url = git@github.com:ansible/ansible.git
- fetch = +refs/heads/*:refs/remotes/origin/*
-
- - name: update git config for submodules
- lineinfile:
- dest: "{{release_dir}}/.git/modules/lib/ansible/modules/{{item}}/config"
- regexp: "submodule_upstream"
- line: |
- [remote "submodule_upstream"]
- url = git@github.com:ansible/ansible-modules-{{item}}.git
- fetch = +refs/heads/*:refs/remotes/origin/*
- with_items:
- - core
- - extras
- when: has_submodules|bool
-
- - name: create the dist tar.gz
- command:
- _raw_params: make sdist
- chdir: "{{release_dir}}/"
- environment:
- OFFICIAL: yes
-
- - name: rename the dist tar.gz to include the full release
- command:
- _raw_params: "mv dist/ansible-{{ansible_release_version}}.tar.gz dist/ansible-{{ansible_release_version}}-{{ansible_release_string}}.tar.gz"
- chdir: "{{release_dir}}/"
-
- - name: generate the SHA file for the tar.gz
- shell:
- _raw_params: "sha256sum dist/ansible-{{ansible_release_version}}-{{ansible_release_string}}.tar.gz > dist/ansible-{{ansible_release_version}}-{{ansible_release_string}}.tar.gz.sha"
- chdir: "{{release_dir}}/"
-
- - block:
- - pause:
- prompt: "Ready to push, this is the last chance to abort..."
-
- - name: Push the submodule repos
- shell:
- _raw_params: "git push submodule_upstream {{ansible_release_branch}}"
- chdir: "{{release_dir}}/lib/ansible/modules/{{item}}/"
- with_items:
- - core
- - extras
- when: has_submodules|bool
-
- - name: Push the updates and/or tag
- shell:
- _raw_params: "git push --tags upstream {{ansible_release_branch}}"
- chdir: "{{release_dir}}/lib/ansible/modules/{{item}}/"
- when: do_push|bool
diff --git a/packaging/release/templates/RELEASES.tmpl b/packaging/release/templates/RELEASES.tmpl
deleted file mode 100644
index dbe76c6896..0000000000
--- a/packaging/release/templates/RELEASES.tmpl
+++ /dev/null
@@ -1,16 +0,0 @@
-Ansible Releases at a Glance
-============================
-
-VERSION RELEASE CODE NAME
-++++++++++++++++++++++++++++++
-
-{% for version in versions %}
-{% for vkey, vdata in version.items() %}
-{% for release in vdata.releases %}
-{% for rkey, rdata in release.items() %}
-{% set major_minor = vkey + "." + rkey %}
-{{"%-8s"|format(major_minor)}} {{"%-10s"|format(rdata)}} "{{vdata.code_name}}"
-{% endfor %}
-{% endfor %}
-{% endfor %}
-{% endfor %}
diff --git a/packaging/release/tests/__init__.py b/packaging/release/tests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packaging/release/tests/__init__.py
diff --git a/packaging/release/tests/version_helper_test.py b/packaging/release/tests/version_helper_test.py
new file mode 100644
index 0000000000..72271e4d66
--- /dev/null
+++ b/packaging/release/tests/version_helper_test.py
@@ -0,0 +1,42 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import pytest
+
+from packaging.version import InvalidVersion
+from versionhelper.version_helper import AnsibleVersionMunger
+
+
+@pytest.mark.parametrize('version,revision,codename,output_propname,expected', [
+ ('2.5.0dev1', None, None, 'raw', '2.5.0dev1'),
+ ('2.5.0', None, None, 'raw', '2.5.0'),
+ ('2.5.0dev1', None, None, 'major_version', '2.5'),
+ ('2.5.0', None, None, 'major_version', '2.5'),
+ ('2.5.0dev1', None, None, 'base_version', '2.5.0'),
+ ('2.5.0', None, None, 'base_version', '2.5.0'),
+ ('2.5.0dev1', None, None, 'deb_version', '2.5.0~dev1'),
+ ('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'),
+ ('2.5.0', None, None, 'deb_version', '2.5.0'),
+ ('2.5.0dev1', None, None, 'deb_release', '1'),
+ ('2.5.0b1', 2, None, 'deb_release', '2'),
+ ('2.5.0dev1', None, None, 'rpm_release', '0.1.dev1'),
+ ('2.5.0a1', None, None, 'rpm_release', '0.101.a1'),
+ ('2.5.0b1', None, None, 'rpm_release', '0.201.b1'),
+ ('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'),
+ ('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'),
+ ('2.5.0.rc.1', None, None, 'rpm_release', '0.1001.rc.1'),
+ ('2.5.0', None, None, 'rpm_release', '1'),
+ ('2.5.0', 2, None, 'rpm_release', '2'),
+ ('2.5.0', None, None, 'codename', 'UNKNOWN'),
+ ('2.5.0', None, 'LedZeppelinSongHere', 'codename', 'LedZeppelinSongHere'),
+ ('2.5.0x1', None, None, None, InvalidVersion)
+])
+def test_output_values(version, revision, codename, output_propname, expected):
+ try:
+ v = AnsibleVersionMunger(version, revision, codename)
+ assert getattr(v, output_propname) == expected
+ except Exception as ex:
+ if isinstance(expected, type):
+ assert isinstance(ex, expected)
+ else:
+ raise
diff --git a/packaging/release/vars/versions.yml b/packaging/release/vars/versions.yml
deleted file mode 100644
index ab4bf49dea..0000000000
--- a/packaging/release/vars/versions.yml
+++ /dev/null
@@ -1,167 +0,0 @@
-versions:
-- "2.6":
- code_name: "Heartbreaker"
- releases:
- - "0": TBD
-- "2.5":
- code_name: "Kashmir"
- releases:
- - "0": TBD
-- "2.4":
- code_name: "Dancing Days"
- releases:
- - "4": "04-04-2018"
- - "3": "01-31.2018"
- - "2": "11-29-2017"
- - "1": "10-25-2017"
- - "0": "09-19-2017"
-- "2.3":
- code_name: "Ramble On"
- releases:
- - "3": "12-20-2017"
- - "2": "08-04-2017"
- - "1": "06-01-2017"
- - "0": "04-12-2017"
-- "2.2":
- code_name: "The Battle of Evermore"
- releases:
- - "3": "05-09-2017"
- - "2": "03-27-2017"
- - "1": "01-16-2017"
- - "0": "11-01-2016"
-- "2.1":
- code_name: "The Song Remains the Same"
- releases:
- - "6": "06-01-2017"
- - "5": "03-27-2017"
- - "4": "01-16-2017"
- - "3": "11-04-2016"
- - "2": "09-29-2016"
- - "1": "07-28-2016"
- - "0": "05-25-2016"
-- "2.0":
- code_name: "Over the Hills and Far Away"
- releases:
- - '2': "04-19-2016"
- - '1': "02-24-2016"
- - '0': "01-12-2016"
-- "1.9":
- code_name: "Dancing In the Streets"
- releases:
- - '6': "04-15-2016"
- - '5': "03-21-2016"
- - '4': "10-09-2015"
- - '3': "09-03-2015"
- - '2': "06-24-2015"
- - '1': "04-27-2015"
- - '0': "03-25-2015"
-- "1.8":
- code_name: "You Really Got Me"
- releases:
- - '4': "02-19-2015"
- - '3': "02-17-2015"
- - '2': "12-04-2014"
- - '1': "11-26-2014"
- - '0': "11-25-2014"
-- "1.7":
- code_name: "Summer Nights"
- releases:
- - '2': "09-24-2014"
- - '1': "08-14-2014"
- - '0': "08-06-2014"
-- "1.6":
- code_name: "The Cradle Will Rock"
- releases:
- - '10': "07-25-2014"
- - '9': "07-24-2014"
- - '8': "07-22-2014"
- - '7': "07-21-2014"
- - '6': "07-01-2014"
- - '5': "06-25-2014"
- - '4': "06-25-2014"
- - '3': "06-09-2014"
- - '2': "05-23-2014"
- - '1': "05-07-2014"
- - '0': "05-05-2014"
-- "1.5":
- code_name: "Love Walks In"
- releases:
- - '5': "04-18-2014"
- - '4': "04-01-2014"
- - '3': "03-13-2014"
- - '2': "03-11-2014"
- - '1': "03-10-2014"
- - '0': "02-28-2014"
-- "1.4":
- code_name: "Could This Be Magic?"
- releases:
- - '5': "02-12-2014"
- - '4': "01-06-2014"
- - '3': "12-20-2013"
- - '2': "12-18-2013"
- - '1': "11-27-2013"
- - '0': "11-21-2013"
-- "1.3":
- code_name: "Top of the World"
- releases:
- - '4': "10-29-2013"
- - '3': "10-09-2013"
- - '2': "09-19-2013"
- - '1': "09-16-2013"
- - '0': "09-13-2013"
-- "1.2":
- code_name: "Right Now"
- releases:
- - '3': "08-21-2013"
- - '2': "07-05-2013"
- - '1': "07-04-2013"
- - '0': "06-10-2013"
-- "1.1":
- code_name: "Mean Street"
- releases:
- - '0': "04-02-2013"
-- "1.0":
- code_name: "Eruption"
- releases:
- - '0': "02-01-2013"
-- "0.9":
- code_name: "Dreams"
- releases:
- - '0': "11-30-2012"
-- "0.8":
- code_name: "Cathedral"
- releases:
- - '0': "10-19-2012"
-- "0.7":
- code_name: "Panama"
- releases:
- - '0': "09-06-2012"
-- "0.6":
- code_name: "Cabo"
- releases:
- - '0': "08-06-2012"
-- "0.5":
- code_name: "Amsterdam"
- releases:
- - '0': "07-04-2012"
-- "0.4":
- code_name: "Unchained"
- releases:
- - '0': "05-23-2012"
-- "0.3":
- code_name: "Baluchitherium"
- releases:
- - '0': "04-23-2012"
-- "0.2":
- code_name: "Untitled"
- releases:
- - '0': "?"
-- "0.1":
- code_name: "Untitled"
- releases:
- - '0': "?"
-- "0.0":
- code_name: "Untitled"
- releases:
- - '2': "?"
- - '1': "?"
diff --git a/packaging/release/versionhelper/__init__.py b/packaging/release/versionhelper/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packaging/release/versionhelper/__init__.py
diff --git a/packaging/release/versionhelper/version_helper.py b/packaging/release/versionhelper/version_helper.py
new file mode 100644
index 0000000000..051e7998fe
--- /dev/null
+++ b/packaging/release/versionhelper/version_helper.py
@@ -0,0 +1,182 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import argparse
+import os
+import re
+import sys
+
+from packaging.version import Version, VERSION_PATTERN
+
+
+class AnsibleVersionMunger(object):
+ tag_offsets = dict(
+ dev=0,
+ a=100,
+ b=200,
+ rc=1000
+ )
+
+ # TODO: allow overrides here for packaging bump etc
+ def __init__(self, raw_version, revision=None, codename=None):
+ self._raw_version = raw_version
+ self._revision = revision
+ self._parsed_version = Version(raw_version)
+ self._codename = codename
+ self._parsed_regex_match = re.match(VERSION_PATTERN, raw_version, re.VERBOSE | re.IGNORECASE)
+
+ @property
+ def deb_version(self):
+ v = self._parsed_version
+
+ match = self._parsed_regex_match
+
+ if v.is_prerelease:
+ if match.group('pre'):
+ tag_value = match.group('pre')
+ tag_type = match.group('pre_l')
+ tag_ver = match.group('pre_n')
+ elif match.group('dev'):
+ tag_type = "dev"
+ tag_value = match.group('dev')
+ tag_ver = match.group('dev_n')
+ else:
+ raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
+
+ elif v.is_postrelease:
+ raise Exception("post-release identifiers are not supported")
+ else:
+ tag_type = None
+ tag_value = ''
+ tag_ver = 0
+
+ # not a pre/post/dev release, just return base version
+ if not tag_type:
+ return '{base_version}'.format(base_version=self.base_version)
+
+ # it is a pre/dev release, include the tag value with a ~
+ return '{base_version}~{tag_value}'.format(base_version=self.base_version, tag_value=tag_value)
+
+ @property
+ def deb_release(self):
+ return '1' if self._revision is None else str(self._revision)
+
+ @property
+ def rpm_release(self):
+ v = self._parsed_version
+ match = self._parsed_regex_match
+
+ if v.is_prerelease:
+ if match.group('pre'):
+ tag_value = match.group('pre')
+ tag_type = match.group('pre_l')
+ tag_ver = match.group('pre_n')
+ elif match.group('dev'):
+ tag_type = "dev"
+ tag_value = match.group('dev')
+ tag_ver = match.group('dev_n')
+ else:
+ raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
+
+ elif v.is_postrelease:
+ raise Exception("post-release identifiers are not supported")
+ else:
+ tag_type = None
+ tag_value = ''
+ tag_ver = 0
+
+ # not a pre/post/dev release, just append revision (default 1)
+ if not tag_type:
+ if self._revision is None:
+ self._revision = 1
+ return '{revision}'.format(revision=self._revision)
+
+ # cleanse tag value in case it starts with .
+ tag_value = tag_value.strip('.')
+
+ # coerce to int and None == 0
+ tag_ver = int(tag_ver if tag_ver else 0)
+
+ if self._revision is None:
+ tag_offset = self.tag_offsets.get(tag_type)
+ if tag_offset is None:
+ raise Exception('no tag offset defined for tag {0}'.format(tag_type))
+ pkgrel = '0.{0}'.format(tag_offset + tag_ver)
+ else:
+ pkgrel = self._revision
+
+ return '{pkgrel}.{tag_value}'.format(pkgrel=pkgrel, tag_value=tag_value)
+
+ @property
+ def raw(self):
+ return self._raw_version
+
+ # return the x.y.z version without any other modifiers present
+ @property
+ def base_version(self):
+ return self._parsed_version.base_version
+
+ # return the x.y version without any other modifiers present
+ @property
+ def major_version(self):
+ return re.match(r'^(\d+.\d+)', self._raw_version).group(1)
+
+ @property
+ def codename(self):
+ return self._codename if self._codename else "UNKNOWN"
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Extract/transform Ansible versions to various packaging formats')
+
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument('--raw', action='store_true')
+ group.add_argument('--majorversion', action='store_true')
+ group.add_argument('--baseversion', action='store_true')
+ group.add_argument('--debversion', action='store_true')
+ group.add_argument('--debrelease', action='store_true')
+ group.add_argument('--rpmrelease', action='store_true')
+ group.add_argument('--codename', action='store_true')
+ group.add_argument('--all', action='store_true')
+
+ parser.add_argument('--revision', action='store', default='auto')
+
+ args = parser.parse_args()
+
+ mydir = os.path.dirname(__file__)
+ release_loc = os.path.normpath(mydir + '/../../../lib')
+
+ sys.path.insert(0, release_loc)
+
+ from ansible import release
+
+ rev = None
+ if args.revision != 'auto':
+ rev = args.revision
+
+ v_raw = release.__version__
+ codename = release.__codename__
+ v = AnsibleVersionMunger(v_raw, revision=rev, codename=codename)
+
+ if args.raw:
+ print(v.raw)
+ elif args.baseversion:
+ print(v.base_version)
+ elif args.majorversion:
+ print(v.major_version)
+ elif args.debversion:
+ print(v.deb_version)
+ elif args.debrelease:
+ print(v.deb_release)
+ elif args.rpmrelease:
+ print(v.rpm_release)
+ elif args.codename:
+ print(v.codename)
+ elif args.all:
+ props = [name for (name, impl) in vars(AnsibleVersionMunger).items() if isinstance(impl, property)]
+
+ for propname in props:
+ print('{0}: {1}'.format(propname, getattr(v, propname)))
+
+if __name__ == '__main__':
+ main()