Skip to content

Commit

Permalink
release.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yalov committed Dec 22, 2021
1 parent 2fa7c7d commit f92e73b
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions release.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/python3

"""requirements:
Python3.9
pip install pyperclip GitPython PyGithub
./release_spacedock_utils.py
./release_github.py
make sure, that ssh is set up
copy private key to ~/.ssh/
Public domain license.
https://github.com/yalov/SpeedUnitAnnex/blob/master/release.py
version: 21
version: 24
Script loads release-arhive to github and spacedock
you need to set values in the release.json
Expand All @@ -21,6 +24,15 @@
"""

import sys
def show_exception_and_exit(exc_type, exc_value, tb):
import traceback
traceback.print_exception(exc_type, exc_value, tb)
print("\n" + __doc__ + "\n")
input("Press key to exit.")
sys.exit(-1)

sys.excepthook = show_exception_and_exit

import json
import os.path
import re
Expand All @@ -33,6 +45,9 @@
from release_spacedock_utils import PublishToSpacedock





def archive_to(file):
"""Archive GameData and Extras to .zip"""
if os.path.exists(file):
Expand Down Expand Up @@ -74,6 +89,7 @@ def get_description(path):

if __name__ == '__main__':


jsn = json.load(open("release.json"))
tkn = json.load(open("release_token.json"))

Expand All @@ -91,6 +107,8 @@ def get_description(path):
TOKEN = tkn["GITHUB_TOKEN"]
SD_LOGIN = tkn["SPACEDOCK_LOGIN"]
SD_PASS = tkn["SPACEDOCK_PASS"]

is_published = False

if MODNAME == "auto":
# parent = os.path.basename([x for x in sys.path if x][0])
Expand Down Expand Up @@ -148,7 +166,7 @@ def get_description(path):
if input("[y/N]: ") == 'y':
resp = PublishToGithub(TOKEN, MODNAME, VERSION, LAST_CHANGE, DRAFT, PRERELEASE, ZIPFILE)
if resp == 1:
is_published=True
is_published = True

# ======================================

Expand All @@ -175,8 +193,12 @@ def get_description(path):
if KSP_VER not in all_versions:
print("KSP {} is not supported by Spacedock,\nlast supported version is KSP {}"
.format(KSP_VER, all_versions[0]))
input("Press Enter to exit")
sys.exit(-1)
print("Release with the last supported by Spacedock {} tag?".format(all_versions[0]))
if input("[y/N]: ") == 'y':
KSP_VER = all_versions[0]
else:
input("Press Enter to exit")
sys.exit(-1)

print("KSP {} is supported by Spacedock.".format(KSP_VER))

Expand All @@ -197,9 +219,9 @@ def get_description(path):
if input("[y/N]: ") == 'y':
resp = PublishToSpacedock(SD_ID, ZIPFILE, LAST_CHANGE, VERSION, KSP_VER, SD_LOGIN, SD_PASS)
if not 'error' in resp:
is_published=True
is_published = True

if FORUM_ID and 'is_published' in locals():
if FORUM_ID and is_published:
import webbrowser
webbrowser.open(f"https://forum.kerbalspaceprogram.com/index.php?/topic/{FORUM_ID}-*", new=2, autoraise=False)
print("The forum page is opened.")
Expand Down

0 comments on commit f92e73b

Please sign in to comment.