Skip to content

Commit

Permalink
Add the git sha to version output
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <dnephin@docker.com>
  • Loading branch information
dnephin committed Dec 3, 2015
1 parent 3b6cc7a commit bea2072
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/docs/_site
/venv
README.rst
compose/GITSHA
2 changes: 1 addition & 1 deletion Dockerfile.run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ COPY requirements.txt /code/requirements.txt
RUN pip install -r /code/requirements.txt

ADD dist/docker-compose-release.tar.gz /code/docker-compose
RUN pip install /code/docker-compose/docker-compose-*
RUN pip install --no-deps /code/docker-compose/docker-compose-*

ENTRYPOINT ["/usr/bin/docker-compose"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include *.md
exclude README.md
include README.rst
include compose/config/*.json
include compose/GITSHA
recursive-include contrib/completion *
recursive-include tests *
global-exclude *.pyc
Expand Down
4 changes: 2 additions & 2 deletions compose/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

from . import errors
from . import verbose_proxy
from .. import __version__
from .. import config
from ..project import Project
from ..service import ConfigError
from .docker_client import docker_client
from .utils import call_silently
from .utils import get_version_info
from .utils import is_mac
from .utils import is_ubuntu

Expand Down Expand Up @@ -71,7 +71,7 @@ def get_client(verbose=False, version=None):
client = docker_client(version=version)
if verbose:
version_info = six.iteritems(client.version())
log.info("Compose version %s", __version__)
log.info(get_version_info('full'))
log.info("Docker base_url: %s", client.base_url)
log.info("Docker version: %s",
", ".join("%s=%s" % item for item in version_info))
Expand Down
39 changes: 29 additions & 10 deletions compose/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import ssl
import subprocess

from docker import version as docker_py_version
import docker
from six.moves import input

from .. import __version__
import compose


def yesno(prompt, default=None):
Expand Down Expand Up @@ -57,13 +57,32 @@ def is_ubuntu():


def get_version_info(scope):
versioninfo = 'docker-compose version: %s' % __version__
versioninfo = 'docker-compose version {}, build {}'.format(
compose.__version__,
get_build_version())

if scope == 'compose':
return versioninfo
elif scope == 'full':
return versioninfo + '\n' \
+ "docker-py version: %s\n" % docker_py_version \
+ "%s version: %s\n" % (platform.python_implementation(), platform.python_version()) \
+ "OpenSSL version: %s" % ssl.OPENSSL_VERSION
else:
raise RuntimeError('passed unallowed value to `cli.utils.get_version_info`')
if scope == 'full':
return (
"{}\n"
"docker-py version: {}\n"
"{} version: {}\n"
"OpenSSL version: {}"
).format(
versioninfo,
docker.version,
platform.python_implementation(),
platform.python_version(),
ssl.OPENSSL_VERSION)

raise ValueError("{} is not a valid version scope".format(scope))


def get_build_version():
filename = os.path.join(os.path.dirname(compose.__file__), 'GITSHA')
if not os.path.exists(filename):
return 'unknown'

with open(filename) as fh:
return fh.read().strip()
24 changes: 19 additions & 5 deletions docker-compose.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,32 @@ a = Analysis(['bin/docker-compose'],
runtime_hooks=None,
cipher=block_cipher)

pyz = PYZ(a.pure,
cipher=block_cipher)
pyz = PYZ(a.pure, cipher=block_cipher)

exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[('compose/config/fields_schema.json', 'compose/config/fields_schema.json', 'DATA')],
[('compose/config/service_schema.json', 'compose/config/service_schema.json', 'DATA')],
[
(
'compose/config/fields_schema.json',
'compose/config/fields_schema.json',
'DATA'
),
(
'compose/config/service_schema.json',
'compose/config/service_schema.json',
'DATA'
),
(
'compose/GITSHA',
'compose/GITSHA',
'DATA'
)
],
name='docker-compose',
debug=False,
strip=None,
upx=True,
console=True )
console=True)
1 change: 1 addition & 0 deletions script/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fi
TAG=$1
VERSION="$(python setup.py --version)"

./script/write-git-sha
python setup.py sdist
cp dist/docker-compose-$VERSION.tar.gz dist/docker-compose-release.tar.gz
docker build -t docker/compose:$TAG -f Dockerfile.run .
1 change: 1 addition & 0 deletions script/build-linux
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ docker build -t "$TAG" . | tail -n 200
docker run \
--rm --entrypoint="script/build-linux-inner" \
-v $(pwd)/dist:/code/dist \
-v $(pwd)/.git:/code/.git \
"$TAG"
1 change: 1 addition & 0 deletions script/build-linux-inner
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mkdir -p `pwd`/dist
chmod 777 `pwd`/dist

$VENV/bin/pip install -q -r requirements-build.txt
./script/write-git-sha
su -c "$VENV/bin/pyinstaller docker-compose.spec" user
mv dist/docker-compose $TARGET
$TARGET version
1 change: 1 addition & 0 deletions script/build-osx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ virtualenv -p /usr/local/bin/python venv
venv/bin/pip install -r requirements.txt
venv/bin/pip install -r requirements-build.txt
venv/bin/pip install --no-deps .
./script/write-git-sha
venv/bin/pyinstaller docker-compose.spec
mv dist/docker-compose dist/docker-compose-Darwin-x86_64
dist/docker-compose-Darwin-x86_64 version
2 changes: 2 additions & 0 deletions script/build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ virtualenv .\venv
.\venv\Scripts\pip install --no-deps .
.\venv\Scripts\pip install --allow-external pyinstaller -r requirements-build.txt

git rev-parse --short HEAD | out-file -encoding ASCII compose\GITSHA

# Build binary
# pyinstaller has lots of warnings, so we need to run with ErrorAction = Continue
$ErrorActionPreference = "Continue"
Expand Down
1 change: 1 addition & 0 deletions script/release/push-release
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ docker push docker/compose:$VERSION
echo "Uploading sdist to pypi"
pandoc -f markdown -t rst README.md -o README.rst
sed -i -e 's/logo.png?raw=true/https:\/\/github.com\/docker\/compose\/raw\/master\/logo.png?raw=true/' README.rst
./script/write-git-sha
python setup.py sdist
if [ "$(command -v twine 2> /dev/null)" ]; then
twine upload ./dist/docker-compose-${VERSION}.tar.gz
Expand Down
7 changes: 7 additions & 0 deletions script/write-git-sha
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
#
# Write the current commit sha to the file GITSHA. This file is included in
# packaging so that `docker-compose version` can include the git sha.
#
set -e
git rev-parse --short HEAD > compose/GITSHA

0 comments on commit bea2072

Please sign in to comment.