From 42941cbb7e1e2e86908231030fa5183e9c5bd25b Mon Sep 17 00:00:00 2001 From: Alexander Yalov Date: Sun, 19 Jul 2020 18:55:07 +0300 Subject: [PATCH] release.py --- release.py | 17 +++++++++++++---- release_spacedock_utils.py | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/release.py b/release.py index 7ee3bc9..a606e18 100644 --- a/release.py +++ b/release.py @@ -6,7 +6,7 @@ copy private key to ~/.ssh/ Public domain license. -author: flart, version: 14 +author: flart, version: 15 https://github.com/yalov/SpeedUnitAnnex/blob/master/release.py Script loads release-arhive to github and spacedock @@ -60,13 +60,17 @@ def archive_to(file): len(zipf.infolist()), os.path.getsize(file))) -def get_version(version_file, obj="VERSION"): +def get_version(version_file, obj="VERSION", ignore_patch = False): """ get version from the version_file """ data = json.load(open(version_file)) if obj not in data: return "NO" ver = data[obj] + if ignore_patch: + return "{}.{}".format(ver["MAJOR"], ver["MINOR"]) + version = "{}.{}.{}".format(ver["MAJOR"], ver["MINOR"], ver["PATCH"]) + if "BUILD" in ver and ver["BUILD"] != 0: version += '.' + str(ver["BUILD"]) return version @@ -233,8 +237,13 @@ def publish_to_github(token, mod_name, version, last_change, is_draft, is_prerel 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("trying to ignore the patch... ") + KSP_VER = get_version(VERSIONFILE, "KSP_VERSION", True) + 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("KSP {} is supported by Spacedock.".format(KSP_VER)) diff --git a/release_spacedock_utils.py b/release_spacedock_utils.py index 5627d4f..bc199e7 100644 --- a/release_spacedock_utils.py +++ b/release_spacedock_utils.py @@ -1,7 +1,7 @@ """utils for accessing to the spacedock""" # Public domain license. # Based on: https://github.com/ihsoft/KSPDev_ReleaseBuilder -# $version: 2 +# $version: 3 # -*- coding: utf-8 -*- import json @@ -21,7 +21,8 @@ # The actions paths. API_AUTHORIZE = '/api/login' API_UPDATE_MOD_TMPL = '/api/mod/{mod_id}/update' -API_GET_VERSIONS = '/api/kspversions' +# API_GET_VERSIONS = '/api/kspversions' +API_GET_VERSIONS = '/api/3102/versions' API_GET_MOD = '/api/mod/{mod_id}' # The authorization cookie. It's only created once. To refresh it, simply