Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
extract version from Dockerfile (#504)
Browse files Browse the repository at this point in the history
* extract version from Dockerfile

* pr feedback
  • Loading branch information
alexander-fenster authored Sep 27, 2018
1 parent 20839f4 commit 4d49d72
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
command: |
if [ "${DOCKER_EMAIL}" == '[email protected]' ]; 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"
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 16 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions update-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand All @@ -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 + '.')


Expand Down

0 comments on commit 4d49d72

Please sign in to comment.