def vagrant(ver='latest'):
    """
    (Default) Deploy latest version or specific tag to vagrant. Usage: deploy.vagrant:(latest|#.#.#)
    """
    if ver == 'latest':
        create_package()
        ver = get_git_version()

    packages = [f for f in os.listdir('ansible/roles/application/files') if re.match(r'\w+-%s(\.tar.gz|.*\.whl)' % ver.replace('.', '\.'), f)]
    if len(packages) != 2:
        print 'failed to find packages for version: %s' % ver
        exit(1)

    local('ansible-playbook -i ansible/inventory/webservers/vagrant.ini --extra-vars "version=%s" --private-key=.vagrant/machines/web/virtualbox/private_key -u vagrant -v --sudo ansible/deploy.yml' % ver)
def production(ver='latest'):
    """
    Deploy latest version or specific tag to production. Usage: deploy.production:(latest|#.#.#)
    """
    if 'settings' not in env:
        env['settings'] = 'mysite.settings.production'

    if ver == 'latest':
        create_package()
        ver = get_git_version()

    packages = [f for f in os.listdir('ansible/roles/application/files') if re.match(r'\w+-%s(\.tar.gz|.*\.whl)' % ver.replace('.', '\.'), f)]
    if len(packages) != 2:
        print 'failed to find packages for version: %s' % ver
        exit(1)

    local('ansible-playbook ansible/deploy.yml -i ansible/inventory/production.ini --list-hosts')
def bump(component):
    """
    Bump git tag. Usage: build.bump:(major|minor|patch)
    """
    if component not in ['major', 'minor', 'patch']:
        print 'invalid component name valid options: [major|minor|patch]'
        exit(1)
    value = get_git_version()
    components = value.split('.')[:3]
    if len(components) != 3:
        print 'invalid version'
        exit(1)
    components = map(int, components)
    if component == 'major':
        components = [components[0] + 1, 0, 0]
    elif component == 'minor':
        components = [components[0], components[1] + 1, 0]
    elif component == 'patch':
        components = [components[0], components[1], components[2] + 1]
    tag = '.'.join(map(str, components))
    local('git tag -a %s -m "chore(version): bump %s"' % (tag, component))
import os
from glob import glob
from mysite.version import get_git_version
from fabric.api import env

# --set tag=1.1.1
version = env.get('tag', 'latest')
if version == 'latest':
    version = get_git_version()


# verify version
def get_build_files():
    return glob('dist/*-%s*' % version)


# vagrant, development, ci, testing, staging, production
environment = env.get('environment', 'vagrant')
if environment == 'vagrant' or environment == 'ci':
    os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'

bin = {
    'python': env.get('python', 'python'),
    'pip': env.get('pip', 'pip'),
    'gulp': env.get('gulp', 'gulp'),
    'npm': env.get('npm', 'npm'),
    'bower': env.get('bower', 'bower')
}

defaults = {
    'vagrant': {
import os
from glob import glob
from mysite.version import get_git_version
from fabric.api import env

# --set tag=1.1.1
version = env.get('tag', 'latest')
if version == 'latest':
    version = get_git_version()

# verify version
def get_build_files():
    return glob('dist/*-%s*' % version)

# vagrant, development, ci, testing, staging, production
environment = env.get('environment', 'vagrant')
if environment == 'vagrant' or environment == 'ci':
    os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'

bin = {
    'python': env.get('python', 'python'),
    'pip': env.get('pip', 'pip'),
    'gulp': env.get('gulp', 'gulp'),
    'npm': env.get('npm', 'npm'),
    'bower': env.get('bower', 'bower')
}

defaults = {
    'vagrant': {
        'ansible': {
            'inventory': 'ansible/inventory/vagrant.ini'
def get_build_files():
    return glob('dist/*-%s*' % get_git_version())