-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1084bcb
commit 347831a
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# updates the version number in the __about__.py file | ||
import subprocess | ||
|
||
|
||
def update_version(version_type): | ||
with open("src/api/__about__.py", "r") as f: | ||
version = f.read().split("=")[1].replace('"', "").strip() | ||
patch_version = version.split(".")[2] | ||
minor_version = version.split(".")[1] | ||
major_version = version.split(".")[0] | ||
if version_type == "major": | ||
major_version = str(int(major_version) + 1) | ||
minor_version = "0" | ||
patch_version = "0" | ||
elif version_type == "minor": | ||
minor_version = str(int(minor_version) + 1) | ||
patch_version = "0" | ||
elif version_type == "patch": | ||
patch_version = str(int(patch_version) + 1) | ||
else: | ||
raise ValueError("Invalid version type. Please use major, minor, or patch.") | ||
with open("src/api/__about__.py", "w") as f: | ||
new_version = f"{major_version}.{minor_version}.{patch_version}" | ||
f.write(f'__version__ = "{new_version}"\n') | ||
return f"v{new_version}" | ||
|
||
|
||
# passes the command line argument to the function | ||
if __name__ == "__main__": | ||
import sys | ||
|
||
new_version = update_version(sys.argv[1]) | ||
message = input(f"Version updated to {new_version}. Enter commit message: \n") | ||
subprocess.run(["git", "add", "."]) | ||
subprocess.run(["git", "commit", "-m", message.strip()]) | ||
subprocess.run(["git", "push"]) | ||
subprocess.run(["git", "tag", "-a", new_version, "-m", new_version]) | ||
subprocess.run(["git", "push", "origin", new_version]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.0.3" | ||
__version__ = "1.0.4" |