release script now makes sure update file is named ripme.jar; added --test option for dry runs

This commit is contained in:
cyian-1756 2018-06-11 09:22:44 -04:00
parent b12821f8cc
commit 7d20b3927d
2 changed files with 24 additions and 10 deletions

View File

@ -15,9 +15,11 @@ parser.add_argument("-f", "--file", help="Path to the version of ripme to releas
parser.add_argument("-t", "--token", help="Your github personal access token")
parser.add_argument("-d", "--debug", help="Run in debug mode", action="store_true")
parser.add_argument("-n", "--non-interactive", help="Do not ask for any input from the user", action="store_true")
parser.add_argument("--test", help="Perform a dry run", action="store_true")
args = parser.parse_args()
try:
# This binds input to raw_input on python2, we do this because input acts like eval on python2
input = raw_input
except NameError:
pass
@ -38,9 +40,20 @@ def isValidCommitMessage(message):
pattern = re.compile("^\d+\.\d+\.\d+:")
return re.match(pattern, message)
# Checks if the update has the name ripme.jar, if not it renames the file
# Returns the update file path
def renameFile(path):
if not path.endswith("ripme.jar"):
print("Specified file is not named ripme.jar, renaming")
# os.sep is the path separator for the os this is being run on
os.rename(path, path.split(os.sep)[0] + os.sep + "ripme.jar")
return path.split(os.sep)[0] + os.sep + "ripme.jar"
return path
ripmeJson = json.loads(open("ripme.json").read())
fileToUploadPath = args.file
fileToUploadPath = renameFile(args.file)
InNoninteractiveMode = args.non_interactive
commitMessage = ripmeJson.get("changeList")[0]
releaseVersion = ripmeJson.get("latestVersion")
@ -63,11 +76,12 @@ if not isValidCommitMessage(commitMessage):
ripmeUpdate = open(fileToUploadPath, mode='rb').read()
# The actual hash of the file on disk
actualHash = sha256(ripmeUpdate).hexdigest()
# The hash that we expect the update to have
expectedHash = ripmeJson.get("currentHash")
# The actual hash of the file on disk
actualHash = sha256(ripmeUpdate).hexdigest()
# Make sure that the hash of the file we're uploading matches the hash in ripme.json. These hashes not matching will
# cause ripme to refuse to install the update for all users who haven't disabled update hash checking
@ -85,12 +99,12 @@ if not InNoninteractiveMode:
print("Repo: {}/{}".format(repoOwner, repoName))
input("\nPlease review the information above and ensure it is correct and then press enter")
print("Accessing github using token")
g = Github(accessToken)
if args.test:
print("Accessing github using token")
g = Github(accessToken)
print("Creating release")
release = g.get_user(repoOwner).get_repo(repoName).create_git_release(releaseVersion, commitMessage, "")
print("Creating release")
release = g.get_user(repoOwner).get_repo(repoName).create_git_release(releaseVersion, commitMessage, "")
print("Uploading file")
release.upload_asset(fileToUploadPath, "ripme.jar")
print("Uploading file")
release.upload_asset(fileToUploadPath, "ripme.jar")

0
releaseTests.py Normal file
View File