2022-07-09 13:05:42 +02:00
|
|
|
import steam_publish
|
2022-08-26 15:45:49 +02:00
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import macos_sign
|
2022-07-09 13:05:42 +02:00
|
|
|
import argparse
|
|
|
|
import os
|
2022-07-24 17:56:00 +02:00
|
|
|
import build
|
2022-07-09 13:05:42 +02:00
|
|
|
from pathlib import Path
|
2022-07-22 13:21:30 +02:00
|
|
|
from macos_lipo import run_lipo, check_fat_binary
|
|
|
|
import platform
|
2022-08-07 12:24:07 +02:00
|
|
|
import paramiko
|
2022-10-10 11:35:41 +02:00
|
|
|
import defines
|
2022-08-26 15:43:50 +02:00
|
|
|
from util import sftp_exists
|
2022-11-02 12:15:34 +01:00
|
|
|
from sys import stdout
|
|
|
|
|
|
|
|
stdout.reconfigure(encoding='utf-8')
|
|
|
|
|
2022-07-09 13:05:42 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(description='Build and Package ScreenPlay')
|
2022-08-14 11:58:41 +02:00
|
|
|
parser.add_argument('-steam_password', '-sp', action="store", dest="steam_password", help="Steam password")
|
|
|
|
parser.add_argument('-hosting_username','-hu', action="store", dest="hosting_username", help="ssh username")
|
|
|
|
parser.add_argument('-hosting_password', '-hp', action="store", dest="hosting_password", help="ssh password")
|
2022-07-09 13:05:42 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Script needs to run in the tools folder
|
|
|
|
tools_path = Path.cwd()
|
|
|
|
os.chdir(tools_path)
|
2022-07-22 13:21:30 +02:00
|
|
|
root_path = tools_path.parent
|
|
|
|
print(f"Set root directory to: {root_path}")
|
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
build_result = build.BuildResult()
|
|
|
|
|
|
|
|
build_config = build.BuildConfig()
|
2022-10-10 11:35:41 +02:00
|
|
|
build_config.screenplay_version = defines.SCREENPLAY_VERSION
|
|
|
|
build_config.qt_version = defines.QT_VERSION
|
|
|
|
build_config.qt_ifw_version = defines.QT_IFW_VERSION
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.build_steam = "ON"
|
|
|
|
build_config.build_tests = "OFF"
|
2022-08-14 11:58:41 +02:00
|
|
|
build_config.build_deploy = "ON"
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.create_installer = "ON"
|
|
|
|
build_config.build_type = "release"
|
|
|
|
build_config.use_aqt = False
|
|
|
|
|
2022-07-22 13:21:30 +02:00
|
|
|
if platform.system() == "Darwin":
|
2022-08-14 11:58:41 +02:00
|
|
|
# We do not yet support a standalone osx installer
|
|
|
|
build_config.create_installer = "OFF"
|
2022-07-22 13:21:30 +02:00
|
|
|
# OSX builds needs to build for x86 and arm
|
|
|
|
# and also be signed!
|
2022-08-26 15:45:49 +02:00
|
|
|
|
|
|
|
# We need to manually package here at the end after
|
|
|
|
# we run
|
|
|
|
build_config.package = True
|
|
|
|
|
|
|
|
# Remove old build-universal-osx-release dir that does not automatically
|
|
|
|
# deleted because it is not build directly but generated from x64 and arm64
|
|
|
|
universal_build_dir = Path(os.path.join(root_path, "build-universal-osx-release"))
|
|
|
|
if universal_build_dir.exists():
|
|
|
|
print(f"Remove previous build folder: {universal_build_dir}")
|
|
|
|
# ignore_errors removes also not empty folders...
|
|
|
|
shutil.rmtree(universal_build_dir, ignore_errors=True)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
build_config.build_architecture = "arm64"
|
|
|
|
build_result = build.execute(build_config)
|
|
|
|
|
|
|
|
build_config.build_architecture = "x64"
|
|
|
|
build_result = build.execute(build_config)
|
|
|
|
|
2022-07-22 13:21:30 +02:00
|
|
|
# Make sure to reset to tools path
|
|
|
|
os.chdir(root_path)
|
|
|
|
# Create universal (fat) binary
|
|
|
|
run_lipo()
|
|
|
|
check_fat_binary()
|
2022-08-26 15:45:49 +02:00
|
|
|
|
|
|
|
build_config.bin_dir = os.path.join(build_config.root_path,'build-universal-osx-release/bin/')
|
|
|
|
print(f"Change binary dir to: {build_config.bin_dir}")
|
|
|
|
macos_sign.sign(build_config=build_config)
|
2022-07-22 13:21:30 +02:00
|
|
|
else:
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.build_architecture = "x64"
|
|
|
|
build_result = build.execute(build_config)
|
|
|
|
|
2022-08-07 12:24:07 +02:00
|
|
|
ssh = paramiko.SSHClient()
|
2022-08-26 15:43:50 +02:00
|
|
|
ssh.load_system_host_keys()
|
|
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
2022-08-07 12:24:07 +02:00
|
|
|
ssh.connect('kelteseth.com', username=args.hosting_username, password=args.hosting_password)
|
|
|
|
sftp = ssh.open_sftp()
|
|
|
|
release_folder = "/kelteseth_com/public/releases/" + build_config.screenplay_version + "/"
|
2022-08-26 15:43:50 +02:00
|
|
|
if sftp_exists(sftp,release_folder):
|
|
|
|
remoteFiles = sftp.listdir(path=release_folder)
|
|
|
|
for file in remoteFiles:
|
|
|
|
print(f"Delte old: {release_folder+file}")
|
|
|
|
sftp.remove(release_folder+file)
|
|
|
|
else:
|
|
|
|
sftp.mkdir(release_folder)
|
2022-08-07 12:24:07 +02:00
|
|
|
print("Uploading files...")
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2022-08-07 12:24:07 +02:00
|
|
|
sftp.put(build_result.build_zip, release_folder + str(build_result.build_zip.name))
|
|
|
|
sftp.put(build_result.installer, release_folder + str(build_result.installer.name))
|
|
|
|
sftp.put(build_result.installer_zip,release_folder + str(build_result.installer_zip.name))
|
|
|
|
sftp.put(build_result.build_hash, release_folder + str(build_result.build_hash.name))
|
|
|
|
sftp.close()
|
|
|
|
ssh.close()
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2022-08-07 12:24:07 +02:00
|
|
|
# Make sure to reset to tools path
|
2022-08-26 15:43:50 +02:00
|
|
|
os.chdir(tools_path)
|
|
|
|
steam_publish.publish(
|
|
|
|
steam_username="tachiom",
|
|
|
|
steam_password=args.steam_password,
|
|
|
|
set_live_branch_name="internal"
|
|
|
|
)
|