예제 #1
0
 def test_should_bump_build(self):
     self.assertEqual(bump_build('3.4.5-rc.1+build.9'),
                      '3.4.5-rc.1+build.10')
     self.assertEqual(bump_build('3.4.5-rc.1+0009.dev'),
                      '3.4.5-rc.1+0010.dev')
     self.assertEqual(bump_build('3.4.5-rc.1'), '3.4.5-rc.1+build.1')
     self.assertEqual(bump_build('3.4.5'), '3.4.5+build.1')
예제 #2
0
def bump(latest):
    merge_request_id = extract_merge_request_id_from_commit()
    labels = retrieve_labels_from_merge_request(merge_request_id)
    new_version = None
    print('MR Labels', labels)
    if "bump-major" in labels:
        print('Bump major')
        new_version = semver.bump_major(latest)
    elif "bump-minor" in labels:
        print('Bump minor')
        new_version = semver.bump_minor(latest)
    elif "bump-patch" in labels:
        print('Bump patch')
        new_version = semver.bump_patch(latest)
    elif "finalize-rc" in labels:
        print('Finalize rc')
        new_version = semver.finalize_version(latest)
    elif "bump-build":
        print('Bump build')
        new_version = semver.bump_build(new_version if new_version else latest)

    if "bump-rc" in labels and not "finalize-rc" in labels:
        print('Bump rc')
        new_version = semver.bump_prerelease(
            new_version if new_version else latest)
        new_version = semver.bump_build(new_version)

    return new_version if new_version else latest
예제 #3
0
 def test_should_bump_build(self):
     self.assertEqual(bump_build('3.4.5-rc.1+build.9'),
                      '3.4.5-rc.1+build.10')
     self.assertEqual(bump_build('3.4.5-rc.1+0009.dev'),
                      '3.4.5-rc.1+0010.dev')
     self.assertEqual(bump_build('3.4.5-rc.1'),
                      '3.4.5-rc.1+build.1')
     self.assertEqual(bump_build('3.4.5'),
                      '3.4.5+build.1')
    def release(self, release_type, local_template, current_version):
        product_version = current_version
        if release_type == 'build':
            product_version = semver.bump_build(current_version)
        if release_type == 'major':
            product_version = semver.bump_major(current_version)
        if release_type == 'minor':
            product_version = semver.bump_minor(current_version)
        if release_type == 'patch':
            product_version = semver.bump_patch(current_version)

        self.release_new_build(local_template, product_version)
예제 #5
0
def test_should_bump_build():
    assert bump_build('3.4.5-rc.1+build.9') == '3.4.5-rc.1+build.10'
    assert bump_build('3.4.5-rc.1+0009.dev') == '3.4.5-rc.1+0010.dev'
    assert bump_build('3.4.5-rc.1') == '3.4.5-rc.1+build.1'
    assert bump_build('3.4.5') == '3.4.5+build.1'
    assert bump_build('3.4.5', 'nightly') == '3.4.5+nightly.1'
    assert bump_build('3.4.5', '') == '3.4.5+build.1'
예제 #6
0
def test_should_bump_build(version, expected):
    assert bump_build(version) == expected
예제 #7
0
def test_should_bump_build():
    assert bump_build('3.4.5-rc.1+build.9') == '3.4.5-rc.1+build.10'
    assert bump_build('3.4.5-rc.1+0009.dev') == '3.4.5-rc.1+0010.dev'
    assert bump_build('3.4.5-rc.1') == '3.4.5-rc.1+build.1'
    assert bump_build('3.4.5') == '3.4.5+build.1'
예제 #8
0
import semver

CHANGELOG_LABEL_PREFIX = 'changelog/'
CHANGELOG_TYPE_NONE = 'no-changelog'
VERSION_BUMP = OrderedDict([
    ('Added', semver.bump_minor),
    ('Changed', semver.bump_major),
    ('Deprecated', semver.bump_minor),
    ('Fixed', semver.bump_patch),
    ('Removed', semver.bump_major),
    ('Security', semver.bump_minor),
    ('major', semver.bump_major),
    ('minor', semver.bump_minor),
    ('patch', semver.bump_patch),
    ('fix', semver.bump_patch),
    ('build', lambda v: semver.bump_build(v, 'build')),
    ('nightly', lambda v: semver.bump_build(v, 'nightly')),
    ('dev', lambda v: semver.bump_prerelease(v, 'dev')),
    ('rc', lambda v: semver.bump_prerelease(v, 'rc')),
    ('pre', lambda v: semver.bump_prerelease(v, 'pre')),
    ('alpha', lambda v: semver.bump_prerelease(v, 'alpha')),
    ('beta', lambda v: semver.bump_prerelease(v, 'beta')),
])

