2 #####################################################################
3 # Helper script to release
4 #####################################################################
14 # Helper Script to release WebKit. #
16 Usage: release-webkit [OPTIONS]
19 -h, --help : Print this message.
20 -n, --dry-run : Don't actually run any commands; just print them.
21 -c, --create-commit : (devel/webkit/upversion branch) Create Release commit and push to gerrit.
22 If you want to release by latest commit, please 'git pull' before execute this command.
23 -r, --merge-release : (w/master branch) Merge release commit and push to gerrit.
32 def openFile(fileName, mode):
33 return open(fileName, mode)
35 def closeFile(filePtr):
39 if "TizenScripts" in os.getcwd():
44 findFirstCommit = False
46 maxCommitCount = "500"
48 os.system("git log -n " + maxCommitCount + " > logForCheckNewPatch")
49 logForCheckNewPatch = openFile("logForCheckNewPatch", "r")
50 for line in logForCheckNewPatch:
55 findFirstCommit = True
58 if "[Release] Webkit" in line:
61 closeFile(logForCheckNewPatch)
62 os.system("rm logForCheckNewPatch")
65 print "There is no new patch after previous release."
68 def updatePatchVersion(revision, major, minor, issue):
71 currentSpec = openFile(path + "packaging/webkit2-efl.spec","r")
72 modifiedSpec = openFile("modifiedSpec","w")
74 for line in currentSpec:
75 if "Version:" in line:
76 Version = line.split(".");
77 patchVersion = str(int(Version[2]) + 1)
79 changedLine = "Version: " + revision + "_" + major + "." + minor + "." + patchVersion + "." + issue + "\n"
80 modifiedSpec.write(changedLine)
81 print "Modified Version in webkit2-efl.spec to " + major + "." + minor + "." + patchVersion.strip() + "." + issue
82 elif "-DPROJECT_VERSION=" in line:
83 modifiedSpec.write(" -DPROJECT_VERSION=" + revision + "_" + major + "." + minor + "." + patchVersion + "." + issue + " \\" + "\n")
85 modifiedSpec.write(line)
87 closeFile(currentSpec)
88 closeFile(modifiedSpec)
91 os.system("rm modifiedSpec")
93 os.system("chmod 644 modifiedSpec")
94 os.system("mv modifiedSpec " + path + "packaging/webkit2-efl.spec")
96 execute("git add " + path + "packaging/webkit2-efl.spec" )
100 def getReleaseCommitId(branch):
101 maxCommitCount = "500"
103 os.system("git log -n " + maxCommitCount + " " + branch + " > currentLog")
104 currentLog = openFile("currentLog", "r")
106 for line in currentLog:
108 commitId = line.replace("commit ","").strip()
109 elif line.find("[Release] Webkit2-efl") == 4:
112 closeFile(currentLog)
113 os.system("rm currentLog")
114 os.system("git log " + commitId + " > patchLog")
118 def createReleaseCommit():
119 branchName = "devel/webkit/upversion"
125 execute("git checkout " + branchName)
127 patchVersion = updatePatchVersion(revision, majorVersion, minorVersion, issueVersion)
128 execute("git commit -m '[Release] Webkit2-efl-" + revision + "_" + majorVersion + "." + minorVersion + "." + patchVersion + "." + issueVersion + "\n[Branch] " + branchName + "'" )
129 execute("git push origin HEAD:refs/for/" + branchName)
131 print "[Creating release commit] finished."
133 def mergeRelaseCommit():
134 branchName = "w/master"
136 execute("git checkout " + branchName)
137 execute("git pull --rebase")
138 releaseCommitId = getReleaseCommitId("devel/webkit/upversion")
139 execute("git merge -m 'Merge commit \'" + releaseCommitId + "\' into " + branchName + "' " + releaseCommitId)
140 execute("git commit --amend -m 'Merge commit \'" + releaseCommitId + "\' into " + branchName + "'")
141 execute("git push origin HEAD:refs/for/" + branchName)
143 print "[Package release] finished."
147 enableCreateCommit = False
148 enableRelease = False
150 optlist, args = getopt.getopt(sys.argv[1:], 'hncrm:o', [ 'help', 'dry-run', 'create-commit', 'merge-release'])
151 for opt, var in optlist:
152 if opt in ('--help', '-h'):
155 if opt in ('--dry-run', '-n'):
157 if opt in ('--create-commit', '-c'):
158 enableCreateCommit = True
159 if opt in ('--merge-release', '-r'):
162 if enableCreateCommit and enableRelease:
163 print "ERROR : This options are can't executed simultaneously"
166 if enableCreateCommit:
167 createReleaseCommit()