Update Build Script

This commit is contained in:
Mike A. Trethewey
2021-01-07 23:34:15 -08:00
parent 5a426b194d
commit 735f19fbd6
6 changed files with 54 additions and 28 deletions

View File

@@ -26,8 +26,8 @@ jobs:
# os & python versions
strategy:
matrix:
os-name: [ ubuntu-latest, ubuntu-16.04, macOS-latest, windows-latest ]
python-version: [ 3.7 ]
os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ]
python-version: [ 3.8 ]
# needs: [ install-test ]
steps:
# checkout commit
@@ -88,8 +88,8 @@ jobs:
strategy:
matrix:
# install/release on not xenial
os-name: [ ubuntu-latest, macOS-latest, windows-latest ]
python-version: [ 3.7 ]
os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ]
python-version: [ 3.8 ]
needs: [ install-build ]
steps:
@@ -150,9 +150,9 @@ jobs:
# os & python versions
strategy:
matrix:
# release only on bionic
# release only on focal/bionic
os-name: [ ubuntu-latest ]
python-version: [ 3.7 ]
python-version: [ 3.8 ]
needs: [ install-prepare-release ]
steps:

View File

@@ -3,7 +3,10 @@
import sys
block_cipher = None
console = True
console = False # <--- change this to True to enable command prompt when the app runs
if sys.platform.find("mac") or sys.platform.find("osx"):
console = False
BINARY_SLUG = "DungeonRandomizer"
@@ -27,9 +30,6 @@ def recurse_for_py_files(names_so_far):
hiddenimports = []
binaries = []
#if sys.platform.find("windows"):
# binaries.append(("ucrtbase.dll","."))
a = Analysis([f"./{BINARY_SLUG}.py"],
pathex=[],
binaries=binaries,
@@ -46,6 +46,7 @@ a = Analysis([f"./{BINARY_SLUG}.py"],
# https://stackoverflow.com/questions/17034434/how-to-remove-exclude-modules-and-files-from-pyinstaller
excluded_binaries = [
'VCRUNTIME140.dll',
'ucrtbase.dll',
'msvcp140.dll',
'mfc140u.dll']
a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
@@ -64,4 +65,4 @@ exe = EXE(pyz,
strip=False,
upx=True,
runtime_tmpdir=None,
console=console ) # <--- change this to True to enable command prompt when the app runs
console=console )

View File

@@ -3,10 +3,11 @@
import sys
block_cipher = None
console = True
console = False # <--- change this to True to enable command prompt when the app runs
if sys.platform.find("mac") or sys.platform.find("osx"):
console = False
BINARY_SLUG = "Gui"
def recurse_for_py_files(names_so_far):
@@ -29,9 +30,6 @@ def recurse_for_py_files(names_so_far):
hiddenimports = []
binaries = []
#if sys.platform.find("windows"):
# binaries.append(("ucrtbase.dll","."))
a = Analysis([f"./{BINARY_SLUG}.py"],
pathex=[],
binaries=binaries,
@@ -48,6 +46,7 @@ a = Analysis([f"./{BINARY_SLUG}.py"],
# https://stackoverflow.com/questions/17034434/how-to-remove-exclude-modules-and-files-from-pyinstaller
excluded_binaries = [
'VCRUNTIME140.dll',
'ucrtbase.dll',
'msvcp140.dll',
'mfc140u.dll']
a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
@@ -66,4 +65,4 @@ exe = EXE(pyz,
strip=False,
upx=True,
runtime_tmpdir=None,
console=console ) # <--- change this to True to enable command prompt when the app runs
console=console )

View File

@@ -1,6 +1,22 @@
import os # for env vars
import stat # file statistics
global UBUNTU_VERSIONS
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"
}
DEFAULT_EVENT = "event"
DEFAULT_REPO_SLUG = "miketrethewey/ALttPDoorRandomizer"
FILENAME_CHECKS = [ "Gui", "DungeonRandomizer" ]
FILESIZE_CHECK = (6 * 1024 * 1024) # 6MB
# take number of bytes and convert to string with units measure
def convert_bytes(num):
for x in ["bytes","KB","MB","GB","TB","PB"]:
@@ -16,9 +32,8 @@ def file_size(file_path):
# prepare environment variables
def prepare_env():
DEFAULT_EVENT = "event"
DEFAULT_REPO_SLUG = "miketrethewey/ALttPDoorRandomizer"
global DEFAULT_EVENT
global DEFAULT_REPO_SLUG
env = {}
# get app version
@@ -33,7 +48,7 @@ def prepare_env():
env["BRANCH"] = os.getenv("TRAVIS_BRANCH","")
env["GITHUB_ACTOR"] = os.getenv("GITHUB_ACTOR","MegaMan.EXE")
env["GITHUB_SHA"] = os.getenv("GITHUB_SHA","")
env["GITHUB_RUN_ID"] = os.getenv("GITHUB_RUN_ID","")
env["GITHUB_RUN_NUMBER"] = os.getenv("GITHUB_RUN_NUMBER","")
env["GITHUB_SHA_SHORT"] = env["GITHUB_SHA"]
# commit data
env["COMMIT_ID"] = os.getenv("TRAVIS_COMMIT",os.getenv("GITHUB_SHA",""))
@@ -57,7 +72,7 @@ def prepare_env():
env["GITHUB_SHA_SHORT"] = env["GITHUB_SHA"][:7]
# ci data
env["BUILD_NUMBER"] = os.getenv("TRAVIS_BUILD_NUMBER",env["GITHUB_RUN_ID"])
env["BUILD_NUMBER"] = os.getenv("TRAVIS_BUILD_NUMBER",env["GITHUB_RUN_NUMBER"])
GITHUB_TAG = os.getenv("TRAVIS_TAG",os.getenv("GITHUB_TAG",""))
OS_NAME = os.getenv("TRAVIS_OS_NAME",os.getenv("OS_NAME","")).replace("macOS","osx")
@@ -68,10 +83,8 @@ 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 == "latest":
OS_VERSION = "bionic"
elif OS_VERSION == "16.04":
OS_VERSION = "xenial"
if OS_VERSION in UBUNTU_VERSIONS:
OS_VERSION = UBUNTU_VERSIONS[OS_VERSION]
OS_DIST = OS_VERSION
if OS_VERSION == "" and not OS_DIST == "" and not OS_DIST == "notset":
@@ -115,8 +128,8 @@ def prepare_filename(BUILD_FILENAME):
# find a binary file if it's executable
# failing that, assume it's over 6MB
def find_binary(listdir):
FILENAME_CHECKS = [ "Gui", "DungeonRandomizer" ]
FILESIZE_CHECK = (6 * 1024 * 1024) # 6MB
global FILENAME_CHECKS
global FILESIZE_CHECK
BUILD_FILENAMES = []
executable = stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH

View File

@@ -32,6 +32,8 @@ for BUILD_FILENAME in BUILD_FILENAMES:
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(

View File

@@ -29,6 +29,11 @@ for dirname in ["resources","user","meta","manifests"]:
if os.path.isdir(dirpath):
os.chmod(dirpath,0o755)
# nuke git files
for git in [ os.path.join(".", ".gitattrubutes"), os.path.join(".", ".gitignore") ]:
if os.path.isfile(git):
os.remove(git)
# nuke travis file if it exists
for travis in [ os.path.join(".", ".travis.yml"), os.path.join(".", ".travis.off") ]:
if os.path.isfile(travis):
@@ -95,7 +100,10 @@ if len(BUILD_FILENAMES) > 0:
# .zip if windows
# .tar.gz otherwise
ZIP_FILENAME = os.path.join("..","deploy",env["REPO_NAME"]) if len(BUILD_FILENAMES) > 1 else os.path.join("..","deploy",os.path.splitext(BUILD_FILENAME)[0])
if len(BUILD_FILENAMES) > 1:
ZIP_FILENAME = os.path.join("..","deploy",env["REPO_NAME"])
else:
ZIP_FILENAME = os.path.join("..","deploy",os.path.splitext(BUILD_FILENAME)[0])
if env["OS_NAME"] == "windows":
make_archive(ZIP_FILENAME,"zip")
ZIP_FILENAME += ".zip"
@@ -125,3 +133,6 @@ else:
print("No Zip to prepare: " + ZIP_FILENAME)
print("Git tag: " + env["GITHUB_TAG"])
if (len(BUILD_FILENAMES) == 0) or (ZIP_FILENAME == ""):
exit(1)