CI Changes
This commit is contained in:
committed by
aerinon
parent
54858500e5
commit
ca40f87daa
0
resources/app/meta/manifests/app_version.txt
Normal file
0
resources/app/meta/manifests/app_version.txt
Normal file
7
resources/app/meta/manifests/binaries.json
Normal file
7
resources/app/meta/manifests/binaries.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
"DungeonRandomizer",
|
||||
"Gui",
|
||||
"MultiClient",
|
||||
"MultiServer",
|
||||
"Mystery"
|
||||
]
|
||||
34
resources/app/meta/manifests/excluded_dlls.json
Normal file
34
resources/app/meta/manifests/excluded_dlls.json
Normal file
@@ -0,0 +1,34 @@
|
||||
[
|
||||
"conio",
|
||||
"console",
|
||||
"convert",
|
||||
"datetime",
|
||||
"debug",
|
||||
"environment",
|
||||
"errorhandling",
|
||||
"file",
|
||||
"filesystem",
|
||||
"handle",
|
||||
"heap",
|
||||
"interlocked",
|
||||
"libraryloader",
|
||||
"locale",
|
||||
"localization",
|
||||
"math",
|
||||
"memory",
|
||||
"namedpipe",
|
||||
"process",
|
||||
"processenvironment",
|
||||
"processthreads",
|
||||
"profile",
|
||||
"rtlsupport",
|
||||
"runtime",
|
||||
"stdio",
|
||||
"string",
|
||||
"synch",
|
||||
"sysinfo",
|
||||
"time",
|
||||
"timezone",
|
||||
"util",
|
||||
"utility"
|
||||
]
|
||||
@@ -1,7 +1,8 @@
|
||||
aenum
|
||||
aioconsole
|
||||
colorama
|
||||
distro
|
||||
fast-enum
|
||||
python-bps-continued
|
||||
colorama
|
||||
aioconsole
|
||||
pyyaml
|
||||
websockets
|
||||
pyyaml
|
||||
@@ -1,6 +1,11 @@
|
||||
import os # for env vars
|
||||
import stat # file statistics
|
||||
import sys # default system info
|
||||
try:
|
||||
import distro
|
||||
except ModuleNotFoundError as e:
|
||||
pass
|
||||
|
||||
from my_path import get_py_path
|
||||
|
||||
global UBUNTU_VERSIONS
|
||||
@@ -8,15 +13,20 @@ global DEFAULT_EVENT
|
||||
global DEFAULT_REPO_SLUG
|
||||
global FILENAME_CHECKS
|
||||
global FILESIZE_CHECK
|
||||
UBUNTU_VERSIONS = {
|
||||
"latest": "focal",
|
||||
"20.04": "focal",
|
||||
"18.04": "bionic",
|
||||
"16.04": "xenial"
|
||||
}
|
||||
# GitHub Hosted Runners
|
||||
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
||||
# ubuntu: 22.04, 20.04
|
||||
# windows: 2022, 2019
|
||||
# macos: 14, 13, 12, 11
|
||||
DEFAULT_EVENT = "event"
|
||||
DEFAULT_REPO_SLUG = "miketrethewey/ALttPDoorRandomizer"
|
||||
FILENAME_CHECKS = [ "Gui", "DungeonRandomizer" ]
|
||||
FILENAME_CHECKS = [
|
||||
"DungeonRandomizer",
|
||||
"Gui",
|
||||
"MultiClient",
|
||||
"MultiServer",
|
||||
"Mystery"
|
||||
]
|
||||
FILESIZE_CHECK = (6 * 1024 * 1024) # 6MB
|
||||
|
||||
# take number of bytes and convert to string with units measure
|
||||
@@ -38,12 +48,19 @@ def prepare_env():
|
||||
global DEFAULT_REPO_SLUG
|
||||
env = {}
|
||||
|
||||
# get app version
|
||||
# get app version
|
||||
APP_VERSION = ""
|
||||
APP_VERSION_FILE = os.path.join(".","resources","app","meta","manifests","app_version.txt")
|
||||
if os.path.isfile(APP_VERSION_FILE):
|
||||
with open(APP_VERSION_FILE,"r") as f:
|
||||
APP_VERSION = f.readlines()[0].strip()
|
||||
APP_VERSION_FILES = [
|
||||
os.path.join(".","resources","app","meta","manifests","app_version.txt"),
|
||||
os.path.join("..","build","app_version.txt")
|
||||
]
|
||||
for app_version_file in APP_VERSION_FILES:
|
||||
if os.path.isfile(app_version_file):
|
||||
with open(app_version_file,"r") as f:
|
||||
lines = f.readlines()
|
||||
if len(lines) > 0:
|
||||
APP_VERSION = lines[0].strip()
|
||||
|
||||
# ci data
|
||||
env["CI_SYSTEM"] = os.getenv("CI_SYSTEM","")
|
||||
# py data
|
||||
@@ -96,9 +113,11 @@ def prepare_env():
|
||||
OS_VERSION = OS_NAME[OS_NAME.find('-')+1:]
|
||||
OS_NAME = OS_NAME[:OS_NAME.find('-')]
|
||||
if OS_NAME == "linux" or OS_NAME == "ubuntu":
|
||||
if OS_VERSION in UBUNTU_VERSIONS:
|
||||
OS_VERSION = UBUNTU_VERSIONS[OS_VERSION]
|
||||
OS_DIST = OS_VERSION
|
||||
try:
|
||||
if distro.codename() != "":
|
||||
OS_DIST = distro.codename()
|
||||
except NameError as e:
|
||||
pass
|
||||
|
||||
if OS_VERSION == "" and not OS_DIST == "" and not OS_DIST == "notset":
|
||||
OS_VERSION = OS_DIST
|
||||
@@ -111,7 +130,7 @@ def prepare_env():
|
||||
# if the app version didn't have the build number, add it
|
||||
# set to <app_version>.<build_number>
|
||||
if env["BUILD_NUMBER"] not in GITHUB_TAG:
|
||||
GITHUB_TAG += '.' + env["BUILD_NUMBER"]
|
||||
GITHUB_TAG += ".r" + env["BUILD_NUMBER"]
|
||||
|
||||
env["GITHUB_TAG"] = GITHUB_TAG
|
||||
env["OS_NAME"] = OS_NAME
|
||||
|
||||
@@ -10,7 +10,7 @@ def get_get_pip(PY_VERSION):
|
||||
try:
|
||||
import pip
|
||||
except ImportError:
|
||||
print("Getting pip getter!")
|
||||
print("🟡Getting pip getter!")
|
||||
#make the request!
|
||||
url = "https://bootstrap.pypa.io/get-pip.py"
|
||||
context = ssl._create_unverified_context()
|
||||
@@ -40,7 +40,7 @@ def get_get_pip(PY_VERSION):
|
||||
if float(PY_VERSION) > 0:
|
||||
PYTHON_EXECUTABLE = "py"
|
||||
|
||||
print("Getting pip!")
|
||||
print("🟡Getting pip!")
|
||||
args = [
|
||||
env["PYTHON_EXE_PATH"] + PYTHON_EXECUTABLE,
|
||||
'-' + str(PY_VERSION),
|
||||
@@ -58,6 +58,6 @@ if __name__ == "__main__":
|
||||
|
||||
try:
|
||||
import pip
|
||||
print("pip is installed")
|
||||
print("🟢pip is installed")
|
||||
except ImportError:
|
||||
get_get_pip(PY_VERSION)
|
||||
|
||||
440
resources/ci/common/get_pipline.py
Normal file
440
resources/ci/common/get_pipline.py
Normal file
@@ -0,0 +1,440 @@
|
||||
# import modules
|
||||
import common # app common functions
|
||||
|
||||
import json # json manipulation
|
||||
import os # for os data, filesystem manipulation
|
||||
import subprocess # for running shell commands
|
||||
import sys # for system commands
|
||||
import traceback # for errors
|
||||
|
||||
# get env
|
||||
env = common.prepare_env() # get environment variables
|
||||
|
||||
# width for labels
|
||||
WIDTH = 70
|
||||
|
||||
# bucket for cli args
|
||||
args = []
|
||||
|
||||
# pip exe path
|
||||
PIPEXE = ""
|
||||
|
||||
# py exe path
|
||||
# py version
|
||||
# py minor version
|
||||
PYTHON_EXECUTABLE = os.path.splitext(sys.executable.split(os.path.sep).pop())[0] # get command to run python
|
||||
PYTHON_VERSION = sys.version.split(" ")[0]
|
||||
PYTHON_MINOR_VERSION = '.'.join(PYTHON_VERSION.split(".")[:2])
|
||||
|
||||
# pip string version
|
||||
# pip float version
|
||||
PIP_VERSION = ""
|
||||
PIP_FLOAT_VERSION = 0
|
||||
|
||||
# success
|
||||
SUCCESS = False
|
||||
# bucket for versions
|
||||
VERSIONS = {}
|
||||
|
||||
# process module output
|
||||
# read output from installing
|
||||
# print relevant info
|
||||
# print unknown stuff
|
||||
def process_module_output(lines):
|
||||
for line in lines:
|
||||
# if there's an error, print it and bail
|
||||
if "status 'error'" in line.strip():
|
||||
print(
|
||||
"🔴[%s] %s"
|
||||
%
|
||||
(
|
||||
"_",
|
||||
line.strip()
|
||||
)
|
||||
)
|
||||
return
|
||||
# sys.exit(1)
|
||||
# if it's already satisfied or building a wheel, print version data
|
||||
elif "already satisfied" in line or \
|
||||
"Building wheel" in line or \
|
||||
"Created wheel" in line:
|
||||
|
||||
modulename = print_module_line(line)
|
||||
|
||||
if "=" not in modulename and VERSIONS[modulename]["installed"] != VERSIONS[modulename]["latest"]:
|
||||
# install modules from list
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
"--upgrade",
|
||||
f"{modulename}"
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
# if there's output
|
||||
if ret.stdout.strip():
|
||||
process_module_output(ret.stdout.strip().split("\n"))
|
||||
|
||||
# ignore lines about certain things
|
||||
elif "Attempting uninstall" in line or \
|
||||
"Collecting" in line or \
|
||||
"Downloading" in line or \
|
||||
"eta 0:00:00" in line or \
|
||||
"Found existing" in line or \
|
||||
"Installing collected" in line or \
|
||||
"Preparing metadata" in line or \
|
||||
"Successfully built" in line or \
|
||||
"Successfully installed" in line or \
|
||||
"Successfully uninstalled" in line or \
|
||||
"Stored in" in line or \
|
||||
"Uninstalling " in line or \
|
||||
"Using cached" in line:
|
||||
pass
|
||||
# else, I don't know what it is, print it
|
||||
else:
|
||||
print(line.strip())
|
||||
print("")
|
||||
|
||||
# print module line
|
||||
# name, installed version, latest version
|
||||
def print_module_line(line):
|
||||
global VERSIONS
|
||||
# is it already installed?
|
||||
satisfied = line.strip().split(" in ")
|
||||
# get the installed version
|
||||
sver = ((len(satisfied) > 1) and satisfied[1].split("(").pop().replace(")", "")) or ""
|
||||
|
||||
# if we're making a wheel
|
||||
if "Created wheel" in line:
|
||||
line = line.strip().split(':')
|
||||
satisfied = [line[0]]
|
||||
sver = line[1].split('-')[1]
|
||||
|
||||
# get module name
|
||||
modulename = satisfied[0].replace("Requirement already satisfied: ", "")
|
||||
# save info for later use
|
||||
VERSIONS[modulename] = {
|
||||
"installed": sver,
|
||||
"latest": (sver and get_module_version(satisfied[0].split(" ")[-1])).strip() or ""
|
||||
}
|
||||
|
||||
# print what we found
|
||||
print(
|
||||
(
|
||||
"[%s] %s\t%s\t%s"
|
||||
%
|
||||
(
|
||||
"Building wheel" in line and '.' or "X",
|
||||
satisfied[0].ljust(len("Requirement already satisfied: ") + len("python-bps-continued")),
|
||||
VERSIONS[modulename]["installed"],
|
||||
VERSIONS[modulename]["latest"]
|
||||
)
|
||||
)
|
||||
)
|
||||
# return the name of this module
|
||||
return modulename
|
||||
|
||||
# get module version
|
||||
# get installed version
|
||||
def get_module_version(module):
|
||||
# pip index versions [module] // >= 21.2
|
||||
# pip install [module]== // >= 21.1
|
||||
# pip install --use-deprecated=legacy-resolver [module]== // >= 20.3
|
||||
# pip install [module]== // >= 9.0
|
||||
# pip install [module]==blork // < 9.0
|
||||
global args
|
||||
global PIPEXE
|
||||
global PIP_FLOAT_VERSION
|
||||
ret = ""
|
||||
ver = ""
|
||||
|
||||
# based on version of pip, get the installation status of a module
|
||||
if float(PIP_FLOAT_VERSION) >= 21.2:
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"index",
|
||||
"versions",
|
||||
module
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
lines = ret.stdout.strip().split("\n")
|
||||
lines = lines[2::]
|
||||
vers = (list(map(lambda x: x.split(' ')[-1], lines)))
|
||||
if len(vers) > 1:
|
||||
ver = vers[1]
|
||||
elif float(PIP_FLOAT_VERSION) >= 21.1:
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
f"{module}=="
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
elif float(PIP_FLOAT_VERSION) >= 20.3:
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
"--use-deprecated=legacy-resolver",
|
||||
f"{module}=="
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
elif float(PIP_FLOAT_VERSION) >= 9.0:
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
f"{module}=="
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
elif float(PIP_FLOAT_VERSION) < 9.0:
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
f"{module}==blork"
|
||||
],
|
||||
capture_output=True,
|
||||
ext=True
|
||||
)
|
||||
|
||||
# if ver == "" and ret.stderr.strip():
|
||||
# ver = (ret.stderr.strip().split("\n")[0].split(",")[-1].replace(')', '')).strip()
|
||||
|
||||
# return what we found
|
||||
return ver
|
||||
|
||||
# get python info
|
||||
def python_info():
|
||||
global args
|
||||
global PYTHON_VERSION
|
||||
|
||||
# get python debug info
|
||||
ret = subprocess.run([*args, "--version"], capture_output=True, text=True)
|
||||
if ret.stdout.strip():
|
||||
PYTHON_VERSION = ret.stdout.strip().split(" ")[1]
|
||||
PY_STRING = (
|
||||
"%s\t%s\t%s"
|
||||
%
|
||||
(
|
||||
((isinstance(args[0], list) and " ".join(
|
||||
args[0])) or args[0]).strip(),
|
||||
PYTHON_VERSION,
|
||||
sys.platform
|
||||
)
|
||||
)
|
||||
print(PY_STRING)
|
||||
print('.' * WIDTH)
|
||||
|
||||
# get pip info
|
||||
def pip_info():
|
||||
global args
|
||||
global PIPEXE
|
||||
global PIPEXE
|
||||
global VERSIONS
|
||||
|
||||
# get pip debug info
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"--version"
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
if ret.stdout.strip():
|
||||
if " from " in ret.stdout.strip():
|
||||
PIP_VERSION = ret.stdout.strip().split(" from ")[0].split(" ")[1]
|
||||
if PIP_VERSION:
|
||||
b, f, a = PIP_VERSION.partition('.')
|
||||
global PIP_FLOAT_VERSION
|
||||
PIP_FLOAT_VERSION = b+f+a.replace('.', '')
|
||||
PIP_LATEST = get_module_version("pip")
|
||||
|
||||
VERSIONS["py"] = {
|
||||
"version": PYTHON_VERSION,
|
||||
"platform": sys.platform
|
||||
}
|
||||
VERSIONS["pip"] = {
|
||||
"version": [
|
||||
PIP_VERSION,
|
||||
PIP_FLOAT_VERSION
|
||||
],
|
||||
"latest": PIP_LATEST
|
||||
}
|
||||
|
||||
PIP_STRING = (
|
||||
"%s\t%s\t%s\t%s\t%s\t%s"
|
||||
%
|
||||
(
|
||||
((isinstance(args[0], list) and " ".join(
|
||||
args[0])) or args[0]).strip(),
|
||||
PYTHON_VERSION,
|
||||
sys.platform,
|
||||
PIPEXE,
|
||||
PIP_VERSION,
|
||||
PIP_LATEST
|
||||
)
|
||||
)
|
||||
print(PIP_STRING)
|
||||
print('.' * WIDTH)
|
||||
|
||||
# upgrade pip
|
||||
def pip_upgrade():
|
||||
global args
|
||||
global PIPEXE
|
||||
|
||||
# upgrade pip
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
"--upgrade", "pip"
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
# get output
|
||||
if ret.stdout.strip():
|
||||
# if it's not already satisfied, update it
|
||||
if "already satisfied" not in ret.stdout.strip():
|
||||
print(ret.stdout.strip())
|
||||
pip_info()
|
||||
|
||||
# install modules
|
||||
def install_modules():
|
||||
global args
|
||||
global PIPEXE
|
||||
global SUCCESS
|
||||
|
||||
# install modules from list
|
||||
ret = subprocess.run(
|
||||
[
|
||||
*args,
|
||||
"-m",
|
||||
PIPEXE,
|
||||
"install",
|
||||
"-r",
|
||||
os.path.join(
|
||||
".",
|
||||
"resources",
|
||||
"app",
|
||||
"meta",
|
||||
"manifests",
|
||||
"pip_requirements.txt"
|
||||
)
|
||||
],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
# if there's output
|
||||
if ret.stdout.strip():
|
||||
process_module_output(ret.stdout.strip().split("\n"))
|
||||
manifests_path = os.path.join(".", "resources", "user", "meta", "manifests")
|
||||
if not os.path.isdir(manifests_path):
|
||||
os.makedirs(manifests_path)
|
||||
|
||||
with open(os.path.join(manifests_path, "settings.json"), "w+") as settings:
|
||||
settings.write(
|
||||
json.dumps(
|
||||
{
|
||||
"py": args,
|
||||
"pip": PIPEXE,
|
||||
"pipline": " ".join(args) + " -m " + PIPEXE,
|
||||
"versions": VERSIONS
|
||||
},
|
||||
indent=2
|
||||
)
|
||||
)
|
||||
with open(os.path.join(manifests_path, "pipline.txt"), "w+") as settings:
|
||||
settings.write(" ".join(args) + " -m " + PIPEXE)
|
||||
SUCCESS = True
|
||||
|
||||
|
||||
def main():
|
||||
global args
|
||||
global PIPEXE
|
||||
global SUCCESS
|
||||
# print python debug info
|
||||
heading = (
|
||||
"%s-%s-%s"
|
||||
%
|
||||
(
|
||||
PYTHON_EXECUTABLE,
|
||||
PYTHON_VERSION,
|
||||
sys.platform
|
||||
)
|
||||
)
|
||||
print(heading)
|
||||
print('=' * WIDTH)
|
||||
|
||||
# figure out pip executable
|
||||
PIPEXE = "pip" if "windows" in env["OS_NAME"] else "pip3"
|
||||
PIPEXE = "pip" if "osx" in env["OS_NAME"] and "actions" in env["CI_SYSTEM"] else PIPEXE
|
||||
|
||||
PIP_VERSION = "" # holder for pip's version
|
||||
|
||||
SUCCESS = False
|
||||
# foreach py executable
|
||||
for PYEXE in ["py", "python3", "python"]:
|
||||
if SUCCESS:
|
||||
continue
|
||||
|
||||
args = []
|
||||
# if it's the py launcher, specify the version
|
||||
if PYEXE == "py":
|
||||
PYEXE = [PYEXE, "-" + PYTHON_MINOR_VERSION]
|
||||
# if it ain't windows, skip it
|
||||
if "windows" not in env["OS_NAME"]:
|
||||
continue
|
||||
|
||||
# build executable command
|
||||
if isinstance(PYEXE, list):
|
||||
args = [*PYEXE]
|
||||
else:
|
||||
args = [PYEXE]
|
||||
|
||||
try:
|
||||
python_info()
|
||||
|
||||
# foreach pip executable
|
||||
for PIPEXE in ["pip3", "pip"]:
|
||||
pip_info()
|
||||
pip_upgrade()
|
||||
install_modules()
|
||||
|
||||
# if something else went fucky, print it
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -21,10 +21,11 @@ if not os.path.isdir(os.path.join(".","upx")):
|
||||
UPX_FILE = UPX_SLUG + ".tar.xz"
|
||||
UPX_URL = "https://github.com/upx/upx/releases/download/v" + UPX_VERSION + '/' + UPX_FILE
|
||||
|
||||
# if it's not macos
|
||||
if "osx" not in env["OS_NAME"]:
|
||||
|
||||
print("Getting UPX: " + UPX_FILE)
|
||||
|
||||
# download UPX
|
||||
with open(os.path.join(".",UPX_FILE),"wb") as upx:
|
||||
UPX_REQ = urllib.request.Request(
|
||||
UPX_URL,
|
||||
@@ -34,8 +35,10 @@ if not os.path.isdir(os.path.join(".","upx")):
|
||||
UPX_DATA = UPX_REQ.read()
|
||||
upx.write(UPX_DATA)
|
||||
|
||||
# extract UPX
|
||||
unpack_archive(UPX_FILE,os.path.join("."))
|
||||
|
||||
# move UPX
|
||||
os.rename(os.path.join(".",UPX_SLUG),os.path.join(".","upx"))
|
||||
os.remove(os.path.join(".",UPX_FILE))
|
||||
|
||||
|
||||
168
resources/ci/common/list_actions.py
Normal file
168
resources/ci/common/list_actions.py
Normal file
@@ -0,0 +1,168 @@
|
||||
# pylint: disable=invalid-name
|
||||
'''
|
||||
List GitHub Actions versions used and latest versions
|
||||
'''
|
||||
import json
|
||||
import os
|
||||
import ssl
|
||||
import urllib.request
|
||||
import yaml
|
||||
from json.decoder import JSONDecodeError
|
||||
|
||||
allACTIONS = {}
|
||||
listACTIONS = []
|
||||
|
||||
VER_WIDTH = 10
|
||||
NAME_WIDTH = 40
|
||||
LINE_WIDTH = 1 + NAME_WIDTH + 5 + VER_WIDTH + 5 + VER_WIDTH + 1
|
||||
|
||||
def process_walk(key, node):
|
||||
'''
|
||||
Process walking through the array
|
||||
'''
|
||||
global allACTIONS
|
||||
global listACTIONS
|
||||
if key == "uses":
|
||||
action = node.split('@')
|
||||
version = ""
|
||||
if '@' in node:
|
||||
version = action[1]
|
||||
action = action[0]
|
||||
if action not in allACTIONS:
|
||||
allACTIONS[action] = {
|
||||
"versions": [],
|
||||
"latest": ""
|
||||
}
|
||||
allACTIONS[action]["versions"].append(version)
|
||||
allACTIONS[action]["versions"] = list(
|
||||
set(
|
||||
allACTIONS[action]["versions"]
|
||||
)
|
||||
)
|
||||
listACTIONS.append(node)
|
||||
|
||||
|
||||
def walk(key, node):
|
||||
'''
|
||||
How to walk through the array
|
||||
'''
|
||||
if isinstance(node, dict):
|
||||
return {k: walk(k, v) for k, v in node.items()}
|
||||
elif isinstance(node, list):
|
||||
return [walk(key, x) for x in node]
|
||||
else:
|
||||
return process_walk(key, node)
|
||||
|
||||
|
||||
for r, d, f in os.walk(os.path.join(".", ".github")):
|
||||
if "actions" in r or "workflows" in r:
|
||||
for filename in f:
|
||||
# if it's not a YAML or it's turned off, skip it
|
||||
if (".yml" not in filename and ".yaml" not in filename) or (".off" in filename):
|
||||
continue
|
||||
listACTIONS = []
|
||||
# print filename
|
||||
filename_line = "-" * (len(os.path.join(r, filename)) + 2)
|
||||
print(
|
||||
" " +
|
||||
filename_line +
|
||||
" "
|
||||
)
|
||||
print("| " + os.path.join(r, filename) + " |")
|
||||
# read the file
|
||||
with(open(os.path.join(r, filename), "r", encoding="utf-8")) as yamlFile:
|
||||
print(
|
||||
"|" +
|
||||
filename_line +
|
||||
"-" +
|
||||
("-" * (LINE_WIDTH - len(filename_line) + 1)) +
|
||||
" "
|
||||
)
|
||||
yml = yaml.safe_load(yamlFile)
|
||||
walk("uses", yml)
|
||||
dictACTIONS = {}
|
||||
for k in sorted(list(set(listACTIONS))):
|
||||
action = k.split('@')[0]
|
||||
version = k.split('@')[1] if '@' in k else ""
|
||||
latest = ""
|
||||
# if it's not a location action, get the latest version number
|
||||
if "./." not in action:
|
||||
apiURL = f"https://api.github.com/repos/{action}/releases/latest"
|
||||
if True:
|
||||
apiReq = None
|
||||
try:
|
||||
apiReq = urllib.request.urlopen(
|
||||
apiURL,
|
||||
context=ssl._create_unverified_context()
|
||||
)
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code != 403:
|
||||
print(e.code, apiURL)
|
||||
if apiReq:
|
||||
apiRes = {}
|
||||
try:
|
||||
apiRes = json.loads(
|
||||
apiReq.read().decode("utf-8"))
|
||||
except JSONDecodeError as e:
|
||||
raise ValueError("🔴API Request failed: " + apiURL)
|
||||
if apiRes:
|
||||
latest = apiRes["tag_name"] if "tag_name" in apiRes else ""
|
||||
if latest != "":
|
||||
allACTIONS[action]["latest"] = latest
|
||||
dictACTIONS[action] = version
|
||||
# print action name and version info
|
||||
for action, version in dictACTIONS.items():
|
||||
print(
|
||||
"| " + \
|
||||
f"{action.ljust(NAME_WIDTH)}" + \
|
||||
"\t" + \
|
||||
f"{(version or 'N/A').ljust(VER_WIDTH)}" + \
|
||||
"\t" + \
|
||||
f"{(allACTIONS[action]['latest'] or 'N/A').ljust(VER_WIDTH)}" + \
|
||||
" |"
|
||||
)
|
||||
print(
|
||||
" " +
|
||||
("-" * (LINE_WIDTH + 2)) +
|
||||
" "
|
||||
)
|
||||
print("")
|
||||
|
||||
# print outdated versions summary
|
||||
first = True
|
||||
outdated = False
|
||||
for action, actionData in allACTIONS.items():
|
||||
if len(actionData["versions"]) > 0:
|
||||
if actionData["latest"] != "" and actionData["versions"][0] != actionData["latest"]:
|
||||
outdated = True
|
||||
if first:
|
||||
first = False
|
||||
filename_line = "-" * (len("| Outdated |"))
|
||||
print(
|
||||
" " +
|
||||
filename_line +
|
||||
" "
|
||||
)
|
||||
print("| 🔴Outdated |")
|
||||
print(
|
||||
"|" +
|
||||
filename_line +
|
||||
"-" +
|
||||
("-" * (LINE_WIDTH - len(filename_line) + 1)) +
|
||||
" "
|
||||
)
|
||||
print(
|
||||
"| " + \
|
||||
f"{action.ljust(40)}" + \
|
||||
"\t" + \
|
||||
f"{(','.join(actionData['versions']) or 'N/A').ljust(10)}" + \
|
||||
"\t" + \
|
||||
f"{actionData['latest'].ljust(10)}" + \
|
||||
" |"
|
||||
)
|
||||
if outdated:
|
||||
print(
|
||||
" " +
|
||||
("-" * (LINE_WIDTH + 2)) +
|
||||
" "
|
||||
)
|
||||
@@ -5,12 +5,12 @@ from shutil import copy # file manipulation
|
||||
env = common.prepare_env()
|
||||
|
||||
# set tag to app_version.txt
|
||||
if not env["GITHUB_TAG"] == "":
|
||||
with open(os.path.join(".","resources","app","meta","manifests","app_version.txt"),"w+") as f:
|
||||
_ = f.read()
|
||||
f.seek(0)
|
||||
f.write(env["GITHUB_TAG"])
|
||||
f.truncate()
|
||||
# if not env["GITHUB_TAG"] == "":
|
||||
# with open(os.path.join(".","resources","app","meta","manifests","app_version.txt"),"w+") as f:
|
||||
# _ = f.read()
|
||||
# f.seek(0)
|
||||
# f.write(env["GITHUB_TAG"])
|
||||
# f.truncate()
|
||||
|
||||
if not os.path.isdir(os.path.join("..","build")):
|
||||
os.mkdir(os.path.join("..","build"))
|
||||
|
||||
@@ -1,42 +1,48 @@
|
||||
import distutils.dir_util # for copying trees
|
||||
"""
|
||||
Locate and prepare binary builds
|
||||
"""
|
||||
# import distutils.dir_util # for copying trees
|
||||
import os # for env vars
|
||||
import stat # for file stats
|
||||
import subprocess # do stuff at the shell level
|
||||
# import stat # for file stats
|
||||
# import subprocess # do stuff at the shell level
|
||||
import common
|
||||
from shutil import copy, make_archive, move, rmtree # file manipulation
|
||||
from shutil import move # file manipulation
|
||||
|
||||
env = common.prepare_env()
|
||||
|
||||
# make dir to put the binary in
|
||||
if not os.path.isdir(os.path.join("..","artifact")):
|
||||
os.mkdir(os.path.join("..","artifact"))
|
||||
os.mkdir(os.path.join("..","artifact"))
|
||||
|
||||
BUILD_FILENAME = ""
|
||||
|
||||
# list executables
|
||||
BUILD_FILENAME = common.find_binary('.')
|
||||
if BUILD_FILENAME == "":
|
||||
BUILD_FILENAME = common.find_binary(os.path.join("..","artifact"))
|
||||
BUILD_FILENAME = common.find_binary(os.path.join("..","artifact"))
|
||||
|
||||
if isinstance(BUILD_FILENAME,str):
|
||||
BUILD_FILENAME = list(BUILD_FILENAME)
|
||||
BUILD_FILENAME = list(BUILD_FILENAME)
|
||||
|
||||
BUILD_FILENAMES = BUILD_FILENAME
|
||||
|
||||
print("OS Name: " + env["OS_NAME"])
|
||||
print("OS Version: " + env["OS_VERSION"])
|
||||
print("OS Distribution: " + env["OS_DIST"])
|
||||
print("")
|
||||
for BUILD_FILENAME in BUILD_FILENAMES:
|
||||
DEST_FILENAME = common.prepare_filename(BUILD_FILENAME)
|
||||
DEST_FILENAME = common.prepare_filename(BUILD_FILENAME)
|
||||
|
||||
print("OS Name: " + env["OS_NAME"])
|
||||
print("OS Version: " + env["OS_VERSION"])
|
||||
print("Build Filename: " + BUILD_FILENAME)
|
||||
print("Dest Filename: " + DEST_FILENAME)
|
||||
if not BUILD_FILENAME == "":
|
||||
print("Build Filesize: " + common.file_size(BUILD_FILENAME))
|
||||
else:
|
||||
exit(1)
|
||||
print("Build Filename: " + BUILD_FILENAME)
|
||||
print("Dest Filename: " + DEST_FILENAME)
|
||||
if not BUILD_FILENAME == "":
|
||||
print("Build Filesize: " + common.file_size(BUILD_FILENAME))
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
if not BUILD_FILENAME == "":
|
||||
move(
|
||||
os.path.join(".",BUILD_FILENAME),
|
||||
os.path.join("..","artifact",BUILD_FILENAME)
|
||||
)
|
||||
if not BUILD_FILENAME == "":
|
||||
move(
|
||||
os.path.join(".",BUILD_FILENAME),
|
||||
os.path.join("..","artifact",BUILD_FILENAME)
|
||||
)
|
||||
print("")
|
||||
|
||||
@@ -71,7 +71,7 @@ if len(BUILD_FILENAMES) > 0:
|
||||
# clean the git slate
|
||||
git_clean()
|
||||
|
||||
# mv dirs from source code
|
||||
# mv dirs from source code
|
||||
dirs = [
|
||||
os.path.join(".",".git"),
|
||||
os.path.join(".",".github"),
|
||||
@@ -98,8 +98,8 @@ if len(BUILD_FILENAMES) > 0:
|
||||
if "linux" in env["OS_NAME"] or "ubuntu" in env["OS_NAME"] or "mac" in env["OS_NAME"] or "osx" in env["OS_NAME"]:
|
||||
os.chmod(os.path.join(".",BUILD_FILENAME),0o755)
|
||||
|
||||
# .zip if windows
|
||||
# .tar.gz otherwise
|
||||
# .zip if windows
|
||||
# .tar.gz otherwise
|
||||
if len(BUILD_FILENAMES) > 1:
|
||||
ZIP_FILENAME = os.path.join("..","deploy",env["REPO_NAME"])
|
||||
else:
|
||||
@@ -111,7 +111,7 @@ if len(BUILD_FILENAMES) > 0:
|
||||
make_archive(ZIP_FILENAME,"gztar")
|
||||
ZIP_FILENAME += ".tar.gz"
|
||||
|
||||
# mv dirs back
|
||||
# mv dirs back
|
||||
for dir in dirs:
|
||||
if os.path.isdir(os.path.join("..","build",dir)):
|
||||
move(
|
||||
@@ -124,15 +124,15 @@ for BUILD_FILENAME in BUILD_FILENAMES:
|
||||
print("Build Filename: " + BUILD_FILENAME)
|
||||
print("Build Filesize: " + common.file_size(BUILD_FILENAME))
|
||||
else:
|
||||
print("No Build to prepare: " + BUILD_FILENAME)
|
||||
print("🟡No Build to prepare: " + BUILD_FILENAME)
|
||||
|
||||
if not ZIP_FILENAME == "":
|
||||
print("Zip Filename: " + ZIP_FILENAME)
|
||||
print("Zip Filesize: " + common.file_size(ZIP_FILENAME))
|
||||
else:
|
||||
print("No Zip to prepare: " + ZIP_FILENAME)
|
||||
print("🟡No Zip to prepare: " + ZIP_FILENAME)
|
||||
|
||||
print("Git tag: " + env["GITHUB_TAG"])
|
||||
print("App Version: " + env["GITHUB_TAG"])
|
||||
|
||||
if (len(BUILD_FILENAMES) == 0) or (ZIP_FILENAME == ""):
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user