Permalink
Browse files

ISPN-2959 Improve the release scripts

- Only bump version if releasing a Final and also commit version bump on the branch being released
- Make some parts of the scripts less specialized so that it can be used for Infinispan Server
  • Loading branch information...
1 parent 508af24 commit f37c419fada92677f1a1231c0ca8bbf7929fd374 @tristantarrant tristantarrant committed with galderz Mar 22, 2013
Showing with 52 additions and 41 deletions.
  1. +44 −35 bin/release.py
  2. +8 −6 bin/utils.py
View
@@ -2,6 +2,7 @@
import re
import sys
import os
+import os.path
import subprocess
import shutil
from datetime import *
@@ -143,43 +144,44 @@ def update_versions(base_dir, version):
for pom in poms_to_patch:
if patch(pom, version):
modified_files.append(pom)
-
- ## Now look for Version.java
- version_java = "./core/src/main/java/org/infinispan/Version.java"
- modified_files.append(version_java)
-
- f_in = open(version_java)
- f_out = open(version_java+".tmp", "w")
-
- regexp = re.compile('\s*private static final (String (MAJOR|MINOR|MICRO|MODIFIER)|boolean SNAPSHOT)')
pieces = re.compile('[\.\-]').split(version)
snapshot = pieces[3]=='SNAPSHOT'
- try:
- for l in f_in:
- if regexp.match(l):
- if l.find('MAJOR') > -1:
- f_out.write(' private static final String MAJOR = "%s";\n' % pieces[0])
- elif l.find('MINOR') > -1:
- f_out.write(' private static final String MINOR = "%s";\n' % pieces[1])
- elif l.find('MICRO') > -1:
- f_out.write(' private static final String MICRO = "%s";\n' % pieces[2])
- elif l.find('MODIFIER') > -1:
- f_out.write(' private static final String MODIFIER = "%s";\n' % pieces[3])
- elif l.find('SNAPSHOT') > -1:
- f_out.write(' private static final boolean SNAPSHOT = %s;\n' % ('true' if snapshot else 'false'))
- else:
- f_out.write(l)
- finally:
- f_in.close()
- f_out.close()
-
- os.rename(version_java+".tmp", version_java)
+ final = pieces[3]=='Final'
+ ## Now look for Version.java
+ version_java = "./core/src/main/java/org/infinispan/Version.java"
+ if os.path.isfile(version_java):
+ modified_files.append(version_java)
+ f_in = open(version_java)
+ f_out = open(version_java+".tmp", "w")
+ regexp = re.compile('\s*private static final (String (MAJOR|MINOR|MICRO|MODIFIER)|boolean SNAPSHOT)')
+ try:
+ for l in f_in:
+ if regexp.match(l):
+ if l.find('MAJOR') > -1:
+ f_out.write(' private static final String MAJOR = "%s";\n' % pieces[0])
+ elif l.find('MINOR') > -1:
+ f_out.write(' private static final String MINOR = "%s";\n' % pieces[1])
+ elif l.find('MICRO') > -1:
+ f_out.write(' private static final String MICRO = "%s";\n' % pieces[2])
+ elif l.find('MODIFIER') > -1:
+ f_out.write(' private static final String MODIFIER = "%s";\n' % pieces[3])
+ elif l.find('SNAPSHOT') > -1:
+ f_out.write(' private static final boolean SNAPSHOT = %s;\n' % ('true' if snapshot else 'false'))
+ else:
+ f_out.write(l)
+ finally:
+ f_in.close()
+ f_out.close()
+ os.rename(version_java+".tmp", version_java)
# Now make sure this goes back into the repository.
git.commit(modified_files, "'Release Script: update versions for %s'" % version)
# And return the next version
- return pieces[0] + '.' + pieces[1] + '.' + str(int(pieces[2])+1) + ('.Final' if snapshot else '-SNAPSHOT')
+ if final:
+ return pieces[0] + '.' + pieces[1] + '.' + str(int(pieces[2])+ 1) + '-SNAPSHOT'
+ else:
+ return None
def get_module_name(pom_file):
tree = ElementTree()
@@ -246,7 +248,7 @@ def upload_configdocs(base_dir, version):
os.rename("configdocs", "%s/configdocs" % version_short)
## rsync this stuff to filemgmt.jboss.org
- uploader.upload_rsync(version_short, "infinispan@filemgmt.jboss.org:/docs_htdocs/infinispan")
+ uploader.upload_rsync(version_short, "infinispan@filemgmt.jboss.org:/docs_htdocs/infinispan")
os.chdir(base_dir)
def do_task(target, args, async_processes):
@@ -350,13 +352,19 @@ def release():
## Tag the release
git.tag_for_release()
+ # Switch back to the branch being released
+ git.switch_to_branch()
+
# Update to next version
- prettyprint("Step 9: Updating version number for next release", Levels.INFO)
- update_versions(base_dir, version_next)
- prettyprint("Step 9: Complete", Levels.INFO)
+ if version_next is not None:
+ prettyprint("Step 9: Updating version number for next release", Levels.INFO)
+ update_versions(base_dir, version_next)
+ prettyprint("Step 9: Complete", Levels.INFO)
if not settings['dry_run']:
- git.push_to_origin()
+ git.push_tag_to_origin()
+ if version_next is not None:
+ git.push_branch_to_origin()
git.cleanup()
else:
prettyprint("In dry-run mode. Not pushing tag to remote origin and not removing temp release branch %s." % git.working_branch, Levels.DEBUG)
@@ -365,3 +373,4 @@ def release():
if __name__ == "__main__":
release()
+
View
@@ -7,10 +7,8 @@
import shutil
import random
settings_file = '%s/.infinispan_dev_settings' % os.getenv('HOME')
-
+upstream_url = 'git@github.com:infinispan/infinispan.git'
### Known config keys
-svn_base_key = "svn_base"
-local_tags_dir_key = "local_tags_dir"
local_mvn_repo_dir_key = "local_mvn_repo_dir"
maven_pom_xml_namespace = "http://maven.apache.org/POM/4.0.0"
default_settings = {'dry_run': False, 'multi_threaded': False, 'verbose': False, 'use_colors': True}
@@ -25,7 +23,7 @@ class Colors(object):
END = '\033[0m'
UNDERLINE = '\033[4m'
- @staticmethod
+ @staticmethod
def magenta():
if use_colors():
return Colors.MAGENTA
@@ -273,7 +271,7 @@ def is_upstream_clone(self):
def push(e): return e.startswith('PushURL:')
def remove_noise(e): return e.replace('PushURL:', '')
push_urls = map(remove_noise, filter(push, cleaned))
- return len(push_urls) == 1 and push_urls[0] == 'git@github.com:infinispan/infinispan.git'
+ return len(push_urls) == 1 and push_urls[0] == upstream_url
def clean_branches(self, raw_branch_list):
return map(self.clean, filter(self.non_empty, raw_branch_list))
@@ -307,9 +305,13 @@ def tag_for_release(self):
'''Tags the current branch for release using the tag name.'''
self.run_git(["tag", "-a", "-m", "'Release Script: tag %s'" % self.tag, self.tag])
- def push_to_origin(self):
+ def push_tag_to_origin(self):
'''Pushes the updated tags to origin'''
self.run_git("push origin --tags")
+
+ def push_branch_to_origin(self):
+ '''Pushes the updated branch to origin'''
+ self.run_git("push origin %s" % (self.branch))
def current_branch(self):
'''Returns the current branch you are on'''

0 comments on commit f37c419

Please sign in to comment.