Improved versioning
This patch adds versioning system which is consistent with other OpenStack projects. Change-Id: Ia835bf21f800c8c7c65f282a719dbf399d24bb80
This commit is contained in:
@@ -1,19 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
|
||||||
|
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
||||||
|
SCRIPT_DIR=`dirname $SCRIPT_PATH`
|
||||||
|
cd $SCRIPT_DIR/..
|
||||||
|
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git submodule sync
|
|
||||||
git submodule update --init
|
|
||||||
git status -s | grep "." && ( echo "Contains unknown files" ; exit 1 )
|
|
||||||
|
|
||||||
if [ "$1" = "release" ] ; then
|
if [ -n "$1" ] ; then
|
||||||
sed -i -e 's/FINAL=False/FINAL=True/g' packstack/version.py
|
git tag -a -m $1 $1
|
||||||
SNAPTAG=""
|
|
||||||
else
|
|
||||||
SNAPTAG=$(git log --oneline | wc -l)
|
|
||||||
sed -i -e "s/SNAPTAG=None/SNAPTAG=${SNAPTAG}/g" packstack/version.py
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
python setup.py setopt -o tag_build -s "$SNAPTAG" -c egg_info
|
VERSION=`python setup.py --version`
|
||||||
|
|
||||||
|
sed -i -e "s/RESERVE_STR = None/RESERVE_STR = '$VERSION'/g" packstack/version.py
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
||||||
|
if [ -n "$1" ] ; then
|
||||||
|
echo "Packstack was released with tag '$1'. Please don't forget to push tag upstream (git push --tags)."
|
||||||
|
fi
|
||||||
|
|
||||||
git checkout packstack/version.py
|
git checkout packstack/version.py
|
||||||
|
|||||||
@@ -1,14 +1,81 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
from .installer.utils import execute
|
||||||
|
|
||||||
|
|
||||||
|
VERSION = ['2014', '2']
|
||||||
|
OS_RELEASE = 'Juno'
|
||||||
|
RESERVE_STR = None
|
||||||
|
|
||||||
|
|
||||||
|
def vr_from_git():
|
||||||
|
"""Returns VR string calculated from GIT repo."""
|
||||||
|
proj_dir = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
rc, tag = execute(
|
||||||
|
'git describe --exact-match',
|
||||||
|
workdir=proj_dir,
|
||||||
|
use_shell=True,
|
||||||
|
can_fail=False,
|
||||||
|
log=False
|
||||||
|
)
|
||||||
|
if not rc:
|
||||||
|
# we are on tagged commit, so let's use the tag as VR string
|
||||||
|
return tag.strip()
|
||||||
|
|
||||||
|
rc, description = execute(
|
||||||
|
'git describe --always',
|
||||||
|
workdir=proj_dir,
|
||||||
|
use_shell=True,
|
||||||
|
log=False
|
||||||
|
)
|
||||||
|
if '-' in description:
|
||||||
|
# last tag has been found
|
||||||
|
tag, snap_tag, git_hash = description.split('-')
|
||||||
|
else:
|
||||||
|
# no tag has been found
|
||||||
|
rc, git_hash = execute(
|
||||||
|
'git log -n1 --pretty=format:%h',
|
||||||
|
workdir=proj_dir,
|
||||||
|
use_shell=True,
|
||||||
|
log=False
|
||||||
|
)
|
||||||
|
git_hash = 'g{0}'.format(git_hash)
|
||||||
|
rc, snap_tag = execute(
|
||||||
|
'git log --oneline | wc -l',
|
||||||
|
workdir=proj_dir,
|
||||||
|
use_shell=True,
|
||||||
|
log=False
|
||||||
|
)
|
||||||
|
return '{0}.dev{1}.{2}'.format(
|
||||||
|
'.'.join(VERSION),
|
||||||
|
snap_tag.strip(),
|
||||||
|
git_hash.strip(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def vr_from_setuptools():
|
||||||
|
"""Returns VR string fetched from setuptools."""
|
||||||
|
requirement = pkg_resources.Requirement.parse('packstack')
|
||||||
|
provider = pkg_resources.get_provider(requirement)
|
||||||
|
return provider.version
|
||||||
|
|
||||||
VERSION = ['2014', '1', '1']
|
|
||||||
FINAL=False
|
|
||||||
RELEASE="Icehouse"
|
|
||||||
SNAPTAG=None
|
|
||||||
|
|
||||||
def release_string():
|
def release_string():
|
||||||
return RELEASE
|
return OS_RELEASE
|
||||||
|
|
||||||
|
|
||||||
def version_string():
|
def version_string():
|
||||||
if FINAL:
|
try:
|
||||||
return '.'.join(filter(None, VERSION))
|
version = vr_from_git()
|
||||||
else:
|
except Exception:
|
||||||
return '.'.join(filter(None, VERSION))+"dev{0}".format(SNAPTAG)
|
# Not a git repo, so get version from setuptools
|
||||||
|
try:
|
||||||
|
version = vr_from_setuptools()
|
||||||
|
except Exception:
|
||||||
|
# In case of problem with setuptools, return version
|
||||||
|
# saved by release.sh or VERSION if nothing was saved
|
||||||
|
version = RESERVE_STR if RESERVE_STR else '.'.join(VERSION)
|
||||||
|
return version
|
||||||
|
|||||||
Reference in New Issue
Block a user