switched to module and cli install
This commit is contained in:
parent
611cfeafdf
commit
89689f7a03
@ -5,9 +5,9 @@ tag = True
|
||||
tag_name = v{new_version}
|
||||
message = Bump version: {current_version} -> {new_version}
|
||||
|
||||
[bumpversion:file:VERSION]
|
||||
search = version={current_version}
|
||||
replace = version={new_version}
|
||||
[bumpversion:file:semver.semver]
|
||||
search = version = {current_version}
|
||||
replace = version = {new_version}
|
||||
|
||||
[semver]
|
||||
main_branches = develop, env-test, env-stage, env-prod
|
||||
|
@ -13,8 +13,8 @@ RUN useradd -d /semver semver
|
||||
WORKDIR /semver
|
||||
|
||||
ADD ./ /semver
|
||||
RUN chown -R semver:semver /semver && chmod -R ug+x /semver/*
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
RUN python setup.py sdist
|
||||
RUN pip install dist/semver-1.0.4.tar.gz
|
||||
|
||||
CMD python semver.py && python get_version.py
|
||||
CMD semver && semver_get_version
|
||||
|
@ -1,9 +1,7 @@
|
||||
Semantic Versioning
|
||||
----------
|
||||
# Semantic Versioning
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
# Usage
|
||||
|
||||
# FULL_PATH_TO_LOCAL_REPO gives container access to repo to be versioned
|
||||
# FULL_PATH_TO_SSH_FOLDER gives container access to ssh keys to be able to push repo
|
20
README.rst
Normal file
20
README.rst
Normal file
@ -0,0 +1,20 @@
|
||||
Semantic Versioning
|
||||
===================
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
FULL\_PATH\_TO\_LOCAL\_REPO gives container access to repo to be versioned
|
||||
==========================================================================
|
||||
|
||||
FULL\_PATH\_TO\_SSH\_FOLDER gives container access to ssh keys to be able to push repo
|
||||
======================================================================================
|
||||
|
||||
docker build -t semver . docker run -v
|
||||
FULL\_PATH\_TO\_LOCAL\_REPO:/application\_repo -v
|
||||
FULL\_PATH\_TO\_SSH\_FOLDER:/root/.ssh semver
|
||||
|
||||
after this finishes must go to FULL\_PATH\_TO\_LOCAL\_REPO and push yourself
|
||||
============================================================================
|
||||
|
||||
git push origin develop git push origin --tags
|
@ -2,6 +2,7 @@ import re
|
||||
import subprocess
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
version = "1.0.4"
|
||||
|
||||
class SemVer(object):
|
||||
|
||||
@ -19,7 +20,7 @@ class SemVer(object):
|
||||
|
||||
def _setting_to_array(self, setting):
|
||||
config = ConfigParser()
|
||||
config.read('/application_repo/.bumpversion.cfg')
|
||||
config.read('./.bumpversion.cfg')
|
||||
value = config.get('semver', setting)
|
||||
# filter() removes empty string which is what we get if setting is blank
|
||||
return filter(bool, [v.strip() for v in value.split(',')])
|
||||
@ -27,7 +28,7 @@ class SemVer(object):
|
||||
# based on commit message see what branches are involved in the merge
|
||||
def get_branches(self):
|
||||
p = subprocess.Popen(['git', 'log', '-1'], stdout=subprocess.PIPE,
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
message = p.stdout.read()
|
||||
matches = self.GET_COMMIT_MESSAGE.search(message)
|
||||
if matches:
|
||||
@ -56,10 +57,10 @@ class SemVer(object):
|
||||
# setup git user
|
||||
p = subprocess.Popen(['git', 'config', 'user.email',
|
||||
'"versioner@semver.com"'],
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
p = subprocess.Popen(['git', 'config', 'user.name',
|
||||
'"Semantic Versioner"'],
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
p.wait()
|
||||
return self
|
||||
|
||||
@ -67,19 +68,19 @@ class SemVer(object):
|
||||
def version_repo(self):
|
||||
# version repo
|
||||
p = subprocess.Popen(['bumpversion', self.version_type],
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
p.wait()
|
||||
return self
|
||||
|
||||
def commit_and_push(self):
|
||||
# push versioning commit
|
||||
p = subprocess.Popen(['git', 'push', 'origin', 'develop'],
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
p.wait()
|
||||
|
||||
# push versioning tag
|
||||
p = subprocess.Popen(['git', 'push', 'origin', '--tags'],
|
||||
cwd='/application_repo')
|
||||
cwd='.')
|
||||
p.wait()
|
||||
return self
|
||||
|
||||
@ -99,9 +100,12 @@ class SemVer(object):
|
||||
self.commit_and_push()
|
||||
return self
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
try:
|
||||
SemVer().run()
|
||||
except Exception as e:
|
||||
print e.message
|
||||
|
||||
if __name__ == '__main__':
|
||||
try: main()
|
||||
except: raise
|
@ -3,10 +3,14 @@ from ConfigParser import ConfigParser
|
||||
|
||||
def get_version():
|
||||
config = ConfigParser()
|
||||
config.read('/application_repo/.bumpversion.cfg')
|
||||
config.read('./.bumpversion.cfg')
|
||||
version = config.get('bumpversion', 'current_version')
|
||||
return version
|
||||
|
||||
|
||||
def main():
|
||||
print(get_version())
|
||||
|
||||
if __name__ == '__main__':
|
||||
print get_version()
|
||||
try: main()
|
||||
except: raise
|
134
setup.py
Normal file
134
setup.py
Normal file
@ -0,0 +1,134 @@
|
||||
"""A setuptools based setup module.
|
||||
See:
|
||||
https://packaging.python.org/en/latest/distributing.html
|
||||
https://github.com/pypa/sampleproject
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
|
||||
# Always prefer setuptools over distutils
|
||||
from setuptools import setup, find_packages
|
||||
# To use a consistent encoding
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
||||
|
||||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
# Get the long description from the README file
|
||||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
||||
long_description = f.read()
|
||||
|
||||
def read(*parts):
|
||||
# intentionally *not* adding an encoding option to open
|
||||
# see here: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
|
||||
return open(path.join(here, *parts), 'r').read()
|
||||
|
||||
def find_version(*file_paths):
|
||||
version_file = read(*file_paths)
|
||||
version_match = re.search(r"^version = ['\"]([^'\"]*)['\"]",
|
||||
version_file, re.M)
|
||||
if version_match:
|
||||
return version_match.group(1)
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
setup(
|
||||
name='semver',
|
||||
|
||||
# Versions should comply with PEP440. For a discussion on single-sourcing
|
||||
# the version across setup.py and the project code, see
|
||||
# https://packaging.python.org/en/latest/single_source_version.html
|
||||
version=find_version('semver','__init__.py'),
|
||||
#version='0.0.1',
|
||||
|
||||
description='Automatic Semantic Versioner',
|
||||
long_description=long_description,
|
||||
|
||||
# The project's main homepage.
|
||||
url='https://git-codecommit.us-east-1.amazonaws.com/v1/repos/auto-semver',
|
||||
|
||||
# Author details
|
||||
author='RightBrain Networks',
|
||||
author_email='cloud@rightbrainnetworks.com',
|
||||
|
||||
# Choose your license
|
||||
license='Apache2.0',
|
||||
|
||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=[
|
||||
# How mature is this project? Common values are
|
||||
# 3 - Alpha
|
||||
# 4 - Beta
|
||||
# 5 - Production/Stable
|
||||
'Development Status :: 3 - Alpha',
|
||||
|
||||
# Indicate who your project is intended for
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: System Administrators',
|
||||
'Topic :: Software Development :: Build Tools',
|
||||
|
||||
# Pick your license as you wish (should match "license" above)
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
|
||||
# Specify the Python versions you support here. In particular, ensure
|
||||
# that you indicate whether you support Python 2, Python 3 or both.
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6'
|
||||
],
|
||||
|
||||
# What does your project relate to?
|
||||
keywords='Semantic Version',
|
||||
|
||||
# You can just specify the packages manually here if your project is
|
||||
# simple. Or you can use find_packages().
|
||||
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
||||
|
||||
# Alternatively, if you want to distribute just a my_module.py, uncomment
|
||||
# this:
|
||||
# py_modules=["my_module"],
|
||||
|
||||
# List run-time dependencies here. These will be installed by pip when
|
||||
# your project is installed. For an analysis of "install_requires" vs pip's
|
||||
# requirements files see:
|
||||
# https://packaging.python.org/en/latest/requirements.html
|
||||
install_requires=[
|
||||
'bumpversion==0.5.3'
|
||||
],
|
||||
|
||||
# List additional groups of dependencies here (e.g. development
|
||||
# dependencies). You can install these using the following syntax,
|
||||
# for example:
|
||||
# $ pip install -e .[dev,test]
|
||||
#extras_require={
|
||||
# 'dev': ['check-manifest'],
|
||||
# 'test': ['coverage'],
|
||||
#},
|
||||
|
||||
# If there are data files included in your packages that need to be
|
||||
# installed, specify them here. If using Python 2.6 or less, then these
|
||||
# have to be included in MANIFEST.in as well.
|
||||
package_data={
|
||||
},
|
||||
|
||||
# Although 'package_data' is the preferred approach, in some case you may
|
||||
# need to place data files outside of your packages. See:
|
||||
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
|
||||
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
|
||||
#data_files=[('my_data', ['data/data_file'])],
|
||||
|
||||
# To provide executable scripts, use entry points in preference to the
|
||||
# "scripts" keyword. Entry points provide cross-platform support and allow
|
||||
# pip to create the appropriate form of executable for the target platform.
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'semver = semver:main',
|
||||
'semver_get_version = semver.get_version:main'
|
||||
],
|
||||
},
|
||||
)
|
Loading…
Reference in New Issue
Block a user