diff --git a/.circleci/config.yml b/.circleci/config.yml index c8de0688..a745c37c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -124,7 +124,7 @@ jobs: command: | if [ "${DOCKER_EMAIL}" == 'googleapis-publisher@google.com' ]; then # extract version number from setup.py - ARTMAN_VERSION=`awk -F"'" '/current_version =/ { print $2; }' setup.py` + ARTMAN_VERSION=`awk '/ENV ARTMAN_VERSION/ { print $3; }' Dockerfile` # push to docker docker login -e "${DOCKER_EMAIL}" -u "${DOCKER_USER}" -p "${DOCKER_PASS}" docker tag artman "googleapis/artman:AUTO_BUILD_$CIRCLE_BUILD_NUM" diff --git a/Dockerfile b/Dockerfile index 034c4a34..8ea5834b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM ubuntu:16.04 # Release parameters ENV GOOGLEAPIS_HASH 837973f525ecf5f0cb1cfa2bd8fc85e936d4c6c9 ENV GAPIC_GENERATOR_HASH 48441a7c3382583d5887a9db7286fb0fb93223e7 +# Define version number below. The ARTMAN_VERSION line is parsed by +# .circleci/config.yml and setup.py, please keep the format. ENV ARTMAN_VERSION 0.15.5 ENV DEBIAN_FRONTEND noninteractive diff --git a/setup.py b/setup.py index 3d31766b..4c0b34ba 100644 --- a/setup.py +++ b/setup.py @@ -19,14 +19,25 @@ import io import os +import re import setuptools -# The following line is parsed by CI scripts (see .circleci/config.yml) -# and by release.py. Please keep the format. -current_version = '0.15.5' - cur_dir = os.path.realpath(os.path.dirname(__file__)) -with io.open('%s/requirements.txt' % cur_dir) as requirements_file: + +# version is defined in Dockerfile: ENV ARTMAN_VERSION version +current_version = None +with io.open(os.path.join(cur_dir, 'Dockerfile')) as dockerfile: + for line in dockerfile: + match = re.match('^ENV ARTMAN_VERSION (\S+)$', line) + if match: + current_version = match.group(1) + break +if not current_version: + print('Cannot determine version from Dockerfile. Exiting.') + exit(1) +print('Version: %s' % current_version) + +with io.open(os.path.join(cur_dir, 'requirements.txt')) as requirements_file: requirements = requirements_file.read().strip().split('\n') setuptools.setup( diff --git a/update-versions.py b/update-versions.py index fb521aee..00e0358e 100644 --- a/update-versions.py +++ b/update-versions.py @@ -30,7 +30,6 @@ dockerfile_googleapis_regex = r'^(ENV GOOGLEAPIS_HASH )\S+()' dockerfile_gapic_generator_regex = r'^(ENV GAPIC_GENERATOR_HASH )\S+()' dockerfile_version_regex = r'^(ENV ARTMAN_VERSION )\S+()' -setup_py_version_regex = r"^(current_version = ')\S+(')" github_gapic_generator_project = 'googleapis/gapic-generator' github_googleapis_project = 'googleapis/googleapis' @@ -139,7 +138,6 @@ def main(): abspath = os.path.abspath(parser.prog) root_dir = os.path.dirname(abspath) dockerfile = os.path.join(root_dir, 'Dockerfile') - setup_py = os.path.join(root_dir, 'setup.py') # Do what they asked if googleapis_sha: @@ -153,7 +151,6 @@ def main(): if args.version: update_file(dockerfile, dockerfile_version_regex, args.version) - update_file(setup_py, setup_py_version_regex, args.version) print('Version is now ' + args.version + '.')