Skip to content

Commit

Permalink
Merge pull request #97 from r0h4n/master
Browse files Browse the repository at this point in the history
Improves versioning
  • Loading branch information
r0h4n committed Jan 8, 2017
2 parents f4e4251 + 11c534a commit 8b8d98b
Show file tree
Hide file tree
Showing 39 changed files with 391 additions and 246 deletions.
2 changes: 1 addition & 1 deletion HACKING.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Style Commandments
=======================
==================

- Tendrl's coding style is inspired by one of the largest python projects, OpenStack
http://docs.openstack.org/developer/hacking/ (excluding the license and trademark sections)
Expand Down
28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
NAME=tendrl-commons
VERSION=0.0.1
VERSION := $(shell PYTHONPATH=. python -c \
'import tendrl.commons; print tendrl.commons.__version__' \
| sed 's/\.dev[0-9]*//')
RELEASE=1
COMMIT := $(shell git rev-parse HEAD)
SHORTCOMMIT := $(shell echo $(COMMIT) | cut -c1-7)
GIT_RELEASE := $(shell git describe --tags --match 'v*' \
| sed 's/^v//' \
| sed 's/^[^-]*-//' \
| sed 's/-.*//')

all: srpm

clean:
rm -rf dist/
rm -f $(NAME)-$(VERSION).tar.gz
rm -f $(NAME)-$(VERSION)-1.el7.src.rpm
rm -rf $(NAME)-$(VERSION)-$(RELEASE).el7.src.rpm

dist:
python setup.py sdist \
Expand All @@ -19,4 +27,18 @@ srpm: dist
rpm: dist
mock -r epel-7-x86_64 rebuild $(NAME)-$(VERSION)-$(RELEASE).el7.src.rpm --resultdir=. --define "dist .el7"

.PHONY: dist rpm srpm
gitversion:
# Set version and release to the latest values from Git
$(eval VERSION := $(VERSION).dev$(GIT_RELEASE))
$(eval RELEASE := $(GIT_RELEASE).$(SHORTCOMMIT))
sed -i tendrl/commons/__init__.py \
-e "s/^__version__ = .*/__version__ = '$(VERSION)'/"
sed -i tendrl-commons.spec \
-e "s/^Version: .*/Version: $(VERSION)/"
sed -i tendrl-commons.spec \
-e "s/^Release: .*/Release: $(RELEASE)/"

snapshot: gitversion srpm


.PHONY: dist rpm srpm gitversion snapshot
29 changes: 26 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,39 @@ Builds
------

.. image:: https://travis-ci.org/Tendrl/commons.svg?branch=master
:target: https://travis-ci.org/Tendrl/commons
:target: https://travis-ci.org/Tendrl/commons

Code Coverage
-------------

.. image:: https://coveralls.io/repos/github/Tendrl/commons/badge.svg
:target: https://coveralls.io/github/Tendrl/commons
:target: https://coveralls.io/github/Tendrl/commons

Release process
---------------

When you are ready to cut a new version:

#. Bump the version number in ``tendrl/commons/__init__.py`` and commit your
changes.
::

python setup.py bumpversion

#. Tag and push to GitHub.
::

python setup.py release

#. Make an SRPM.
::

make srpm



Developer/Install documentation
-----------------------
-------------------------------

We also have sphinx documentation in ``docs/source``.

Expand Down
1 change: 0 additions & 1 deletion check_commit_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
tendrl_spec = None
github_base_url = "http://github.com"


# Extract "tendrl-bug-id" and "tendrl-spec" name from the commit message
for line in commit_msg.split("\n"):
if "tendrl-bug-id" in line:
Expand Down
16 changes: 8 additions & 8 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
.. commons documentation master file, created by
sphinx-quickstart on Tue Jul 9 22:26:36 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
sphinx-quickstart on Tue Jul 9 22:26:36 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to commons documentation
========================================================

Contents:

.. toctree::
:maxdepth: 2
:maxdepth: 2

readme
installation
usage
contributing
readme
installation
usage
contributing

Indices and tables
==================
Expand Down
36 changes: 18 additions & 18 deletions etc/samples/tendrl_api_job.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
# sds api job sample

{
"cluster_id": "bc35fde8-528b-4908-8d52-50d8bf964dd4",
"sds_name": "gluster",
"sds_version": "3.2.0",
"node_ids": ["node_id1", ...],
"run": "tendrl.gluster_integration.flows.create_volume.CreateVolume",
"status": "new",
"parameters": {
"volname": "Volume One"
},
"type": "sds"
"cluster_id": "bc35fde8-528b-4908-8d52-50d8bf964dd4",
"sds_name": "gluster",
"sds_version": "3.2.0",
"node_ids": ["node_id1", ...],
"run": "tendrl.gluster_integration.flows.create_volume.CreateVolume",
"status": "new",
"parameters": {
"volname": "Volume One"
},
"type": "sds"
}

