Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing regex for package deployment. #2853

Merged
merged 2 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]+)/

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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