Skip to content

Commit

Permalink
release.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yalov committed Jul 19, 2020
1 parent b5e0793 commit 42941cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
17 changes: 13 additions & 4 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
5 changes: 3 additions & 2 deletions release_spacedock_utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 42941cb

Please sign in to comment.