Owr actions update (#19)

* Go for Broke

* Let it fire

* Add PipLine

* Create the dir if it doesn't exist

* Install Setuptools

* Track Test Action's files

* Fix Calling Job

* Track Build Action files

* Install Distutils, rename filenames

* Fix Fail conditions

* Make Build scripts smarter

* Add file

* Concat DLLs lists

* Try to fail if Error DLLs

* Try to make the fail smarter

* Moar verbosity

* Print the stuff first

* Print outputs objects

* See if this skips failure

* Use py instead

* Print error list

* Don't ValueError

* Try checking a different way

* Try something else

* Bleh, spell filename correctly

* Update excluded_dlls.json

* Ugh, gotta compare old to new somehow

* Compare to old list

* Condense build script

* Moar verbosity

* Update the global version

* Update Excluded DLLs list

* Actually use the bad DLLs list

* Make a version number

* Fix version number building

* Fix version number building again

* Fix Diagnostics

* Try REST API stuff

* Try REST API again

* Moar REST

* await

* Get SHA

* Try it all together

* Del test workflow

* Add Perms

* Use a Token

* Try this Token

* Try different Token

* Try different Token

* Create App Version earlier

* See this error again

* Don't fail if App Version not made yet

* Use New Secret

* Print whole response

* Documentation for Tagger

* Update CI Instructions

* Update CI

* List References

* Find latest tag

Fix App Version getter

* Fix commas

* Check returned data

* Update Build Script

* Fix substring

* Fix Git tag

* Fix tag again

* Visual indicators

* Use encoding

* Remove an indicator

* Update CI

* Update Project Name

* PyInstaller Spec Template file

* Update Build Script

* Fix Tagger

* Update CI

* Download AppVersion during build

* Test job can fail

* Upload Logs instead of printing them

* Change from Reusable Workflow to Action

* Change ref to token

* Compare to string

* Use PAT

* Use String literal

* Remove Reusable Workflow

* Update CI Scripts

* Go for Broke

* Let it fire

* Add PipLine

* Create the dir if it doesn't exist

* Install Setuptools

* Track Test Action's files

* Fix Calling Job

* Track Build Action files

* Install Distutils, rename filenames

* Fix Fail conditions

* Make Build scripts smarter

* Add file

* Concat DLLs lists

* Try to fail if Error DLLs

* Try to make the fail smarter

* Moar verbosity

* Print the stuff first

* Print outputs objects

* See if this skips failure

* Use py instead

* Print error list

* Don't ValueError

* Try checking a different way

* Try something else

* Bleh, spell filename correctly

* Update excluded_dlls.json

* Ugh, gotta compare old to new somehow

* Compare to old list

* Condense build script

* Moar verbosity

* Update the global version

* Update Excluded DLLs list

* Actually use the bad DLLs list

* Make a version number

* Fix version number building

* Fix version number building again

* Fix Diagnostics

* Try REST API stuff

* Try REST API again

* Moar REST

* await

* Get SHA

* Try it all together

* Del test workflow

* Add Perms

* Use a Token

* Try this Token

* Try different Token

* Try different Token

* Create App Version earlier

* See this error again

* Don't fail if App Version not made yet

* Use New Secret

* Print whole response

* Documentation for Tagger

* Update CI Instructions

* Update CI

* List References

* Find latest tag

Fix App Version getter

* Fix commas

* Check returned data

* Update Build Script

* Fix substring

* Fix Git tag

* Fix tag again

* Visual indicators

* Use encoding

* Remove an indicator

* Update CI

* Update Project Name

* PyInstaller Spec Template file

* Update Build Script

* Fix Tagger

* Update CI

* Download AppVersion during build

* Test job can fail

* Upload Logs instead of printing them

* Change from Reusable Workflow to Action

* Change ref to token

* Compare to string

* Use PAT

* Use String literal

* Remove Reusable Workflow

* Update CI Scripts

---------

Co-authored-by: Minnie A. Trethewey (Mike) <minnietrethewey@gmail.com>
This commit is contained in:
codemann8
2024-05-23 19:29:39 -05:00
committed by GitHub
parent 9eb5293a3c
commit b55c3700c0
39 changed files with 2076 additions and 588 deletions

View File

@@ -1,27 +0,0 @@
import subprocess
import os
import shutil
import sys
# Spec file
SPEC_FILE = os.path.join(".", "source", "DungeonRandomizer.spec")
# Destination is current dir
DEST_DIRECTORY = '.'
# Check for UPX
if os.path.isdir("upx"):
upx_string = "--upx-dir=upx"
else:
upx_string = ""
if os.path.isdir("build") and not sys.platform.find("mac") and not sys.platform.find("osx"):
shutil.rmtree("build")
# Run pyinstaller for DungeonRandomizer
subprocess.run(" ".join([f"pyinstaller {SPEC_FILE} ",
upx_string,
"-y ",
f"--distpath {DEST_DIRECTORY} ",
]),
shell=True)

View File

@@ -1,27 +0,0 @@
import subprocess
import os
import shutil
import sys
# Spec file
SPEC_FILE = os.path.join(".", "source", "Gui.spec")
# Destination is current dir
DEST_DIRECTORY = '.'
# Check for UPX
if os.path.isdir("upx"):
upx_string = "--upx-dir=upx"
else:
upx_string = ""
if os.path.isdir("build") and not sys.platform.find("mac") and not sys.platform.find("osx"):
shutil.rmtree("build")
# Run pyinstaller for Gui
subprocess.run(" ".join([f"pyinstaller {SPEC_FILE} ",
upx_string,
"-y ",
f"--distpath {DEST_DIRECTORY} ",
]),
shell=True)

155
source/meta/build.py Normal file
View File

@@ -0,0 +1,155 @@
'''
Build Entrypoints
'''
import json
import platform
import os # for checking for dirs
import re
from json.decoder import JSONDecodeError
from subprocess import Popen, PIPE, STDOUT, CalledProcessError
DEST_DIRECTORY = "."
# UPX greatly reduces the filesize. You can get this utility from https://upx.github.io/
# just place it in a subdirectory named "upx" and this script will find it
UPX_DIR = "upx"
if os.path.isdir(os.path.join(".", UPX_DIR)):
upx_string = f"--upx-dir={UPX_DIR}"
else:
upx_string = ""
GO = True
DIFF_DLLS = False
# set a global var for Actions to try to read
def set_output(name, value):
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f'{name}={value}', file=fh)
# build the thing
def run_build(slug):
global GO
global DIFF_DLLS
print(f"Building '{slug}' via Python {platform.python_version()}")
# get template, mod to do the thing
specTemplateFile = open(os.path.join(".","source","Template.spec"))
specTemplate = specTemplateFile.read()
specTemplateFile.close()
with(open(os.path.join(".","source",f"{slug}.spec"), "w")) as specFile:
print(f"Writing '{slug}' PyInstaller spec file")
thisTemplate = specTemplate.replace("<BINARY_SLUG>", slug)
specFile.write(thisTemplate)
PYINST_EXECUTABLE = "pyinstaller"
args = [
os.path.join("source", f"{slug}.spec").replace(os.sep, os.sep * 2),
upx_string,
"-y",
f"--distpath={DEST_DIRECTORY}"
]
errs = []
strs = []
print("PyInstaller args: %s" % " ".join(args))
cmd = [
PYINST_EXECUTABLE,
*args
]
ret = {
"stdout": [],
"stderr": []
}
with Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
ret["stdout"].append(line)
print(line, end='')
# if p.stderr:
# for line in p.stderr:
# ret["stderr"].append(line)
# print(line, end='')
# if p.returncode != 0:
# raise CalledProcessError(p.returncode, p.args)
# check stdout & stderr
for key in ["stdout","stderr"]:
if len(ret[key]) > 0:
for line in ret[key]:
# UPX can't compress this file
if "NotCompressibleException" in line.strip():
print(line)
errs.append(line.strip())
# print UPX messages
if "UPX" in line:
print(line)
# try to get DLL filename
elif "NotCompressibleException" in line.strip():
matches = re.search(r'api-ms-win-(?:[^-]*)-([^-]*)', line.strip())
if matches:
strAdd = matches.group(1)
strs.append(strAdd)
errs.append(line.strip())
# print collected errors
if len(errs) > 0:
print("=" * 10)
print("| ERRORS |")
print("=" * 10)
print("\n".join(errs))
else:
GO = False
# if we identified DLLs to ignore
if len(strs) > 0:
# read DLLs manifest that we've already got saved
with open(os.path.join(".","resources","app","meta","manifests","excluded_dlls.json"), "w+", encoding="utf-8") as dllsManifest:
oldDLLs = []
try:
oldDLLs = json.load(dllsManifest)
except JSONDecodeError as e:
oldDLLs = []
# raise ValueError("Windows DLLs manifest malformed!")
# bucket for new list
newDLLs = sorted(list(set(oldDLLs)))
# items to add
addDLLs = sorted(list(set(strs)))
# add items
newDLLs += addDLLs
newDLLs = sorted(list(set(newDLLs)))
# if the lists differ, we've gotta update the included list
diffDLLs = newDLLs != oldDLLs
if diffDLLs:
DIFF_DLLS = True
dllsManifest.seek(0)
dllsManifest.truncate()
dllsManifest.write(json.dumps(sorted(newDLLs), indent=2))
print(f"Old DLLs: {json.dumps(sorted(oldDLLs))}")
print(f"Add DLLs: {json.dumps(sorted(addDLLs))}")
print(f"New DLLs: {json.dumps(sorted(newDLLs))}")
print(f"Diff DLLs: {DIFF_DLLS}")
print("")
def go_build(slug):
slug = slug or ""
if slug != "":
GO = True
while GO:
run_build(slug)
GO = False
if __name__ == "__main__":
binary_slugs = []
#TODO: Make sure we've got the proper binaries that we need
with open(os.path.join(".","resources","app","meta","manifests","binaries.json")) as binariesFile:
binary_slugs = json.load(binariesFile)
for file_slug in binary_slugs:
go_build(file_slug)
if DIFF_DLLS:
print("🔴Had to update Error DLLs list!")
exit(1)

View File

@@ -0,0 +1,10 @@
import json
import os
error_dlls_path = os.path.join(".","resources","app","meta","manifests","excluded_dlls.json")
if os.path.isfile(error_dlls_path):
with open(error_dlls_path, "r") as error_dlls_file:
error_dlls_json = json.load(error_dlls_file)
if len(error_dlls_json) > 0 and error_dlls_json[0].strip() != "":
print(error_dlls_json)
# exit(1)

10
source/meta/run_diags.py Normal file
View File

@@ -0,0 +1,10 @@
from source.classes import diags as diags
global VERBOSE
VERBOSE = True
if __name__ == "__main__":
if VERBOSE:
print("DIAGNOSTICS")
print('.' * 70)
print("\n".join(diags.output()))