Skip to content

Commit

Permalink
Merge pull request #2853 from dhermes/fix-pkg-regex-on-circleci
Browse files Browse the repository at this point in the history
Fixing regex for package deployment.
  • Loading branch information
dhermes authored Dec 16, 2016
2 parents a514703 + 358c51e commit ac0eb25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ general:

deployment:
release:
tag: /(([a-z]+)-)?([0-9]+)\.([0-9]+)\.([0-9]+)/
# See "scripts/circleci_tagged_pkg.py" for info on REGEX
tag: /(([a-z]+)-)*([0-9]+)\.([0-9]+)\.([0-9]+)/
owner: GoogleCloudPlatform
commands:
- pip install --upgrade twine
Expand Down
13 changes: 9 additions & 4 deletions scripts/circleci_tagged_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@
import sys


RE_TXT = r'^((?P<pkg>[a-z]+)-)?([0-9]+)\.([0-9]+)\.([0-9]+)$'
TAG_RE = re.compile(RE_TXT)
TAG_RE = re.compile(r"""
^
(?P<pkg>
(([a-z]+)-)*) # pkg-name-with-hyphens- (empty allowed)
([0-9]+)\.([0-9]+)\.([0-9]+) # Version x.y.z (x, y, z all ints)
$
""", re.VERBOSE)
TAG_ENV = 'CIRCLE_TAG'
ERROR_MSG = '%s env. var. not set' % (TAG_ENV,)
BAD_TAG_MSG = 'Invalid tag name: %s. Expected ' + RE_TXT
BAD_TAG_MSG = 'Invalid tag name: %s. Expected pkg-name-x.y.z'
_SCRIPTS_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.abspath(os.path.join(_SCRIPTS_DIR, '..'))

Expand All @@ -52,7 +57,7 @@ def main():
if pkg_name is None:
print(ROOT_DIR)
else:
pkg_dir = pkg_name.replace('-', '_')
pkg_dir = pkg_name.rstrip('-').replace('-', '_')
print(os.path.join(ROOT_DIR, pkg_dir))


Expand Down

0 comments on commit ac0eb25

Please sign in to comment.