Skip to content

Commit

Permalink
MINOR: release.py: fix some compatibility problems.
Browse files Browse the repository at this point in the history
Rather than using sed, use built-in Python regular expressions to strip
the SNAPSHOT expression from the pom.xml files.  Sed has different flags
on different platforms, such as Linux.  Using Python directly here is
more compatible, as well as being more efficient, and not requiring an
rm command afterwards.

When running release_notes.py, use the current Python interpreter.
This is needed to prevent attempting to run release_notes.py with
Python 3 on some systems.  release_notes.py will not (yet) work with
Python 3.

Author: Colin P. Mccabe <[email protected]>

Reviewers: Magnus Edenhill <[email protected]>, David Arthur <[email protected]>, Manikumar Reddy <[email protected]>

Closes apache#6198 from cmccabe/release_py
  • Loading branch information
cmccabe authored and omkreddy committed Feb 4, 2019
1 parent 776041d commit e942e29
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ def replace(path, pattern, replacement):
for line in updated:
f.write(line)

def regexReplace(path, pattern, replacement):
updated = []
with open(path, 'r') as f:
for line in f:
updated.append(re.sub(pattern, replacement, line))

with open(path, 'w') as f:
for line in updated:
f.write(line)

def user_ok(msg):
ok = raw_input(msg)
return ok.lower() == 'y'
Expand Down Expand Up @@ -522,12 +532,17 @@ def select_gpg_key():
print("Updating version numbers")
replace("gradle.properties", "version", "version=%s" % release_version)
replace("tests/kafkatest/__init__.py", "__version__", "__version__ = '%s'" % release_version)
cmd("update streams quickstart pom", ["sed", "-i", ".orig"," s/-SNAPSHOT//", "streams/quickstart/pom.xml"])
cmd("update streams quickstart java pom", ["sed", "-i", ".orig", "s/-SNAPSHOT//", "streams/quickstart/java/pom.xml"])
cmd("update streams quickstart java pom", ["sed", "-i", ".orig", "s/-SNAPSHOT//", "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml"])
cmd("remove backup pom.xml", "rm streams/quickstart/pom.xml.orig")
cmd("remove backup java pom.xml", "rm streams/quickstart/java/pom.xml.orig")
cmd("remove backup java pom.xml", "rm streams/quickstart/java/src/main/resources/archetype-resources/pom.xml.orig")
print("updating streams quickstart pom")
regexReplace("streams/quickstart/pom.xml", "-SNAPSHOT", "")
print("updating streams quickstart java pom")
regexReplace("streams/quickstart/java/pom.xml", "-SNAPSHOT", "")
print("updating streams quickstart archetype pom")
regexReplace("streams/quickstart/java/src/main/resources/archetype-resources/pom.xml", "-SNAPSHOT", "")
print("updating ducktape version.py")
regexReplace("./tests/kafkatest/version.py", "^DEV_VERSION =.*",
"DEV_VERSION = KafkaVersion(\"%s-SNAPSHOT\")" % release_version)
print("updating ducktape __init__.py")
regexReplace("./tests/kafkatest/__init__.py", ".dev.*", "")
# Command in explicit list due to messages with spaces
cmd("Committing version number updates", ["git", "commit", "-a", "-m", "Bump version to %s" % release_version])
# Command in explicit list due to messages with spaces
Expand Down Expand Up @@ -555,7 +570,7 @@ def select_gpg_key():
with open(os.path.join(artifacts_dir, "RELEASE_NOTES.html"), 'w') as f:
print("Generating release notes")
try:
subprocess.check_call(["./release_notes.py", release_version], stdout=f)
subprocess.check_call([sys.executable, "./release_notes.py", release_version], stdout=f)
except subprocess.CalledProcessError as e:
print_output(e.output)

Expand Down

0 comments on commit e942e29

Please sign in to comment.