forked from databrickslabs/mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple release scripts (databrickslabs#248)
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import sys | ||
import re | ||
|
||
def main(version): | ||
os.system("git checkout main && git pull") | ||
os.system("git tag -a v_%s -m 'Version %s'" % (version, version)) | ||
os.system("git push origin v_%s" % version) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 2: | ||
raise Exception("Please specify a version. Use format x.y.z.") | ||
version = sys.argv[1] | ||
|
||
if (not re.match(r'\d+\.\d+\.\d+', version)): | ||
raise Exception("Invalid version: %s. Use format x.y.z." % version) | ||
|
||
main(version) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import re | ||
import sys | ||
|
||
def main(version, snapshot): | ||
update_pom_version('../pom.xml', version + snapshot) | ||
update_python_version('../python/mosaic/__init__.py', version + snapshot) | ||
update_r_version('../R/sparkR-mosaic/sparkrMosaic/DESCRIPTION', version) | ||
update_r_version('../R/sparklyr-mosaic/sparklyrMosaic/DESCRIPTION', version) | ||
|
||
if not snapshot: | ||
update_docs_version('../docs/source/conf.py', version) | ||
|
||
def update_pom_version(file, version): | ||
update_version(file, r'(<version>)(\d+\.\d+\.\d+(-SNAPSHOT)?)(</version>)', r'\g<1>%s\g<4>' % version) | ||
|
||
def update_python_version(file, version): | ||
update_version(file, r'(__version__ = )("\d+\.\d+\.\d+(-SNAPSHOT)?")', r'\g<1>"%s"' % version) | ||
|
||
def update_r_version(file, version): | ||
update_version(file, r'(Version: )(\d+\.\d+\.\d+(-SNAPSHOT)?)', r'\g<1>%s' % version) | ||
|
||
def update_docs_version(file, version): | ||
update_version(file, r'(release = )("v\d+\.\d+\.\d+")', r'\g<1>"v%s"' % version) | ||
|
||
|
||
def update_version(file, pattern, replace_pattern): | ||
#Open file and replace | ||
|
||
with open (file, 'r' ) as f: | ||
content = f.read() | ||
content_new = re.sub(pattern, replace_pattern, content, flags = re.M, count = 1) | ||
with open (file, 'w' ) as f: | ||
f.write(content_new) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
version = sys.argv[1] | ||
snapshot = "" | ||
if len(sys.argv) > 2: | ||
snapshot = sys.argv[2] | ||
if snapshot != "-SNAPSHOT": | ||
raise Exception("Invalid argument: %s. Use -SNAPSHOT or leave blank." % snapshot) | ||
|
||
if re.match(r'\d+\.\d+\.\d+', version) is None: | ||
raise Exception("Invalid version: %s. Use format x.y.z." % version) | ||
|
||
os.system( | ||
"git checkout main && git pull && git checkout -b releases/v_%s%s" % (version, snapshot) | ||
) | ||
main(version, snapshot) | ||
print("Version updated to %s%s" % (version, snapshot)) | ||
print("Please update the CHANGELOG.md and press ENTER to continue.") | ||
input() | ||
|
||
os.system("git add '../pom.xml'") | ||
os.system("git add '../python/mosaic/__init__.py'") | ||
os.system("git add '../R/sparkR-mosaic/sparkrMosaic/DESCRIPTION'") | ||
os.system("git add '../R/sparklyr-mosaic/sparklyrMosaic/DESCRIPTION'") | ||
|
||
os.system("git commit -m 'Update version to %s%s' && git push -u origin releases/v_%s%s" % (version, snapshot, version, snapshot)) |