Skip to content

Commit

Permalink
Merge pull request #137 from mvdwetering/update_release_script
Browse files Browse the repository at this point in the history
Misc fixes for release script, check cmd line output, fix numbering f…
  • Loading branch information
mvdwetering authored Nov 25, 2024
2 parents 3649e13 + 46c7485 commit 7728c6b
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,39 @@ def workarea_is_clean() -> bool:

@staticmethod
def checkout(branch):
subprocess.run(["git", "checkout", branch])
subprocess.run(["git", "checkout", branch], check=True)

@staticmethod
def add_changes():
subprocess.run(["git", "add", "--all"])
subprocess.run(["git", "add", "--all"], check=True)

@staticmethod
def commit_changes(message):
subprocess.run(["git", "commit", "-m", message])
subprocess.run(["git", "commit", "-m", message], check=True)

@staticmethod
def pull():
subprocess.run(["git", "pull"])
subprocess.run(["git", "pull"], check=True)

@staticmethod
def delete_branch(name):
subprocess.run(["git", "branch", "-D", name])
subprocess.run(["git", "branch", "-D", name], check=True)

@staticmethod
def create_branch(name):
subprocess.run(["git", "branch", name])
subprocess.run(["git", "branch", name], check=True)

@staticmethod
def create_tag(name):
subprocess.run(["git", "tag", name])
subprocess.run(["git", "tag", name], check=True)

@staticmethod
def push_to_origin(name):
subprocess.run(["git", "push", "origin", name])
subprocess.run(["git", "push", "origin", name], check=True)

@staticmethod
def fetch_tags():
subprocess.run(["git", "fetch", "--tags"])

subprocess.run(["git", "fetch", "--tags"], check=True)

def menu(title, choices):
while True:
Expand Down Expand Up @@ -287,8 +286,7 @@ def main(args):
)

# Changing from alpha to beta should bump the version before release
version_diff = next_manifest_version - manifest_version
if version_diff.modifier:
if manifest_version.alpha and next_manifest_version.beta:
next_version = next_manifest_version
else:
next_version = manifest_version
Expand Down Expand Up @@ -323,8 +321,7 @@ def main(args):
Git.commit_changes(f"Update version to {next_version}")

if not next_version.modifier:
# Merge to master, ideally this would be done with a PR
# but I don't know how to specify the merge strategy
# Merge to master
Git.checkout(MASTER)
Git.pull()
subprocess.run(
Expand All @@ -337,7 +334,8 @@ def main(args):
"theirs",
"-m",
f"Release v{next_version}",
]
],
check=True,
)

Git.create_tag(tag_name)
Expand All @@ -349,14 +347,13 @@ def main(args):
Git.commit_changes(f"Update version to {bump_version_after_release}")

if input("Push to origin? [Y/n]: ") != "n":
if Git.get_current_branch().name == MASTER:
if Git.get_current_branch() == MASTER:
Git.push_to_origin(MASTER)
Git.push_to_origin(release_branch_name)
Git.push_to_origin(tag_name)
else:
print("Don't forget to push later or revert changes!")


print("Done!")
print(f"Currently on branch: {Git.get_current_branch().name}")

Expand Down

0 comments on commit 7728c6b

Please sign in to comment.