add semantic versioning checks
This commit is contained in:
parent
ff40fc8ea3
commit
e9de8322da
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 1.0.4
|
current_version = 1.0.5
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
tag_name = v{new_version}
|
tag_name = v{new_version}
|
||||||
@ -10,7 +10,7 @@ search = version = {current_version}
|
|||||||
replace = version = {new_version}
|
replace = version = {new_version}
|
||||||
|
|
||||||
[semver]
|
[semver]
|
||||||
main_branches = develop, env-test, env-stage, env-prod
|
main_branches = develops, env-test, env-stage, env-prod
|
||||||
major_branches =
|
major_branches =
|
||||||
minor_branches = feature
|
minor_branches = feature, RightBrain-Networks/feature
|
||||||
patch_branches = hotfix, bugfix
|
patch_branches = hotfix, bugfix
|
||||||
|
BIN
dist/semver-1.0.5.tar.gz
vendored
Normal file
BIN
dist/semver-1.0.5.tar.gz
vendored
Normal file
Binary file not shown.
43
semver.egg-info/PKG-INFO
Normal file
43
semver.egg-info/PKG-INFO
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
Metadata-Version: 1.1
|
||||||
|
Name: semver
|
||||||
|
Version: 1.0.5
|
||||||
|
Summary: Automatic Semantic Versioner
|
||||||
|
Home-page: https://git-codecommit.us-east-1.amazonaws.com/v1/repos/auto-semver
|
||||||
|
Author: RightBrain Networks
|
||||||
|
Author-email: cloud@rightbrainnetworks.com
|
||||||
|
License: Apache2.0
|
||||||
|
Description: 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
|
||||||
|
|
||||||
|
Keywords: Semantic Version
|
||||||
|
Platform: UNKNOWN
|
||||||
|
Classifier: Development Status :: 3 - Alpha
|
||||||
|
Classifier: Intended Audience :: Developers
|
||||||
|
Classifier: Intended Audience :: System Administrators
|
||||||
|
Classifier: Topic :: Software Development :: Build Tools
|
||||||
|
Classifier: License :: OSI Approved :: Apache Software License
|
||||||
|
Classifier: Programming Language :: Python :: 2
|
||||||
|
Classifier: Programming Language :: Python :: 2.7
|
||||||
|
Classifier: Programming Language :: Python :: 3
|
||||||
|
Classifier: Programming Language :: Python :: 3.3
|
||||||
|
Classifier: Programming Language :: Python :: 3.4
|
||||||
|
Classifier: Programming Language :: Python :: 3.5
|
||||||
|
Classifier: Programming Language :: Python :: 3.6
|
10
semver.egg-info/SOURCES.txt
Normal file
10
semver.egg-info/SOURCES.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
README.rst
|
||||||
|
setup.py
|
||||||
|
semver/__init__.py
|
||||||
|
semver/get_version.py
|
||||||
|
semver.egg-info/PKG-INFO
|
||||||
|
semver.egg-info/SOURCES.txt
|
||||||
|
semver.egg-info/dependency_links.txt
|
||||||
|
semver.egg-info/entry_points.txt
|
||||||
|
semver.egg-info/requires.txt
|
||||||
|
semver.egg-info/top_level.txt
|
1
semver.egg-info/dependency_links.txt
Normal file
1
semver.egg-info/dependency_links.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
4
semver.egg-info/entry_points.txt
Normal file
4
semver.egg-info/entry_points.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[console_scripts]
|
||||||
|
semver = semver:main
|
||||||
|
semver_get_version = semver.get_version:main
|
||||||
|
|
1
semver.egg-info/requires.txt
Normal file
1
semver.egg-info/requires.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
bumpversion==0.5.3
|
1
semver.egg-info/top_level.txt
Normal file
1
semver.egg-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
semver
|
@ -6,38 +6,58 @@ except ImportError:
|
|||||||
# Python < 3
|
# Python < 3
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
|
|
||||||
class SemVer(object):
|
class SemVer(object):
|
||||||
|
|
||||||
GET_COMMIT_MESSAGE = re.compile(r"Merge branch '(.+)' into ([^\n]+)")
|
GET_COMMIT_MESSAGE = re.compile(r"Merge (branch|pull request) '?(.+)'? (into|from) ([\w/-]+)")
|
||||||
|
#Merge pull request #1 from RightBrain-Networks/feature/PLAT-185-versioning
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.merged_branch = None
|
self.merged_branch = None
|
||||||
self.main_branch = None
|
self.main_branch = None
|
||||||
self.version_type = None
|
self.version_type = None
|
||||||
|
|
||||||
self.main_branches = self._setting_to_array('main_branches')
|
self.main_branches = ['development', 'env-test', 'env-stage', 'env-prod']
|
||||||
self.major_branches = self._setting_to_array('major_branches')
|
self.major_branches = []
|
||||||
self.minor_branches = self._setting_to_array('minor_branches')
|
self.minor_branches = ['feature', 'RightBrain-Networks/feature']
|
||||||
self.patch_branches = self._setting_to_array('patch_branches')
|
self.patch_branches = ['hotfix', 'bugfix']
|
||||||
|
|
||||||
def _setting_to_array(self, setting):
|
#def _setting_to_array(self, setting):
|
||||||
config = ConfigParser()
|
# config = ConfigParser()
|
||||||
config.read('./.bumpversion.cfg')
|
# config.read('./.bumpversion.cfg')
|
||||||
value = config.get('semver', setting)
|
# value = config.get('semver', setting)
|
||||||
|
# print(str(value))
|
||||||
|
|
||||||
|
#return value.split(',')
|
||||||
# filter() removes empty string which is what we get if setting is blank
|
# filter() removes empty string which is what we get if setting is blank
|
||||||
return filter(bool, [v.strip() for v in value.split(',')])
|
#return [v.strip() for v in value.split(',')]
|
||||||
|
|
||||||
# based on commit message see what branches are involved in the merge
|
# based on commit message see what branches are involved in the merge
|
||||||
|
|
||||||
def get_branches(self):
|
def get_branches(self):
|
||||||
p = subprocess.Popen(['git', 'log', '-1'], stdout=subprocess.PIPE,
|
p = subprocess.Popen(['git', 'log', '-1'], stdout=subprocess.PIPE,
|
||||||
cwd='.')
|
cwd='.')
|
||||||
|
#check current branch
|
||||||
|
b = subprocess.Popen(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout=subprocess.PIPE,
|
||||||
|
cwd='.')
|
||||||
message = str(p.stdout.read())
|
message = str(p.stdout.read())
|
||||||
|
br = b.stdout.read().decode('utf-8')
|
||||||
|
#remove newline
|
||||||
|
branch=br.rstrip()
|
||||||
|
print("Main branch is "+branch)
|
||||||
matches = self.GET_COMMIT_MESSAGE.search(message)
|
matches = self.GET_COMMIT_MESSAGE.search(message)
|
||||||
if matches:
|
if matches:
|
||||||
self.merged_branch = matches.group(1)
|
if str(matches.group(4)) == branch:
|
||||||
self.main_branch = matches.group(2)
|
self.merged_branch = matches.group(2)
|
||||||
|
else:
|
||||||
|
self.merged_branch = matches.group(4)
|
||||||
|
self.main_branch = branch
|
||||||
|
#print("group1 "+matches.group(1))
|
||||||
|
#print("group2 "+matches.group(2))
|
||||||
|
#print("group3 "+matches.group(3))
|
||||||
|
#print("group4 "+matches.group(4))
|
||||||
|
|
||||||
return bool(matches)
|
return bool(matches)
|
||||||
|
|
||||||
# based on branches involved see what type of versioning should be done
|
# based on branches involved see what type of versioning should be done
|
||||||
@ -78,7 +98,7 @@ class SemVer(object):
|
|||||||
|
|
||||||
def commit_and_push(self):
|
def commit_and_push(self):
|
||||||
# push versioning commit
|
# push versioning commit
|
||||||
p = subprocess.Popen(['git', 'push', 'origin', 'develop'],
|
p = subprocess.Popen(['git', 'push', 'origin', self.main_branch],
|
||||||
cwd='.')
|
cwd='.')
|
||||||
p.wait()
|
p.wait()
|
||||||
|
|
||||||
@ -93,6 +113,7 @@ class SemVer(object):
|
|||||||
# 3) see what type of versioning we should do
|
# 3) see what type of versioning we should do
|
||||||
# 4) version the repo
|
# 4) version the repo
|
||||||
def run(self):
|
def run(self):
|
||||||
|
print(self.main_branches)
|
||||||
if not self.get_branches():
|
if not self.get_branches():
|
||||||
raise Exception('No merge found')
|
raise Exception('No merge found')
|
||||||
if self.main_branch not in self.main_branches:
|
if self.main_branch not in self.main_branches:
|
||||||
|
BIN
semver/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
semver/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user