From 1f80ba90cac02aefd227f77ff8df09b8748c4e78 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 9 Jul 2022 13:05:42 +0200 Subject: [PATCH] Refactor build and publish scripts Add mac arm support Refactor build and publish build build --- Tools/Scoop/ScreenPlay.json | 4 +- Tools/build.py | 315 +++++++++++++++---------- Tools/build_and_publish.py | 32 +++ Tools/steam_publish.py | 109 +++++---- Tools/steamcmd/app_build_linux.vdf | 2 +- Tools/steamcmd/app_build_mac.vdf | 2 +- Tools/steamcmd/app_build_windows.vdf | 2 +- Tools/steamcmd/depot_build_mac_arm.vdf | 13 + 8 files changed, 303 insertions(+), 176 deletions(-) create mode 100644 Tools/build_and_publish.py create mode 100644 Tools/steamcmd/depot_build_mac_arm.vdf diff --git a/Tools/Scoop/ScreenPlay.json b/Tools/Scoop/ScreenPlay.json index 5f00b76c..ebcaaad1 100644 --- a/Tools/Scoop/ScreenPlay.json +++ b/Tools/Scoop/ScreenPlay.json @@ -2,8 +2,8 @@ "version": "0.15.0", "description": "ScreenPlay is an Open Source Live-Wallpaper app for Windows and OSX. ", "homepage": "https://screen-play.app/", - "url": "https://kelteseth.com/SP.zip", + "url": "https://kelteseth.com/screenplay/ScreenPlay-0.15.0-RC1-x64-windows-release.zip", "bin": "ScreenPlay.exe", "license": "AGPL-3.0", - "extract_dir": "build-x64-windows-release/bin" + "extract_dir": "bin" } \ No newline at end of file diff --git a/Tools/build.py b/Tools/build.py index 0ea1bdd9..20e32f56 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -6,12 +6,25 @@ import platform import shutil import argparse import time +import zipfile from pathlib import Path from concurrent.futures import ThreadPoolExecutor +from datetime import datetime + +SCREENPLAY_VERSION = "0.15.0-RC1" + +def zipdir(path, ziph): + # ziph is zipfile handle + for root, dirs, files in os.walk(path): + for file in files: + ziph.write(os.path.join(root, file), + os.path.relpath(os.path.join(root, file), + os.path.join(path, '..'))) + # Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c def get_vs_env_dict(): - vcvars = "" # We support 2019 or 2022 + vcvars = "" # We support 2019 or 2022 # Hardcoded VS path # check if vcvars64.bat is available. @@ -24,7 +37,8 @@ def get_vs_env_dict(): if Path(msvc_2022_path).exists(): vcvars = msvc_2022_path if not vcvars: - raise RuntimeError("No Visual Studio installation found, only 2019 and 2022 are supported.") + raise RuntimeError( + "No Visual Studio installation found, only 2019 and 2022 are supported.") print(f"\n\nLoading MSVC env variables via {vcvars}\n\n") @@ -38,12 +52,14 @@ def get_vs_env_dict(): output = stdout.decode("mbcs").split("\r\n") return dict((e[0].upper(), e[1]) for e in [p.rstrip().split("=", 1) for p in output] if len(e) == 2) + def run_io_tasks_in_parallel(tasks): with ThreadPoolExecutor() as executor: running_tasks = [executor.submit(task) for task in tasks] for running_task in running_tasks: running_task.result() + def clean_build_dir(build_dir): if isinstance(build_dir, str): build_dir = Path(build_dir) @@ -53,107 +69,60 @@ def clean_build_dir(build_dir): shutil.rmtree(build_dir, ignore_errors=True) build_dir.mkdir(parents=True, exist_ok=True) -def run(cmd, cwd = Path.cwd()): + +def run(cmd, cwd=Path.cwd()): result = subprocess.run(cmd, shell=True, cwd=cwd) if result.returncode != 0: raise RuntimeError(f"Failed to execute {cmd}") -if __name__ == "__main__": +def build( + qt_version, + qt_ifw_version, + build_steam, + build_tests, + build_release, + create_installer, + build_type, + sign_build, + use_aqt +): + + # Make sure the script is always started from the same folder root_path = Path.cwd() - qt_version = "6.3.0" - qt_installer_version = "4.4" - qt_path = "" - build_steam = "OFF" - build_tests = "OFF" - build_installer = "OFF" - build_release = "OFF" - create_installer = "OFF" - cmake_target_triplet = "" - cmake_build_type = "" - executable_file_ending = "" + if root_path.name == "Tools": + root_path = root_path.parent + print(f"Change root directory to: {root_path}") + os.chdir(root_path) + + aqt_path="" + if use_aqt: + aqt_path = Path(f"{root_path}/../aqt/").resolve() + + if not Path(aqt_path).exists(): + print( + f"aqt path does not exist at {aqt_path}. Please make sure you have installed aqt.") + exit(2) + deploy_command = "" - aqt_path = "" - ifw_root_path = "" + executable_file_ending="" + qt_path = "" aqt_install_qt_packages = "" aqt_install_tool_packages = "" - cmake_bin_path = "" + cmake_target_triplet = "" file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".a", ".exp", ".manifest", ".cmake", ".cbp", "CMakeCache.txt"] - parser = argparse.ArgumentParser(description='Build and Package ScreenPlay') - - parser.add_argument('-qt-version', action="store", dest="qt_version_overwrite", - help="Overwrites the default Qt version") - parser.add_argument('-qt-installer-version', action="store", dest="qt_installer_version_overwrite", - help="Overwrites the default Qt installer framework version") - parser.add_argument('-type', action="store", dest="build_type", - help="Build type. This is either debug or release.") - parser.add_argument('-use-aqt', action="store_true", dest="use_aqt", - help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.") - parser.add_argument('-sign', action="store_true", dest="sign_build", - help="Enable if you want to sign the apps. This is macOS only for now.") - parser.add_argument('-steam', action="store_true", dest="build_steam", - help="Enable if you want to build the Steam workshop plugin.") - parser.add_argument('-tests', action="store_true", dest="build_tests", - help="Build tests.") - parser.add_argument('-installer', action="store_true", dest="create_installer", - help="Create a installer.") - parser.add_argument('-release', action="store_true", dest="build_release", - help="Create a release version of ScreenPlay for sharing with the world. This is not about debug/release build, but the c++ define SCREENPLAY_RELEASE.") - args = parser.parse_args() - - if not args.build_type: - print("Build type argument is missing (release, debug). E.g: python build.py -type release -steam") - print(f"Defaulting to Qt version: {qt_version}. This can be overwritten via -qt-version 6.5.0") - exit(1) - - if args.qt_version_overwrite: - qt_version = args.qt_version_overwrite - print("Using Qt version {qt_version}") - - if args.qt_installer_version_overwrite: - qt_installer_version = args.qt_installer_version_overwrite - print("Using Qt installer framework version {qt_installer_version}") - - - remove_files_from_build_folder = [ - ".ninja_deps", - ".ninja", - ".ninja_log", - ".lib", - ".a", - ".dylib", - ".exp", - ".manifest", - ".cmake", - ".cbp", - "CMakeCache.txt", - "steam_appid.txt" # This file is only needed for testing. It must not be in a release version! - ] - - if args.build_steam and not args.build_release: - print("Steam Builds must have release option enabled via -release") - exit(4) - - if root_path.name == "Tools": - root_path = root_path.parent - - if args.use_aqt: - aqt_path = Path(f"{root_path}/../aqt/").resolve() - - if not Path(aqt_path).exists(): - print(f"aqt path does not exist at {aqt_path}. Please make sure you have installed aqt.") - exit(2) if platform.system() == "Windows": cmake_target_triplet = "x64-windows" - cmake_build_type = args.build_type windows_msvc = "msvc2019_64" executable_file_ending = ".exe" - qt_path = aqt_path.joinpath(qt_version).joinpath(windows_msvc) if args.use_aqt else Path(f"C:/Qt/{qt_version}/{windows_msvc}") + qt_path = aqt_path.joinpath(qt_version).joinpath( + windows_msvc) if use_aqt else Path(f"C:/Qt/{qt_version}/{windows_msvc}") vs_env_dict = get_vs_env_dict() - vs_env_dict["PATH"] = vs_env_dict["PATH"] + ";" + str(qt_path) + "\\bin" + vs_env_dict["PATH"] = vs_env_dict["PATH"] + \ + ";" + str(qt_path) + "\\bin" os.environ.update(vs_env_dict) deploy_command = "windeployqt.exe --{type} --qmldir ../../{app}/qml {app}{executable_file_ending}" @@ -165,8 +134,9 @@ if __name__ == "__main__": cmake_target_triplet = "arm64-osx" else: cmake_target_triplet = "x64-osx" - - qt_path = aqt_path.joinpath(f"{qt_version}/macos") if args.use_aqt else Path(f"~/Qt/{qt_version}/macos") + + qt_path = aqt_path.joinpath( + f"{qt_version}/macos") if use_aqt else Path(f"~/Qt/{qt_version}/macos") deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml -executable={app}.app/Contents/MacOS/{app}" aqt_install_qt_packages = f"mac desktop {qt_version} clang_64 -m all" @@ -174,7 +144,8 @@ if __name__ == "__main__": elif platform.system() == "Linux": cmake_target_triplet = "x64-linux" - qt_path = aqt_path.joinpath(f"{qt_version}/gcc_64") if args.use_aqt else Path(f"~/Qt/{qt_version}/gcc_64") + qt_path = aqt_path.joinpath( + f"{qt_version}/gcc_64") if use_aqt else Path(f"~/Qt/{qt_version}/gcc_64") aqt_install_qt_packages = f"linux desktop {qt_version} gcc_64 -m all" aqt_install_tool_packages = "linux desktop tools_ifw" if shutil.which("cqtdeployer"): @@ -182,37 +153,33 @@ if __name__ == "__main__": else: print("cqtdeployer not available, build may be incomplete and incompatible with some distro (typically Ubuntu)") home_path = str(Path.home()) - qt_path = aqt_path.joinpath(f"{qt_version}/gcc_64") if args.use_aqt else Path(f"{home_path}/Qt/{qt_version}/gcc_64") + qt_path = aqt_path.joinpath( + f"{qt_version}/gcc_64") if use_aqt else Path(f"{home_path}/Qt/{qt_version}/gcc_64") else: - raise NotImplementedError("Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.") - + raise NotImplementedError( + "Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.") + + # Default to QtMaintainance installation. - if args.use_aqt: - print("qt_path path %s." % qt_path) + if use_aqt: + print(f"qt_path: {qt_path}.") if not Path(aqt_path).exists(): - print(f"aqt path does not exist at {aqt_path}. Installing now into...") + print( + f"aqt path does not exist at {aqt_path}. Installing now into...") run(f"aqt install-qt -O ../aqt {aqt_install_qt_packages}", cwd=root_path) - run(f"aqt install-tool -O ../aqt {aqt_install_tool_packages}", cwd=root_path) - - + run( + f"aqt install-tool -O ../aqt {aqt_install_tool_packages}", cwd=root_path) + # Prepare cmake_toolchain_file = f"'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'" + ifw_root_path=f"{qt_path}\\Tools\\QtInstallerFramework\\{qt_ifw_version}" print(f"cmake_toolchain_file: {cmake_toolchain_file}") - print(f"Starting build with type {args.build_type}. Qt Version: {qt_version}. Root path: {root_path}") - - if args.build_steam: - build_steam = "ON" - if args.build_tests: - build_tests = "ON" - if args.build_release: - build_release = "ON" - if args.create_installer: - create_installer = "ON" - ifw_root_path = f"{aqt_path}\\Tools\\QtInstallerFramework\\{qt_installer_version}" + print( + f"Starting build with type {build_type}. Qt Version: {qt_version}. Root path: {root_path}") cmake_configure_command = f'cmake ../ \ -DCMAKE_PREFIX_PATH={qt_path} \ - -DCMAKE_BUILD_TYPE={args.build_type} \ + -DCMAKE_BUILD_TYPE={build_type} \ -DVCPKG_TARGET_TRIPLET={cmake_target_triplet} \ -DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file} \ -DSCREENPLAY_STEAM={build_steam} \ @@ -223,7 +190,8 @@ if __name__ == "__main__": -G "CodeBlocks - Ninja" \ -B.' - build_folder = root_path.joinpath(f"build-{cmake_target_triplet}-{args.build_type}") + build_folder = root_path.joinpath( + f"build-{cmake_target_triplet}-{build_type}") clean_build_dir(build_folder) # Build @@ -235,22 +203,22 @@ if __name__ == "__main__": bin_dir = build_folder.joinpath("bin") # Deploy dependencies - if deploy_command: # Only deploy if we have the dependencies + if deploy_command: # Only deploy if we have the dependencies print("Executing deploy commands...") run(deploy_command.format( - type=cmake_build_type, + type=build_type, prefix_path=qt_path, app="ScreenPlay", executable_file_ending=executable_file_ending), cwd=bin_dir) run(deploy_command.format( - type=cmake_build_type, + type=build_type, prefix_path=qt_path, app="ScreenPlayWidget", executable_file_ending=executable_file_ending), cwd=bin_dir) run(deploy_command.format( - type=cmake_build_type, + type=build_type, prefix_path=qt_path, app="ScreenPlayWallpaper", executable_file_ending=executable_file_ending), cwd=bin_dir) @@ -261,27 +229,29 @@ if __name__ == "__main__": qt_lib_path = qt_path for file in qt_lib_path.joinpath("lib").glob("*.so"): shutil.copy(str(file), str(bin_dir)) - + # Copy qt_qml_path folder content into bin_dir qt_qml_path = qt_path for folder in qt_qml_path.joinpath("qml").iterdir(): if not folder.is_file(): - shutil.copytree(str(folder), str(bin_dir.joinpath(folder.name))) + shutil.copytree(str(folder), str( + bin_dir.joinpath(folder.name))) print("Copied %s" % folder) - # Copy all plugin folder from qt_path plugins subfolder into bin_dir qt_plugins_path = qt_path for folder in qt_path.joinpath("plugins").iterdir(): if not folder.is_file(): - shutil.copytree(str(folder), str(bin_dir.joinpath(folder.name))) + shutil.copytree(str(folder), str( + bin_dir.joinpath(folder.name))) print("Copied %s" % folder) # Copy all folder from qt_path translation files into bin_dir translation folder qt_translations_path = qt_path for folder in qt_translations_path.joinpath("translations").iterdir(): if not folder.is_file(): - shutil.copytree(str(folder), str(bin_dir.joinpath("translations").joinpath(folder.name))) + shutil.copytree(str(folder), str( + bin_dir.joinpath("translations").joinpath(folder.name))) print("Copied %s" % folder) # Copy all filesfrom qt_path resources folder into bin_dir folder @@ -292,9 +262,9 @@ if __name__ == "__main__": else: print("Not executing deploy commands due to missing dependencies.") - + # Post-build - if platform.system() == "Darwin" and args.sign_build: + if platform.system() == "Darwin" and sign_build: run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --entitlements \"../../ScreenPlay/entitlements.plist\" --deep \"ScreenPlay.app/\"", cwd=bin_dir) run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWallpaper.app/\"", cwd=bin_dir) @@ -304,7 +274,6 @@ if __name__ == "__main__": run("codesign --verify --verbose=4 \"ScreenPlayWallpaper.app/\"", cwd=bin_dir) run("codesign --verify --verbose=4 \"ScreenPlayWidget.app/\"", cwd=bin_dir) - run("xcnotary notarize ScreenPlay.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir), run("xcnotary notarize ScreenPlayWallpaper.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir), run("xcnotary notarize ScreenPlayWidget.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir) @@ -316,7 +285,8 @@ if __name__ == "__main__": # Some dlls like openssl do no longer get copied automatically. # Lets just copy all of them into bin. if platform.system() == "Windows": - vcpkg_bin_path = Path(f"{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").resolve() + vcpkg_bin_path = Path( + f"{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").resolve() print(vcpkg_bin_path) for file in vcpkg_bin_path.iterdir(): if file.suffix == ".dll" and file.is_file(): @@ -329,21 +299,112 @@ if __name__ == "__main__": print("Remove: %s" % file.resolve()) file.unlink() - if args.create_installer: + if create_installer == "ON": os.chdir(build_folder) print("Running cpack at: ", os.getcwd()) run("cpack", cwd=build_folder) # We also need to sign the installer in osx: - if platform.system() == "Darwin" and args.sign_build: + if platform.system() == "Darwin" and sign_build: run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder) run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder) run("xcnotary notarize ScreenPlay-Installer.dmg/ScreenPlay-Installer.app -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder) run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/\"", cwd=build_folder) run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/\"", cwd=build_folder) - run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/\"", cwd=build_folder) + run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/\"", + cwd=build_folder) run("xcnotary notarize ScreenPlay-Installer.dmg -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder) - run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/\"", cwd=build_folder) + run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/\"", + cwd=build_folder) + + # Create a zip file for scoop + if platform.system() == "Windows": + zipName = f"ScreenPlay-{SCREENPLAY_VERSION}-{cmake_target_triplet}-{build_type}.zip" + print(f"Creating scoop zip file: \n{bin_dir} \n{zipName}") + os.chdir(build_folder) + with zipfile.ZipFile(zipName, 'w', zipfile.ZIP_DEFLATED) as zipf: + zipdir(bin_dir, zipf) print("Time taken: {}s".format(time.time() - start_time)) + + +if __name__ == "__main__": + + parser = argparse.ArgumentParser( + description='Build and Package ScreenPlay') + + parser.add_argument('-qt-version', action="store", dest="qt_version_overwrite", + help="Overwrites the default Qt version") + parser.add_argument('-qt-installer-version', action="store", dest="qt_installer_version_overwrite", + help="Overwrites the default Qt installer framework version") + parser.add_argument('-type', action="store", dest="build_type", + help="Build type. This is either debug or release.") + parser.add_argument('-use-aqt', action="store_true", dest="use_aqt", + help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.") + parser.add_argument('-sign', action="store_true", dest="sign_build", + help="Enable if you want to sign the apps. This is macOS only for now.") + parser.add_argument('-steam', action="store_true", dest="build_steam", + help="Enable if you want to build the Steam workshop plugin.") + parser.add_argument('-tests', action="store_true", dest="build_tests", + help="Build tests.") + parser.add_argument('-installer', action="store_true", dest="create_installer", + help="Create a installer.") + parser.add_argument('-release', action="store_true", dest="build_release", + help="Create a release version of ScreenPlay for sharing with the world. This is not about debug/release build, but the c++ define SCREENPLAY_RELEASE.") + args = parser.parse_args() + + qt_version = "6.3.0" + qt_ifw_version = "4.4" # Not yet used. + qt_version_overwrite = "" + use_aqt = False + + if args.qt_version_overwrite: + qt_version = args.qt_version_overwrite + print("Using Qt version {qt_version}") + + if args.qt_installer_version_overwrite: + qt_ifw_version = args.qt_installer_version_overwrite + print("Using Qt installer framework version {qt_ifw_version}") + + if args.build_steam and not args.build_release: + print("Steam Builds must have release option enabled via -release") + exit(4) + + if not args.build_type: + print("Build type argument is missing (release, debug). E.g: python build.py -type release -steam") + print( + f"Defaulting to Qt version: {qt_version}. This can be overwritten via -qt-version 6.5.0") + exit(1) + build_type = args.build_type + + build_steam = "OFF" + if args.build_steam: + build_steam = "ON" + + build_tests = "OFF" + if args.build_tests: + build_tests = "ON" + + build_release = "OFF" + if args.build_release: + build_release = "ON" + + create_installer = "OFF" + if args.create_installer: + create_installer = "ON" + sign_build ="OFF" + if args.sign_build: + sign_build = "ON" + + build( + qt_version, + qt_ifw_version, + build_steam, + build_tests, + build_release, + create_installer, + build_type, + sign_build, + args.use_aqt + ) diff --git a/Tools/build_and_publish.py b/Tools/build_and_publish.py new file mode 100644 index 00000000..d4472f89 --- /dev/null +++ b/Tools/build_and_publish.py @@ -0,0 +1,32 @@ +import build +import steam_publish +import argparse +import os +from pathlib import Path + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Build and Package ScreenPlay') + parser.add_argument('-steam_password', action="store", dest="steam_password", required=True, help="Steam password") + args = parser.parse_args() + + # Script needs to run in the tools folder + tools_path = Path.cwd() + os.chdir(tools_path) + build( + qt_version="6.4.0", + qt_ifw_version="4.4", + build_steam="ON", + build_tests="OFF", + build_release="ON", + create_installer="ON", + build_type="release", + sign_build=False, + use_aqt=False + ) + # Make sure to reset to tools path + os.chdir(tools_path) + steam_publish( + steam_username="tachiom", + steam_password=args.steam_password, + set_live_branch_name="internal" + ) diff --git a/Tools/steam_publish.py b/Tools/steam_publish.py index 38ee5c6b..155e6eb2 100644 --- a/Tools/steam_publish.py +++ b/Tools/steam_publish.py @@ -21,20 +21,14 @@ def get_git_revision_short_hash(): def get_git_commit_text(): return subprocess.check_output(['git', 'log', '-1', '--pretty=%B']) +def steam_publish( + steam_username, + steam_password, + set_live_branch_name +): -# MAIN -parser = argparse.ArgumentParser(description='Publish ScreenPlay to Steam') -parser.add_argument('-u', action="store", dest="steam_username", required=True, - help="Steam Username.") -parser.add_argument('-p', action="store", dest="steam_password", required=True, - help="Steam Password.") -parser.add_argument('-c', action="store", dest="vdf_config_name", - help="Name to the .vdf config. This will use the .vdf files from the steamcmd folder.") -args = parser.parse_args() - -vdf_config_name = "" -depot_config_name = "" -if not args.vdf_config_name: + vdf_config_name = "" + depot_config_name = "" if platform == "win32": vdf_config_name = "app_build_windows.vdf" depot_config_name = "depot_build_windows.vdf" @@ -44,45 +38,72 @@ if not args.vdf_config_name: elif platform == "linux": vdf_config_name = "app_build_linux.vdf" depot_config_name = "depot_build_linux.vdf" - print("No vdf config provided, using default: " + vdf_config_name) -else: - vdf_config_name = args.vdf_config_name -abs_vdf_path = os.path.abspath("steamcmd/" + vdf_config_name) -if not os.path.isfile(abs_vdf_path): - print("Incorrect vdf name") - sys.exit(-1) + abs_vdf_path = os.path.abspath("steamcmd/" + vdf_config_name) -file = open(abs_vdf_path, "r") + if not os.path.isfile(abs_vdf_path): + print("Incorrect vdf name") + sys.exit(-1) -config_content = file.read() -git_hash = get_git_revision_short_hash().decode("utf-8").replace("\n", "") -git_commit_text = get_git_commit_text().decode("utf-8").replace("\n", "") -current_date_time = datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + file = open(abs_vdf_path, "r") -build_description = "- git hash: " + git_hash + ", commit: " + git_commit_text + " - upload datetime: " + current_date_time -config_content = config_content.replace("{{BUILD_DESCRIPTION}}", build_description) -tmp_steam_config_foldername = "tmp_steam_config/" -tmp_steam_config_dir = os.path.abspath(tmp_steam_config_foldername) + config_content = file.read() + git_hash = get_git_revision_short_hash().decode("utf-8").replace("\n", "") + git_commit_text = get_git_commit_text().decode("utf-8").replace("\n", "") + current_date_time = datetime.now().strftime("%m/%d/%Y, %H:%M:%S") -if os.path.isdir(tmp_steam_config_dir): + build_description = "- git hash: " + git_hash + ", commit: " + git_commit_text + " - upload datetime: " + current_date_time + config_content = config_content.replace("{{BUILD_DESCRIPTION}}", build_description) + config_content = config_content.replace("{{SET_LIVE_ON_BRANCH}}", set_live_branch_name) + tmp_steam_config_foldername = "tmp_steam_config/" + tmp_steam_config_dir = os.path.abspath(tmp_steam_config_foldername) + + if os.path.isdir(tmp_steam_config_dir): + shutil.rmtree(tmp_steam_config_dir) + + os.mkdir(tmp_steam_config_dir) + + f = open(os.path.abspath(tmp_steam_config_dir + "/" + vdf_config_name), "w") + f.write(config_content) + f.close() + + print(f"Using config:\n {config_content}\n") + + # We also must copy the depot file + abs_depot_path = os.path.abspath("steamcmd/" + depot_config_name) + copyfile(abs_depot_path, tmp_steam_config_dir + "/" + depot_config_name) + + tmp_steam_config_path = "\"" + os.path.abspath(tmp_steam_config_foldername + vdf_config_name) + "\"" + + print("Execute steamcmd on: " + tmp_steam_config_path) + execute("steamcmd +login {username} {password} +run_app_build {config} +quit".format(username=steam_username, password=steam_password, config=tmp_steam_config_path)) + + print("Deleting tmp config") shutil.rmtree(tmp_steam_config_dir) -os.mkdir(tmp_steam_config_dir) +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Publish ScreenPlay to Steam') + parser.add_argument('-steam_username', action="store", dest="steam_username", required=True, + help="Steam Username.") + parser.add_argument('-steam_password', action="store", dest="steam_password", required=True, + help="Steam Password.") + parser.add_argument('-set_live_branch_name', action="store", dest="set_live_branch_name", + help="Branch name. Defaults to internal") + parser.add_argument('-steam_config', action="store", dest="vdf_config_name", + help="Name to the .vdf config. This will use the .vdf files from the steamcmd folder.") + args = parser.parse_args() -f = open(os.path.abspath(tmp_steam_config_dir + "/" + vdf_config_name), "w") -f.write(config_content) -f.close() + if not args.steam_username or not args.steam_password: + exit(1) -# We also must copy the depot file -abs_depot_path = os.path.abspath("steamcmd/" + depot_config_name) -copyfile(abs_depot_path, tmp_steam_config_dir + "/" + depot_config_name) + if args.set_live_branch_name: + set_live_branch_name = args.set_live_branch_name + else: + set_live_branch_name = "internal" -tmp_steam_config_path = "\"" + os.path.abspath(tmp_steam_config_foldername + vdf_config_name) + "\"" - -print("Execute steamcmd on: " + tmp_steam_config_path) -execute("steamcmd +login {username} {password} +run_app_build {config} +quit".format(username=args.steam_username, password=args.steam_password, config=tmp_steam_config_path)) - -print("Deleting tmp config") -shutil.rmtree(tmp_steam_config_dir) + steam_publish( + steam_username=args.steam_username, + steam_password=args.steam_password, + set_live_branch_name=set_live_branch_name + ) \ No newline at end of file diff --git a/Tools/steamcmd/app_build_linux.vdf b/Tools/steamcmd/app_build_linux.vdf index 17298b40..900d2358 100644 --- a/Tools/steamcmd/app_build_linux.vdf +++ b/Tools/steamcmd/app_build_linux.vdf @@ -4,7 +4,7 @@ "desc" "CI Build linux {{BUILD_DESCRIPTION}}" "buildoutput" "../../ContentBuilder/output" // build output folder for .log, .csm & .csd files, relative to location of this file "contentroot" "../../" // root content folder, relative to location of this file - "setlive" "internal" // branch to set live after successful build, none if empty + "setlive" "{{SET_LIVE_ON_BRANCH}}" // branch to set live after successful build, none if empty "preview" "0" // to enable preview builds "nobaseline" "0" // build without using baseline manifest diff --git a/Tools/steamcmd/app_build_mac.vdf b/Tools/steamcmd/app_build_mac.vdf index 10c23d86..6098dd0c 100644 --- a/Tools/steamcmd/app_build_mac.vdf +++ b/Tools/steamcmd/app_build_mac.vdf @@ -4,7 +4,7 @@ "desc" "CI Build mac {{BUILD_DESCRIPTION}}" "buildoutput" "../../ContentBuilder/output" // build output folder for .log, .csm & .csd files, relative to location of this file "contentroot" "../../" // root content folder, relative to location of this file - "setlive" "internal" // branch to set live after successful build, none if empty + "setlive" "{{SET_LIVE_ON_BRANCH}}" // branch to set live after successful build, none if empty "preview" "0" // to enable preview builds "nobaseline" "0" // build without using baseline manifest diff --git a/Tools/steamcmd/app_build_windows.vdf b/Tools/steamcmd/app_build_windows.vdf index 6875682d..401bac5e 100644 --- a/Tools/steamcmd/app_build_windows.vdf +++ b/Tools/steamcmd/app_build_windows.vdf @@ -4,7 +4,7 @@ "desc" "CI Build Windows {{BUILD_DESCRIPTION}}" "buildoutput" "../../ContentBuilder/output" // build output folder for .log, .csm & .csd files, relative to location of this file "contentroot" "../../" // root content folder, relative to location of this file - "setlive" "internal" // branch to set live after successful build, none if empty + "setlive" "{{SET_LIVE_ON_BRANCH}}" // branch to set live after successful build, none if empty "preview" "0" // to enable preview builds "nobaseline" "0" // build without using baseline manifest diff --git a/Tools/steamcmd/depot_build_mac_arm.vdf b/Tools/steamcmd/depot_build_mac_arm.vdf new file mode 100644 index 00000000..ff9375cc --- /dev/null +++ b/Tools/steamcmd/depot_build_mac_arm.vdf @@ -0,0 +1,13 @@ +"DepotBuildConfig" +{ + "DepotID" "672872" + + // include all files recursively + "FileMapping" + { + "LocalPath" "build-arm64-osx-release/bin/*" + "DepotPath" "." + "recursive" "1" + } + +} \ No newline at end of file