patch.py now includes the jar hash

This commit is contained in:
cyian-1756 2018-05-28 18:46:35 -04:00
parent 70716ed577
commit 2e4acab09a

View File

@ -1,19 +1,40 @@
import json import json
import subprocess import subprocess
from hashlib import sha256
# This script will: # This script will:
# - read current version # - read current version
# - increment patch version # - increment patch version
# - update version in a few places # - update version in a few places
# - insert new line in ripme.json with message # - insert new line in ripme.json with message
# - build ripme
# - add the hash of the lastest binary to ripme.json
message = input('message: ') message = input('message: ')
with open('ripme.json') as dataFile: def get_ripme_json():
with open('ripme.json') as dataFile:
ripmeJson = json.load(dataFile) ripmeJson = json.load(dataFile)
currentVersion = ripmeJson["latestVersion"] return ripmeJson
print ('Current version ' + currentVersion) def update_hash(current_hash):
ripmeJson = get_ripme_json()
with open('ripme.json', 'w') as dataFile:
ripmeJson["currentHash"] = current_hash
print(ripmeJson["currentHash"])
json.dump(ripmeJson, dataFile, indent=4)
def update_change_list(message):
ripmeJson = get_ripme_json()
with open('ripme.json', 'w') as dataFile:
ripmeJson["changeList"] = ripmeJson["changeList"].insert(0, message)
print(ripmeJson["currentHash"])
json.dump(ripmeJson, dataFile, indent=4)
currentVersion = get_ripme_json()["latestVersion"]
print('Current version ' + currentVersion)
versionFields = currentVersion.split('.') versionFields = currentVersion.split('.')
patchCur = int(versionFields[2]) patchCur = int(versionFields[2])
@ -22,14 +43,14 @@ majorMinor = versionFields[:2]
majorMinor.append(str(patchNext)) majorMinor.append(str(patchNext))
nextVersion = '.'.join(majorMinor) nextVersion = '.'.join(majorMinor)
print ('Updating to ' + nextVersion) print('Updating to ' + nextVersion)
substrExpr = 's/' + currentVersion + '/' + nextVersion + '/' substrExpr = 's/' + currentVersion + '/' + nextVersion + '/'
subprocess.call(['sed', '-i', '-e', substrExpr, 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java']) subprocess.call(['sed', '-i', '-e', substrExpr, 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java'])
subprocess.call(['git', 'grep', 'DEFAULT_VERSION.*' + nextVersion, subprocess.call(['git', 'grep', 'DEFAULT_VERSION.*' + nextVersion,
'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java']) 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java'])
substrExpr = 's/\\\"latestVersion\\\": \\\"' + currentVersion + '\\\"/\\\"latestVersion\\\": \\\"' +\ substrExpr = 's/\\\"latestVersion\\\": \\\"' + currentVersion + '\\\"/\\\"latestVersion\\\": \\\"' + \
nextVersion + '\\\"/' nextVersion + '\\\"/'
subprocess.call(['sed', '-i', '-e', substrExpr, 'ripme.json']) subprocess.call(['sed', '-i', '-e', substrExpr, 'ripme.json'])
subprocess.call(['git', 'grep', 'latestVersion', 'ripme.json']) subprocess.call(['git', 'grep', 'latestVersion', 'ripme.json'])
@ -51,6 +72,15 @@ dataFile = open("ripme.json", "w")
dataFile.write(outputContent) dataFile.write(outputContent)
dataFile.close() dataFile.close()
subprocess.call(['git', 'add', '-u']) # subprocess.call(['git', 'add', '-u'])
subprocess.call(['git', 'commit', '-m', commitMessage]) # subprocess.call(['git', 'commit', '-m', commitMessage])
subprocess.call(['git', 'tag', nextVersion]) # subprocess.call(['git', 'tag', nextVersion])
print("Building ripme")
subprocess.call(["mvn", "clean", "compile", "assembly:single"])
print("Hashing .jar file")
openedFile = open("./target/ripme-{}-jar-with-dependencies.jar".format(nextVersion), "rb")
readFile = openedFile.read()
file_hash = sha256(readFile).hexdigest()
print("Hash is: {}".format(file_hash))
print("Updating hash")
update_hash(file_hash)