# The checks requirement file used by the agent
AGENT_REQ_FILE = 'requirements-agent-release.txt'

AGENT_V5_ONLY = {
    'agent_metrics',
    'docker_daemon',
    'kubernetes',
예제 #9
0
 def bump_build(self, token=None):
     if token:
         self.build_token = token
     v = semver.bump_build(str(self), token=self.build_token)
     self.parse_version(v)
     return v
예제 #10
0
def test_should_bump_build(version, expected):
    assert bump_build(version) == expected
예제 #11
0
def release_local(url, version='patch', base='master', integration=None, default_version='0.0.1', use_prefix=None):
    # type: (str, str, str, str, str, str) -> str
    """
    Tag given repository with a new semver tag (bump version),
    optionally merging a integration branch.

    This will:
        - clone the repository to temporary directory
        - checkout branch indicated via base argument
        - retrieve all the tags, sort them in natural order
        - retrieve the last tag and bump it to given version
        - merge integration branch, if defined
        - tag and push base branch back to origin

    If no tag is present and version argument is any of the bump arguments,
    default_version will be used

    :rtype: str
    :param url: URL of the repository
    :param version: specific version or one of: build, prerelease, patch, minor, major
    :param base: base branch to use, by default master
    :param integration: integration branch to use, by default none
    :param default_version: default version used for when there are no tags and no specific version, default 0.0.1
    :param use_prefix: use prefix for tags - sometimes, 'v',
    :return: newly released version string or None if can not tag
    """
    workspace = mkdtemp()
    repo = Repo.clone_from(url, workspace, progress=SimpleProgressPrinter())

    if repo.bare:
        print_err('Cloned a bare repository, can not release [???]')

    origin = repo.remote('origin')

    if repo.active_branch.name != base:
        origin.fetch('refs/heads/{0}:refs/heads/{0}'.format(base), progress=SimpleProgressPrinter())
        repo.heads[base].checkout()

    if integration is not None and integration in repo.heads:
        print_info('Found integration branch "{0}", fetching'.format(integration))
        origin.fetch('refs/heads/{0}:refs/heads/{0}'.format(integration), progress=SimpleProgressPrinter())
        print_info('Will now attempt fast-forward {0} to include {1}'.format(base, integration))
        print_git_output(repo.git.merge('--commit', '--no-edit', '--stat', '--ff-only', '-v', integration))

    head_tags = (tag for tag in repo.tags if tag.commit == repo.head.commit)
    sorted_head_tags = natsorted(head_tags, key=lambda t: t.path)

    if 0 != len(sorted_head_tags):
        print_info(
            'Not going to auto-tag already tagged HEAD, tagged with {0}'
                .format(
                str.join(', ', (t.path[10:] for t in sorted_head_tags))
            )
        )
        return None

    last_tag = None

    if repo.tags:
        sorted_tags = natsorted(repo.tags, key=lambda t: t.path)
        current_tag = sorted_tags[-1].path[10:]
        print_info('Current tag is {0}'.format(current_tag))
        if use_prefix is not None and current_tag.startswith(use_prefix):
            last_tag = current_tag[len(use_prefix):]
        else:
            last_tag = current_tag

    print_info('Last known version: {0}'.format(last_tag))

    if last_tag is None:
        print('Unknown last version, using default version {0}'.format(default_version))
        last_tag = default_version

    if 'build' == version:
        next_version = bump_build(last_tag)

    elif 'prerelease' == version:
        next_version = bump_prerelease(last_tag)

    elif 'patch' == version:
        next_version = bump_patch(last_tag)

    elif 'minor' == version:
        next_version = bump_minor(last_tag)

    elif 'major' == version:
        next_version = bump_major(last_tag)
    else:
        next_version = version

    print_info('Next version: {0}'.format(next_version))

    next_tag = next_version.strip()

    if use_prefix is not None:
        next_tag = use_prefix + next_version

    print_info('Next tag: {0}'.format(next_tag))

    print_info('Tagging and pushing version')

    release_tag = repo.create_tag(
        path=next_tag,
        ref=repo.heads[base],
        message='Release tag of {0}'.format(next_version)
    )

    origin.push([release_tag, repo.heads[base]], progress=SimpleProgressPrinter())

    print_info('Done, clearing workspace')
    rmtree(workspace)

    return next_version