# node agent api job sample
# if job is intended for a specific node_agent, use "node_id", else "node_id" is optional


{
"cluster_id": "bc35fde8-528b-4908-8d52-50d8bf964dd4",
"node_ids": ["node_id1", ...],
"run": "tendrl.node_agent.gluster_integration.flows.import_cluster.ImportCluster",
"status": "new",
"parameters": {
"volname": "Volume One"
},
"type": "node"
"cluster_id": "bc35fde8-528b-4908-8d52-50d8bf964dd4",
"node_ids": ["node_id1", ...],
"run": "tendrl.node_agent.gluster_integration.flows.import_cluster.ImportCluster",
"status": "new",
"parameters": {
"volname": "Volume One"
},
"type": "node"
}
1 change: 0 additions & 1 deletion releasenotes/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
# Output file base name for HTML help builder.
htmlhelp_basename = 'GlanceReleaseNotesdoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
Expand Down
4 changes: 2 additions & 2 deletions releasenotes/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
============================================

.. toctree::
:maxdepth: 1
:maxdepth: 1

unreleased
unreleased
105 changes: 103 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,116 @@
import re
import subprocess

from setuptools import Command
from setuptools import find_packages
from setuptools import setup

try:
# Python 2 backwards compat
from __builtin__ import raw_input as input
except ImportError:
pass


def extract_requirements(filename):
with open(filename, 'r') as requirements_file:
return [x[:-1] for x in requirements_file.readlines()]


install_requires = extract_requirements('requirements.txt')


def read_module_contents():
with open('tendrl/commons/__init__.py') as app_init:
return app_init.read()


def read_spec_contents():
with open('tendrl-commons.spec') as spec:
return spec.read()


module_file = read_module_contents()
metadata = dict(re.findall("__([a-z]+)__\s*=\s*'([^']+)'", module_file))
version = metadata['version']


class BumpCommand(Command):
"""Bump the __version__ number and commit all changes. """

user_options = [('version=', 'v', 'version number to use')]

def initialize_options(self):
new_version = metadata['version'].split('.')
new_version[-1] = str(int(new_version[-1]) + 1) # Bump the final part
self.version = ".".join(new_version)

def finalize_options(self):
pass

def run(self):

print('old version: %s new version: %s' %
(metadata['version'], self.version))
try:
input('Press enter to confirm, or ctrl-c to exit >')
except KeyboardInterrupt:
raise SystemExit("\nNot proceeding")

old = "__version__ = '%s'" % metadata['version']
new = "__version__ = '%s'" % self.version
module_file = read_module_contents()
with open('tendrl/commons/__init__.py', 'w') as fileh:
fileh.write(module_file.replace(old, new))

old = 'Version: %s' % metadata['version']
new = 'Version: %s' % self.version
spec_file = read_spec_contents()
with open('tendrl-commons.spec', 'w') as fileh:
fileh.write(spec_file.replace(old, new))

# Commit everything with a standard commit message
cmd = ['git', 'commit', '-a', '-m', 'version %s' % self.version]
print(' '.join(cmd))
subprocess.check_call(cmd)


class ReleaseCommand(Command):
"""Tag and push a new release. """

user_options = [('sign', 's', 'GPG-sign the Git tag and release files')]

def initialize_options(self):
self.sign = False

def finalize_options(self):
pass

def run(self):
# Create Git tag
tag_name = 'v%s' % version
cmd = ['git', 'tag', '-a', tag_name, '-m', 'version %s' % version]
if self.sign:
cmd.append('-s')
print(' '.join(cmd))
subprocess.check_call(cmd)

# Push Git tag to origin remote
cmd = ['git', 'push', 'origin', tag_name]
print(' '.join(cmd))
subprocess.check_call(cmd)

# Push package to pypi
# cmd = ['python', 'setup.py', 'sdist', 'upload']
# if self.sign:
# cmd.append('--sign')
# print(' '.join(cmd))
# subprocess.check_call(cmd)


setup(
name="tendrl-commons",
version="0.0.1",
version=version,
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*",
"tests"]),
namespace_packages=['tendrl'],
Expand All @@ -19,5 +119,6 @@ def extract_requirements(filename):
author_email="rkanade@redhat.com",
license="LGPL-2.1+",
zip_safe=False,
install_requires=install_requires
install_requires=install_requires,
cmdclass={'bumpversion': BumpCommand, 'release': ReleaseCommand},
)
64 changes: 0 additions & 64 deletions tendrl-common.spec

This file was deleted.

1 change: 1 addition & 0 deletions tendrl/commons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.1'

0 comments on commit 8b8d98b

Please sign in to comment.