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

@@ -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)