From efc70e9fc0446d34e8429ef86d9b8643ecfb0f06 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 11 Aug 2023 17:00:24 +0200 Subject: [PATCH 01/36] Change CI to split into multile sections Change version to be only set via git tags --- .gitlab-ci.yml | 117 ++---------------------------- .gitlab/ci/base_jobs.yml | 46 ++++++++++++ .gitlab/ci/build_jobs.yml | 34 +++++++++ .gitlab/ci/build_release_jobs.yml | 26 +++++++ .gitlab/ci/check_jobs.yml | 16 ++++ CMake/CMakeLists.txt | 1 + CMake/GetProjectVersion.cmake | 32 ++++++++ CMakeLists.txt | 8 +- Tools/build.py | 87 +++++++++++++--------- 9 files changed, 221 insertions(+), 146 deletions(-) create mode 100644 .gitlab/ci/base_jobs.yml create mode 100644 .gitlab/ci/build_jobs.yml create mode 100644 .gitlab/ci/build_release_jobs.yml create mode 100644 .gitlab/ci/check_jobs.yml create mode 100644 CMake/GetProjectVersion.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dd01c5fc..7e569279 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,118 +1,13 @@ +include: + - ".gitlab/ci/base_jobs.yml" + - ".gitlab/ci/build_jobs.yml" + - ".gitlab/ci/build__release_jobs.yml" + - ".gitlab/ci/check_jobs.yml" + stages: - build - check -.base_windows_build: - before_script: - - python -m pip install -U pip wheel - - python -m pip install -r Tools/requirements.txt - - python Tools/setup.py - -.base_linux_build: - before_script: - # Otherwise libglib2 needs interaction - - export DEBIAN_FRONTEND=noninteractive - - apt update -y - - apt install curl wget zip unzip tar git pkg-config libxcb-* libfontconfig-dev apt-transport-https ca-certificates gnupg software-properties-common python3 python3-pip build-essential libgl1-mesa-dev mesa-common-dev lld ninja-build libxkbcommon-* libx11-dev xserver-xorg-dev xorg-dev -y - - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null - - echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal-rc main' | tee -a /etc/apt/sources.list.d/kitware.list >/dev/null - - apt update -y - - apt install cmake -y - - python3 -m pip install -U pip - - python3 -m pip install -r Tools/requirements.txt - - python3 Tools/setup.py - -.base_osx_build: - before_script: - - pip3 install -U pip - - pip3 install -r Tools/requirements.txt - - python3 Tools/setup.py - -standalone_windows: - stage: build - extends: - - .base_windows_build - tags: - - windows10 - script: - - python Tools/build.py -type release -use-aqt -installer -deploy-version - artifacts: - expire_in: "2 weeks" - paths: - - build-x64-windows-release/bin/ - - build-x64-windows-release/ScreenPlay-Installer.exe - -standalone_osx: - stage: build - extends: - - .base_osx_build - tags: - - osx - script: - - python3 Tools/build.py -type release -use-aqt -deploy-version -sign_osx - artifacts: - expire_in: "2 weeks" - paths: - - build-64-osx-universal-release/bin/ - -standalone_linux: - stage: build - extends: - - .base_linux_build - image: - name: ubuntu:20.04 - tags: - - gitlab-org-docker - script: - - python3 Tools/build.py -type release -deploy-version -use-aqt -installer - artifacts: - expire_in: "4 weeks" - paths: - - build-x64-linux-release/bin/ - -steam_windows: - stage: build - extends: - - .base_windows_build - tags: - - windows10 - script: - - python Tools/build.py -type release -steam -use-aqt -deploy-version - artifacts: - expire_in: "2 weeks" - paths: - - build-x64-windows-release/bin/ - -steam_osx: - stage: build - extends: - - .base_osx_build - tags: - - osx - script: - - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -sign_osx - artifacts: - expire_in: "2 weeks" - paths: - - build-64-osx-universal-release/bin/ - -formatting: - stage: check - allow_failure: true - image: - name: ubuntu:20.04 - tags: - - gitlab-org-docker - before_script: - - apt-get update -y - - apt-get install python3-pip python-is-python3 clang clang-format -y - script: - - python -m pip install -U pip wheel - - python -m pip install -U cmakelang - - cd Tools - - python clang_format.py - - python cmake_format.py - documentation: stage: .post script: diff --git a/.gitlab/ci/base_jobs.yml b/.gitlab/ci/base_jobs.yml new file mode 100644 index 00000000..3c345ca0 --- /dev/null +++ b/.gitlab/ci/base_jobs.yml @@ -0,0 +1,46 @@ +.base_windows_build: + before_script: + - python -m pip install -U pip wheel + - python -m pip install -r Tools/requirements.txt + - python Tools/setup.py + tags: + - windows10 + artifacts: + expire_in: "2 weeks" + paths: + - build-x64-windows-release/bin/ + - build-x64-windows-release/ScreenPlay-Installer.exe + +.base_linux_build: + before_script: + # Otherwise libglib2 needs interaction + - export DEBIAN_FRONTEND=noninteractive + - apt update -y + - apt install curl wget zip unzip tar git pkg-config libxcb-* libfontconfig-dev apt-transport-https ca-certificates gnupg software-properties-common python3 python3-pip build-essential libgl1-mesa-dev mesa-common-dev lld ninja-build libxkbcommon-* libx11-dev xserver-xorg-dev xorg-dev -y + - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null + - echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal-rc main' | tee -a /etc/apt/sources.list.d/kitware.list >/dev/null + - apt update -y + - apt install cmake -y + - python3 -m pip install -U pip + - python3 -m pip install -r Tools/requirements.txt + - python3 Tools/setup.py + image: + name: ubuntu:20.04 + tags: + - gitlab-org-docker + artifacts: + expire_in: "4 weeks" + paths: + - build-x64-linux-release/bin/ + +.base_osx_build: + before_script: + - pip3 install -U pip + - pip3 install -r Tools/requirements.txt + - python3 Tools/setup.py + tags: + - osx + artifacts: + expire_in: "2 weeks" + paths: + - build-64-osx-universal-release/bin/ diff --git a/.gitlab/ci/build_jobs.yml b/.gitlab/ci/build_jobs.yml new file mode 100644 index 00000000..b06e328d --- /dev/null +++ b/.gitlab/ci/build_jobs.yml @@ -0,0 +1,34 @@ +standalone_windows: + stage: build + extends: + - .base_windows_build + script: + - python Tools/build.py -type release -use-aqt -installer -deploy-version + +standalone_osx: + stage: build + extends: + - .base_osx_build + script: + - python3 Tools/build.py -type release -use-aqt -deploy-version -sign_osx + +standalone_linux: + stage: build + extends: + - .base_linux_build + script: + - python3 Tools/build.py -type release -deploy-version -use-aqt -installer + +steam_windows: + stage: build + extends: + - .base_windows_build + script: + - python Tools/build.py -type release -steam -use-aqt -deploy-version + +steam_osx: + stage: build + extends: + - .base_osx_build + script: + - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -sign_osx diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml new file mode 100644 index 00000000..255298b8 --- /dev/null +++ b/.gitlab/ci/build_release_jobs.yml @@ -0,0 +1,26 @@ +steam_linux: + stage: build + extends: + - .base_linux_build + script: + - python3 Tools/build.py -type release -steam -deploy-version -use-aqt -installer --tag $CI_COMMIT_TAG + rules: + - if: "$CI_COMMIT_TAG" + +steam_windows: + stage: build + extends: + - .base_windows_build + script: + - python Tools/build.py -type release -steam -use-aqt -deploy-version --tag $CI_COMMIT_TAG + rules: + - if: "$CI_COMMIT_TAG" + +steam_osx: + stage: build + extends: + - .base_osx_build + script: + - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -sign_osx --tag $CI_COMMIT_TAG + rules: + - if: "$CI_COMMIT_TAG" diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml new file mode 100644 index 00000000..d3dbb6ae --- /dev/null +++ b/.gitlab/ci/check_jobs.yml @@ -0,0 +1,16 @@ +formatting: + stage: check + allow_failure: true + image: + name: ubuntu:20.04 + tags: + - gitlab-org-docker + before_script: + - apt-get update -y + - apt-get install python3-pip python-is-python3 clang clang-format -y + script: + - python -m pip install -U pip wheel + - python -m pip install -U cmakelang + - cd Tools + - python clang_format.py + - python cmake_format.py diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index 124d6949..b1d75b0d 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -2,6 +2,7 @@ project(CMake) set(FILES CMakeVariables.h.in + GetProjectVersion.cmake GenerateCMakeVariableHeader.cmake CopyRecursive.cmake CreateIFWInstaller.cmake) diff --git a/CMake/GetProjectVersion.cmake b/CMake/GetProjectVersion.cmake new file mode 100644 index 00000000..f714bcba --- /dev/null +++ b/CMake/GetProjectVersion.cmake @@ -0,0 +1,32 @@ +# Function: get_project_version +# +# Description: +# Fetches the project version from the latest Git tag. If Git is not found or +# the current directory is not a Git repository, it defaults to "0.0.0". +# +# Parameters: +# - VERSION_VAR: The name of the variable in which the fetched or default version will be stored. +# +# Example Usage: +# get_project_version(PROJECT_VERSION) +# message(STATUS "Version: ${PROJECT_VERSION}") +# +function(get_project_version VERSION_VAR) + find_package(Git) + if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --always + OUTPUT_VARIABLE GIT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + + string(REPLACE "V" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'V' prefix + string(REPLACE "-" ";" VERSION_LIST ${STRIPPED_VERSION}) + list(GET VERSION_LIST 0 VERSION_STRING) + + set(${VERSION_VAR} ${VERSION_STRING} PARENT_SCOPE) + else() + set(${VERSION_VAR} "0.0.0" PARENT_SCOPE) + endif() +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 42fcbb95..b8e1bedf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,13 @@ cmake_minimum_required(VERSION 3.23.0) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) +include(GetProjectVersion) +get_project_version(PROJECT_VERSION) +message(STATUS "Version: ${PROJECT_VERSION}") + project( ScreenPlay - VERSION 0.15.0 + VERSION ${PROJECT_VERSION} DESCRIPTION "Modern, Cross Plattform, Live Wallpaper, Widgets and AppDrawer!" HOMEPAGE_URL "https://screen-play.app/" LANGUAGES CXX) @@ -21,7 +26,6 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_CXX_STANDARD 20) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) set(THIRD_PARTY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/") option(OSX_BUNDLE "Enable distribution macOS bundle" OFF) diff --git a/Tools/build.py b/Tools/build.py index bb392231..464d54fc 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -11,7 +11,7 @@ import defines from typing import Tuple from pathlib import Path import macos_sign -from util import sha256, cd_repo_root_path,repo_root_path, zipdir, run, get_vs_env_dict +from util import sha256, cd_repo_root_path, repo_root_path, zipdir, run, get_vs_env_dict from sys import stdout stdout.reconfigure(encoding='utf-8') @@ -25,7 +25,7 @@ def clean_build_dir(build_dir): build_dir.mkdir(parents=True, exist_ok=True) -class BuildResult: +class BuildResult: # Windows example with absolute paths: # [...]/build-x64-windows-release/ build: Path @@ -42,6 +42,7 @@ class BuildResult: # x64, arm64, universal build_arch: str + class BuildConfig: root_path: str cmake_osx_architectures: str @@ -51,8 +52,8 @@ class BuildConfig: package_command: str executable_file_ending: str # qt_* use either aqt or from the maintenance tool - qt_path: str # C:\Qt - qt_bin_path: str # C:\Qt\6.3.2\msvc2019_64 + qt_path: str # C:\Qt + qt_bin_path: str # C:\Qt\6.3.2\msvc2019_64 qt_version: str qt_ifw_version: str ifw_root_path: str @@ -90,12 +91,12 @@ def execute( # 3rd party tools like the crashreporter create local # temporary files in the build directory. clean_build_dir(build_config.build_folder) - + # Runs cmake configure and cmake build step_time = time.time() build_result = build(build_config, build_result) build_duration = time.time() - step_time - #print(f"ā±ļø build_duration (for {build_config.build_architecture}): {build_duration}s") + # print(f"ā±ļø build_duration (for {build_config.build_architecture}): {build_duration}s") # Copies all needed libraries and assets into the bin folder step_time = time.time() @@ -122,9 +123,11 @@ def execute( # Print BuildConfig & BuildResult member for easier debugging print("\nšŸ†— BuildResult:") - print(' '.join("\n- %s: \t\t%s" % item for item in vars(build_result).items())) + print(' '.join("\n- %s: \t\t%s" % + item for item in vars(build_result).items())) print("\nāš™ļø BuildConfig:") - print(' '.join("\n- %s: \t\t%s" % item for item in vars(build_config).items())) + print(' '.join("\n- %s: \t\t%s" % + item for item in vars(build_config).items())) return build_result @@ -134,10 +137,13 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]: build_config.qt_path = defines.QT_PATH if not build_config.qt_path.exists(): - print(f"Qt path does not exist at {build_config.qt_path}. Please make sure to run setup.py!") + print( + f"Qt path does not exist at {build_config.qt_path}. Please make sure to run setup.py!") exit(2) - build_config.qt_bin_path = Path(build_config.qt_path).joinpath(f"{build_config.qt_version}/{defines.QT_PLATFORM}").resolve() - build_config.ifw_root_path = Path(f"{build_config.qt_path}/Tools/QtInstallerFramework/{build_config.qt_ifw_version}").resolve() + build_config.qt_bin_path = Path(build_config.qt_path).joinpath( + f"{build_config.qt_version}/{defines.QT_PLATFORM}").resolve() + build_config.ifw_root_path = Path( + f"{build_config.qt_path}/Tools/QtInstallerFramework/{build_config.qt_ifw_version}").resolve() if platform.system() == "Windows": build_config.cmake_target_triplet = "x64-windows" @@ -157,10 +163,10 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]: build_config.cmake_target_triplet = "64-osx-universal" build_config.executable_file_ending = ".app" # NO f string we fill it later! - #build_config.package_command = "{prefix_path}/bin/macdeployqt ScreenPlay.app -qmldir=../../{app}/qml -executable=ScreenPlay.app/Contents/MacOS/{app} -appstore-compliant -timestamp -hardened-runtime" + # build_config.package_command = "{prefix_path}/bin/macdeployqt ScreenPlay.app -qmldir=../../{app}/qml -executable=ScreenPlay.app/Contents/MacOS/{app} -appstore-compliant -timestamp -hardened-runtime" build_config.aqt_install_qt_packages = f"mac desktop {build_config.qt_version} clang_64 -m all" build_config.aqt_install_tool_packages = "mac desktop tools_ifw" - + elif platform.system() == "Linux": build_config.cmake_target_triplet = "x64-linux" build_config.executable_file_ending = "" @@ -171,21 +177,27 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]: "Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.") # Prepare - build_config.cmake_toolchain_file = Path(f"{build_config.root_path}/../vcpkg/scripts/buildsystems/vcpkg.cmake").resolve() + build_config.cmake_toolchain_file = Path( + f"{build_config.root_path}/../vcpkg/scripts/buildsystems/vcpkg.cmake").resolve() print(f"cmake_toolchain_file: {build_config.cmake_toolchain_file}") print(f"Starting build with type {build_config.build_type}.") - print(f"Qt Version: {build_config.qt_version}. Root path: {build_config.root_path}") + print( + f"Qt Version: {build_config.qt_version}. Root path: {build_config.root_path}") # Remove old build folder to before configuring to get rid of all cmake chaches - build_config.build_folder = build_config.root_path.joinpath(f"build-{build_config.cmake_target_triplet}-{build_config.build_type}") + build_config.build_folder = build_config.root_path.joinpath( + f"build-{build_config.cmake_target_triplet}-{build_config.build_type}") build_config.bin_dir = build_config.build_folder.joinpath("bin") if platform.system() == "Windows": - build_result.installer = Path(build_config.build_folder).joinpath("ScreenPlay-Installer.exe") + build_result.installer = Path(build_config.build_folder).joinpath( + "ScreenPlay-Installer.exe") elif platform.system() == "Darwin": - build_result.installer = Path(build_config.build_folder).joinpath("ScreenPlay.dmg") + build_result.installer = Path( + build_config.build_folder).joinpath("ScreenPlay.dmg") elif platform.system() == "Linux": - build_result.installer = Path(build_config.build_folder).joinpath("ScreenPlay-Installer.run") + build_result.installer = Path(build_config.build_folder).joinpath( + "ScreenPlay-Installer.run") return build_config, build_result @@ -220,21 +232,26 @@ def package(build_config: BuildConfig): if platform.system() == "Darwin": # Make sure to reset to tools path os.chdir(repo_root_path()) - cmd_raw = "{qt_bin_path}/macdeployqt {build_bin_dir}/ScreenPlay.app -qmldir={repo_root_path}/{app}/qml -executable={build_bin_dir}/ScreenPlay.app/Contents/MacOS/{app} -verbose=1 -appstore-compliant -timestamp -hardened-runtime " # -sign-for-notarization=\"Developer ID Application: Elias Steurer (V887LHYKRH)\" - build_bin_dir = Path(repo_root_path()).joinpath(f"{build_config.build_folder}/bin/") - cwd = Path(repo_root_path()).joinpath(f"{build_bin_dir}/ScreenPlay.app/Contents/MacOS/") + # -sign-for-notarization=\"Developer ID Application: Elias Steurer (V887LHYKRH)\" + cmd_raw = "{qt_bin_path}/macdeployqt {build_bin_dir}/ScreenPlay.app -qmldir={repo_root_path}/{app}/qml -executable={build_bin_dir}/ScreenPlay.app/Contents/MacOS/{app} -verbose=1 -appstore-compliant -timestamp -hardened-runtime " + build_bin_dir = Path(repo_root_path()).joinpath( + f"{build_config.build_folder}/bin/") + cwd = Path(repo_root_path()).joinpath( + f"{build_bin_dir}/ScreenPlay.app/Contents/MacOS/") qt_bin_path = Path(defines.QT_BIN_PATH).resolve() source_path = Path(repo_root_path()).resolve() - run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path,repo_root_path=source_path, build_bin_dir=build_bin_dir, app="ScreenPlay"), cwd=cwd) - run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path,repo_root_path=source_path, build_bin_dir=build_bin_dir, app="ScreenPlayWallpaper"), cwd=cwd) - run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path,repo_root_path=source_path, build_bin_dir=build_bin_dir, app="ScreenPlayWidget"), cwd=cwd) + run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path, + build_bin_dir=build_bin_dir, app="ScreenPlay"), cwd=cwd) + run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path, + build_bin_dir=build_bin_dir, app="ScreenPlayWallpaper"), cwd=cwd) + run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path, + build_bin_dir=build_bin_dir, app="ScreenPlayWidget"), cwd=cwd) - if(build_config.sign_osx): + if (build_config.sign_osx): print(f"Sign binary at: {build_config.bin_dir}") macos_sign.sign(build_config=build_config) - if platform.system() == "Windows": print("Executing deploy commands...") run(build_config.package_command.format( @@ -291,8 +308,6 @@ def package(build_config: BuildConfig): shutil.copy(str(file), str(build_config.bin_dir)) print("Copied %s" % file) - - # Some dlls like openssl do no longer get copied automatically. # Lets just copy all of them into bin. if platform.system() == "Windows": @@ -326,6 +341,7 @@ def build_installer(build_config: BuildConfig, build_result: BuildResult): print("Running cpack at: ", os.getcwd()) run("cpack", cwd=build_config.build_folder) + def zip(build_config: BuildConfig, build_result: BuildResult) -> BuildResult: zipName = f"ScreenPlay-{build_config.screenplay_version}-{build_config.cmake_target_triplet}-{build_config.build_type}.zip" build_result.build_zip = Path(build_result.build).joinpath(zipName) @@ -346,9 +362,11 @@ def zip(build_config: BuildConfig, build_result: BuildResult) -> BuildResult: # Some weird company firewalls do not allow direct .exe downloads # lets just zip the installer lol if build_config.create_installer == "ON": - build_result.installer_zip = Path(build_result.build).joinpath(build_result.installer.stem + ".zip") + build_result.installer_zip = Path(build_result.build).joinpath( + build_result.installer.stem + ".zip") print(f"Create zip from installer: {build_result.installer_zip}") - zipfile.ZipFile(build_result.installer_zip, 'w').write(build_result.installer, build_result.installer.name) + zipfile.ZipFile(build_result.installer_zip, 'w').write( + build_result.installer, build_result.installer.name) return build_result @@ -357,7 +375,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser( description='Build and Package ScreenPlay') - + parser.add_argument('--tag', type=str, help="GitLab CI tag", default="") 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", @@ -381,7 +399,10 @@ if __name__ == "__main__": args = parser.parse_args() qt_version = defines.QT_VERSION - screenplay_version = defines.SCREENPLAY_VERSION + if args.tag: + screenplay_version = args.tag + else: + screenplay_version = defines.SCREENPLAY_VERSION qt_ifw_version = defines.QT_IFW_VERSION # Not yet used. qt_version_overwrite: str use_aqt = False From 799f4978be25303590d2ba4c770e9544a988f78e Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 11 Aug 2023 17:01:37 +0200 Subject: [PATCH 02/36] Fix path --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e569279..f99a689e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ include: - ".gitlab/ci/base_jobs.yml" - ".gitlab/ci/build_jobs.yml" - - ".gitlab/ci/build__release_jobs.yml" + - ".gitlab/ci/build_release_jobs.yml" - ".gitlab/ci/check_jobs.yml" stages: From ebff53948c688a3ccbd90dfbdae8875bbedd2054 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Aug 2023 11:53:34 +0200 Subject: [PATCH 03/36] Change build args to have double - Split builds into regular and official git tag release builds --- .gitlab-ci.yml | 4 ++++ .gitlab/ci/build_jobs.yml | 17 ++++++++++++----- .gitlab/ci/build_release_jobs.yml | 12 ++++++------ .gitlab/ci/check_jobs.yml | 2 +- .vscode/tasks.json | 8 ++++---- Tools/build.py | 20 ++++++++++---------- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f99a689e..fa1c3d20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,11 @@ include: - ".gitlab/ci/check_jobs.yml" stages: + # Regular build for every commit - build + # Git release tag builds + - release_build + # Checks for source code formattings - check documentation: diff --git a/.gitlab/ci/build_jobs.yml b/.gitlab/ci/build_jobs.yml index b06e328d..1e0e3b9a 100644 --- a/.gitlab/ci/build_jobs.yml +++ b/.gitlab/ci/build_jobs.yml @@ -3,32 +3,39 @@ standalone_windows: extends: - .base_windows_build script: - - python Tools/build.py -type release -use-aqt -installer -deploy-version + - python Tools/build.py --type=release --use-aqt -installer --deploy-version standalone_osx: stage: build extends: - .base_osx_build script: - - python3 Tools/build.py -type release -use-aqt -deploy-version -sign_osx + - python3 Tools/build.py --type=release --use-aqt --deploy-version --sign_osx standalone_linux: stage: build extends: - .base_linux_build script: - - python3 Tools/build.py -type release -deploy-version -use-aqt -installer + - python3 Tools/build.py --type=release --deploy-version --use-aqt -installer steam_windows: stage: build extends: - .base_windows_build script: - - python Tools/build.py -type release -steam -use-aqt -deploy-version + - python Tools/build.py --type=release -steam --use-aqt --deploy-version steam_osx: stage: build extends: - .base_osx_build script: - - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -sign_osx + - python3 Tools/build.py --type=release -steam --use-aqt --deploy-version --sign_osx + +steam_linux: + stage: build + extends: + - .base_linux_build + script: + - python3 Tools/build.py --type=release -steam --deploy-version --use-aqt -installer diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 255298b8..a60d1aa1 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -1,26 +1,26 @@ steam_linux: - stage: build + stage: release_build extends: - .base_linux_build script: - - python3 Tools/build.py -type release -steam -deploy-version -use-aqt -installer --tag $CI_COMMIT_TAG + - python3 Tools/build.py --type=release --steam --deploy-version --use-aqt -installer --tag $CI_COMMIT_TAG rules: - if: "$CI_COMMIT_TAG" steam_windows: - stage: build + stage: release_build extends: - .base_windows_build script: - - python Tools/build.py -type release -steam -use-aqt -deploy-version --tag $CI_COMMIT_TAG + - python Tools/build.py --type=release --steam --use-aqt --deploy-version --tag $CI_COMMIT_TAG rules: - if: "$CI_COMMIT_TAG" steam_osx: - stage: build + stage: release_build extends: - .base_osx_build script: - - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -sign_osx --tag $CI_COMMIT_TAG + - python3 Tools/build.py --type=release --steam --use-aqt --deploy-version -sign_osx --tag $CI_COMMIT_TAG rules: - if: "$CI_COMMIT_TAG" diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index d3dbb6ae..35e296ab 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -2,7 +2,7 @@ formatting: stage: check allow_failure: true image: - name: ubuntu:20.04 + name: ubuntu:23.10 tags: - gitlab-org-docker before_script: diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0ad99001..3289772a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -102,15 +102,15 @@ "osx": { "args": [ "build.py", - "-type=release", - "-deploy-version", + "--type=release", + "--deploy-version", "-steam" ] }, "args": [ "build.py", - "-type=release", - "-deploy-version", + "--type=release", + "--deploy-version", "-steam" ] }, diff --git a/Tools/build.py b/Tools/build.py index 464d54fc..3a7b1ae7 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -376,25 +376,25 @@ if __name__ == "__main__": parser = argparse.ArgumentParser( description='Build and Package ScreenPlay') parser.add_argument('--tag', type=str, help="GitLab CI tag", default="") - parser.add_argument('-qt-version', action="store", dest="qt_version_overwrite", + 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", + 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", default="release", + parser.add_argument('--type', action="store", dest="build_type", default="release", help="Build type. This is either debug or release.") - parser.add_argument('-use-aqt', action="store_true", dest="use_aqt", + 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('-steam', action="store_true", dest="build_steam", + 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", + parser.add_argument('--tests', action="store_true", dest="build_tests", help="Build tests.") - parser.add_argument('-installer', action="store_true", dest="create_installer", + parser.add_argument('--installer', action="store_true", dest="create_installer", help="Create a installer.") - parser.add_argument('-sign_osx', action="store_true", dest="sign_osx", default=False, + parser.add_argument('--sign_osx', action="store_true", dest="sign_osx", default=False, help="Signs the executable on macOS. This requires a valid Apple Developer ID set up.") - parser.add_argument('-deploy-version', action="store_true", dest="build_deploy", + parser.add_argument('--deploy-version', action="store_true", dest="build_deploy", help="Create a deploy version of ScreenPlay for sharing with the world. A not deploy version is for local development only!") - parser.add_argument('-architecture', action="store", dest="build_architecture", default="", + parser.add_argument('--architecture', action="store", dest="build_architecture", default="", help="Sets the build architecture. Used to build x86 and ARM osx versions. Currently only works with x86_64 and arm64") args = parser.parse_args() From 4bd6cc3da1b7b50c3e32f8f20cd2eccc4539b5f5 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Aug 2023 11:57:36 +0200 Subject: [PATCH 04/36] Add separate steam builds step --- .gitlab-ci.yml | 4 +++- .gitlab/ci/build_jobs.yml | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa1c3d20..0d446915 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,8 +5,10 @@ include: - ".gitlab/ci/check_jobs.yml" stages: - # Regular build for every commit + # None Steam build for every commit - build + # Steam build for every commit + - build_steam # Git release tag builds - release_build # Checks for source code formattings diff --git a/.gitlab/ci/build_jobs.yml b/.gitlab/ci/build_jobs.yml index 1e0e3b9a..23931f12 100644 --- a/.gitlab/ci/build_jobs.yml +++ b/.gitlab/ci/build_jobs.yml @@ -17,24 +17,24 @@ standalone_linux: extends: - .base_linux_build script: - - python3 Tools/build.py --type=release --deploy-version --use-aqt -installer + - python3 Tools/build.py --type=release --use-aqt -installer --deploy-version steam_windows: - stage: build + stage: build_steam extends: - .base_windows_build script: - python Tools/build.py --type=release -steam --use-aqt --deploy-version steam_osx: - stage: build + stage: build_steam extends: - .base_osx_build script: - python3 Tools/build.py --type=release -steam --use-aqt --deploy-version --sign_osx steam_linux: - stage: build + stage: build_steam extends: - .base_linux_build script: From b1cc1587eb09c3f90d3a83490ef87076e9e7339f Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 12 Aug 2023 12:18:39 +0200 Subject: [PATCH 05/36] Fix --installer --- .gitlab/ci/build_jobs.yml | 6 +++--- .gitlab/ci/build_release_jobs.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/ci/build_jobs.yml b/.gitlab/ci/build_jobs.yml index 23931f12..5a7821fb 100644 --- a/.gitlab/ci/build_jobs.yml +++ b/.gitlab/ci/build_jobs.yml @@ -3,7 +3,7 @@ standalone_windows: extends: - .base_windows_build script: - - python Tools/build.py --type=release --use-aqt -installer --deploy-version + - python Tools/build.py --type=release --use-aqt --installer --deploy-version standalone_osx: stage: build @@ -17,7 +17,7 @@ standalone_linux: extends: - .base_linux_build script: - - python3 Tools/build.py --type=release --use-aqt -installer --deploy-version + - python3 Tools/build.py --type=release --use-aqt --installer --deploy-version steam_windows: stage: build_steam @@ -38,4 +38,4 @@ steam_linux: extends: - .base_linux_build script: - - python3 Tools/build.py --type=release -steam --deploy-version --use-aqt -installer + - python3 Tools/build.py --type=release -steam --deploy-version --use-aqt --installer diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index a60d1aa1..d728d88b 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -3,7 +3,7 @@ steam_linux: extends: - .base_linux_build script: - - python3 Tools/build.py --type=release --steam --deploy-version --use-aqt -installer --tag $CI_COMMIT_TAG + - python3 Tools/build.py --type=release --steam --deploy-version --use-aqt --installer --tag $CI_COMMIT_TAG rules: - if: "$CI_COMMIT_TAG" From 18b8c4025b5d94720c5e3a59e42a62415032398c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 17 Aug 2023 10:48:28 +0200 Subject: [PATCH 06/36] Change ci formatter script to allow system wide installation this is fine for a temporary ci --- .gitlab/ci/check_jobs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 35e296ab..561c60c3 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -9,8 +9,8 @@ formatting: - apt-get update -y - apt-get install python3-pip python-is-python3 clang clang-format -y script: - - python -m pip install -U pip wheel - - python -m pip install -U cmakelang + - python -m pip install -U pip wheel --break-system-packages + - python -m pip install -U cmakelang --break-system-packages - cd Tools - python clang_format.py - python cmake_format.py From 58567987aa8dc762c9c57011304212dc61881dc4 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 17 Aug 2023 14:26:39 +0200 Subject: [PATCH 07/36] Remove ScreePlay version from defines.py We now use always the latest set git tag as version. This means we also no longer need to add it as an argument --- .gitlab/ci/build_release_jobs.yml | 17 ++++++-- .vscode/tasks.json | 4 +- CMake/GetProjectVersion.cmake | 1 + CMakeLists.txt | 22 +++++----- Tools/build.py | 23 +++++++--- Tools/build_and_publish.py | 72 ++++++++++++++++++++----------- Tools/defines.py | 1 - Tools/util.py | 48 +++++++++++++++++++-- 8 files changed, 136 insertions(+), 52 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index d728d88b..685eae47 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -3,24 +3,33 @@ steam_linux: extends: - .base_linux_build script: - - python3 Tools/build.py --type=release --steam --deploy-version --use-aqt --installer --tag $CI_COMMIT_TAG + - python3 Tools/build.py --type=release --steam --deploy-version --use-aqt --installer rules: - if: "$CI_COMMIT_TAG" + artifacts: + paths: + - build-x64-linux-release/bin steam_windows: stage: release_build extends: - .base_windows_build script: - - python Tools/build.py --type=release --steam --use-aqt --deploy-version --tag $CI_COMMIT_TAG + - python Tools/build.py --type=release --steam --use-aqt --deploy-version rules: - if: "$CI_COMMIT_TAG" - + artifacts: + paths: + - build-x64-windows-release/ScreenPlay-Installer.exe + - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip steam_osx: stage: release_build extends: - .base_osx_build script: - - python3 Tools/build.py --type=release --steam --use-aqt --deploy-version -sign_osx --tag $CI_COMMIT_TAG + - python3 Tools/build.py --type=release --steam --use-aqt --deploy-version -sign_osx rules: - if: "$CI_COMMIT_TAG" + artifacts: + paths: + - build-64-osx-universal-release/ScreenPlay.app diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3289772a..c83832e7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -104,14 +104,14 @@ "build.py", "--type=release", "--deploy-version", - "-steam" + "--steam" ] }, "args": [ "build.py", "--type=release", "--deploy-version", - "-steam" + "--steam" ] }, { diff --git a/CMake/GetProjectVersion.cmake b/CMake/GetProjectVersion.cmake index f714bcba..7a1564cc 100644 --- a/CMake/GetProjectVersion.cmake +++ b/CMake/GetProjectVersion.cmake @@ -21,6 +21,7 @@ function(get_project_version VERSION_VAR) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) + message(STATUS "Parsing git tag: ${GIT_VERSION}") string(REPLACE "V" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'V' prefix string(REPLACE "-" ";" VERSION_LIST ${STRIPPED_VERSION}) list(GET VERSION_LIST 0 VERSION_STRING) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e1bedf..b8677270 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.23.0) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) include(GetProjectVersion) get_project_version(PROJECT_VERSION) -message(STATUS "Version: ${PROJECT_VERSION}") project( ScreenPlay @@ -140,18 +139,19 @@ if(${SCREENPLAY_INSTALLER} AND NOT APPLE) include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CreateIFWInstaller.cmake) endif() -message(STATUS "[CPP DEFINE] DEPLOY_VERSION = ${DEPLOY_VERSION}") -message(STATUS "[CPP DEFINE] SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") -message(STATUS "[CPP DEFINE] BUILD_DATE = ${BUILD_DATE}") -message(STATUS "[DEFINE] BUILD_TYPE = ${CMAKE_BUILD_TYPE}") -message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") -message(STATUS "[OPTION] SCREENPLAY_DEPLOY = ${SCREENPLAY_DEPLOY}") -message(STATUS "[OPTION] SCREENPLAY_INSTALLER = ${SCREENPLAY_INSTALLER}") -message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}") -message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}") +message(STATUS "[PROJECT] PROJECT_VERSION = ${PROJECT_VERSION}") +message(STATUS "[PROJECT] CMAKE_VERSION = ${CMAKE_VERSION}") message(STATUS "[PROJECT] SCREENPLAY_QML_MODULES_PATH = ${SCREENPLAY_QML_MODULES_PATH}") message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") message(STATUS "[PROJECT] VCPKG_PATH = ${VCPKG_PATH}") message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") -message(STATUS "[PROJECT] CMAKE_VERSION = ${CMAKE_VERSION}") +message(STATUS "[OPTION] SCREENPLAY_DEPLOY = ${SCREENPLAY_DEPLOY}") +message(STATUS "[OPTION] SCREENPLAY_INSTALLER = ${SCREENPLAY_INSTALLER}") +message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}") +message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}") +message(STATUS "[DEFINE] BUILD_TYPE = ${CMAKE_BUILD_TYPE}") +message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") +message(STATUS "[CPP DEFINE] DEPLOY_VERSION = ${DEPLOY_VERSION}") +message(STATUS "[CPP DEFINE] SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") +message(STATUS "[CPP DEFINE] BUILD_DATE = ${BUILD_DATE}") diff --git a/Tools/build.py b/Tools/build.py index 3a7b1ae7..bcced70b 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -11,7 +11,7 @@ import defines from typing import Tuple from pathlib import Path import macos_sign -from util import sha256, cd_repo_root_path, repo_root_path, zipdir, run, get_vs_env_dict +from util import sha256, cd_repo_root_path, repo_root_path, zipdir, run, get_vs_env_dict, get_latest_git_tag, parse_semver, semver_to_string from sys import stdout stdout.reconfigure(encoding='utf-8') @@ -213,7 +213,7 @@ def build(build_config: BuildConfig, build_result: BuildResult) -> BuildResult: -DSCREENPLAY_DEPLOY={build_config.build_deploy} \ -DSCREENPLAY_INSTALLER={build_config.create_installer} \ -DSCREENPLAY_IFW_ROOT:STRING={build_config.ifw_root_path} \ - -G "CodeBlocks - Ninja" \ + -G "Ninja" \ -B.' print(f"\nāš™ļø CMake configure:\n", cmake_configure_command.replace( @@ -375,7 +375,6 @@ if __name__ == "__main__": parser = argparse.ArgumentParser( description='Build and Package ScreenPlay') - parser.add_argument('--tag', type=str, help="GitLab CI tag", default="") 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", @@ -399,14 +398,24 @@ if __name__ == "__main__": args = parser.parse_args() qt_version = defines.QT_VERSION - if args.tag: - screenplay_version = args.tag - else: - screenplay_version = defines.SCREENPLAY_VERSION qt_ifw_version = defines.QT_IFW_VERSION # Not yet used. qt_version_overwrite: str use_aqt = False + tag = get_latest_git_tag() + if tag: + print(f"Latest Git tag: {tag}") + semver = parse_semver(tag) + if semver: + print(f"Parsed SemVer: {semver}") + screenplay_version = semver_to_string(semver) + else: + print("Failed to parse SemVer.") + exit(-1) + else: + print("No git tags found.") + exit(-1) + if args.qt_version_overwrite: qt_version = args.qt_version_overwrite print("Using Qt version {qt_version}") diff --git a/Tools/build_and_publish.py b/Tools/build_and_publish.py index 3e49f7b5..3ee955b2 100644 --- a/Tools/build_and_publish.py +++ b/Tools/build_and_publish.py @@ -1,9 +1,7 @@ #!/usr/bin/python3 # SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only import steam_publish -import shutil import sys -import macos_sign import argparse import os import build @@ -11,18 +9,26 @@ from pathlib import Path import platform import paramiko import defines -from util import sftp_exists, run, repo_root_path +from util import sftp_exists, get_latest_git_tag, parse_semver, semver_to_string from sys import stdout stdout.reconfigure(encoding='utf-8') if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Build and Package ScreenPlay') - parser.add_argument('-skip_publish', '-skp', action="store_true", dest="skip_publish", default=False, help="skip publish") - parser.add_argument('-skip_build', '-skb', action="store_true", dest="skip_build", default=False, help="skip build. If we already have a build and only want to upload it") - 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") + parser = argparse.ArgumentParser( + description='Build and Package ScreenPlay') + parser.add_argument('--skip_steam_publish', '-skstp', action="store_true", + dest="skip_publish", default=False, help="skip publish") + parser.add_argument('--skip_getspde_publish', '-skgsp', action="store_true", + dest="skip_getspde_publish", default=False, help="skip getsp.de publish") + parser.add_argument('--skip_build', '-skb', action="store_true", dest="skip_build", + default=False, help="skip build. If we already have a build and only want to upload it") + 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") args = parser.parse_args() # Script needs to run in the tools folder @@ -31,10 +37,23 @@ if __name__ == "__main__": root_path = tools_path.parent print(f"Set root directory to: {root_path}") + tag = get_latest_git_tag() + if tag: + print(f"Latest Git tag: {tag}") + semver = parse_semver(tag) + if semver: + print(f"Parsed SemVer: {semver}") + screenplay_version = semver_to_string(semver) + else: + print("Failed to parse SemVer.") + exit(-1) + else: + print("No git tags found.") + exit(-1) + build_result = build.BuildResult() build_config = build.BuildConfig() - build_config.screenplay_version = defines.SCREENPLAY_VERSION build_config.qt_version = defines.QT_VERSION build_config.qt_ifw_version = defines.QT_IFW_VERSION build_config.build_steam = "ON" @@ -42,6 +61,7 @@ if __name__ == "__main__": build_config.build_deploy = "ON" build_config.create_installer = "ON" build_config.build_type = "release" + build_config.screenplay_version = screenplay_version if platform.system() == "Darwin" and not args.skip_build: # We do not yet support a standalone osx installer @@ -54,21 +74,21 @@ if __name__ == "__main__": # This will build both arm64 and x64 and sign the unversal binary build_result = build.execute(build_config) - if platform.system() == "Windows" and not args.skip_build: build_config.build_architecture = "x64" - - if not args.skip_publish: + + if not args.skip_getspde_publish: # Steamless version first build_config.build_steam = "OFF" build_result = build.execute(build_config) - ssh = paramiko.SSHClient() + ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect('kelteseth.com', username=args.hosting_username, password=args.hosting_password) + 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 + "/" - if sftp_exists(sftp,release_folder): + release_folder = "/getsp.de/" + build_config.screenplay_version + "/" + if sftp_exists(sftp, release_folder): remoteFiles = sftp.listdir(path=release_folder) for file in remoteFiles: print(f"Delte old: {release_folder+file}") @@ -77,10 +97,14 @@ if __name__ == "__main__": sftp.mkdir(release_folder) print("Uploading files...") - 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.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() @@ -90,14 +114,14 @@ if __name__ == "__main__": build_config.create_installer = "OFF" build_result = build.execute(build_config) - if args.skip_publish: - print("Skip publishing.") + if args.skip_steam_publish: + print("Skip steam publishing.") sys.exit(0) if args.steam_password is None: print("Steam password is required.") sys.exit(1) - + # Make sure to reset to tools path os.chdir(tools_path) steam_publish.publish( diff --git a/Tools/defines.py b/Tools/defines.py index 496fb299..3650ae32 100644 --- a/Tools/defines.py +++ b/Tools/defines.py @@ -18,7 +18,6 @@ elif sys.platform == "linux": OS = "linux" QT_PLATFORM = "gcc_64" -SCREENPLAY_VERSION = "0.15.1" QT_PATH = path = Path(os.path.join( os.path.realpath(__file__), "../../../aqt")).resolve() QT_VERSION = "6.5.2" diff --git a/Tools/util.py b/Tools/util.py index 1e1415c3..6e79a641 100644 --- a/Tools/util.py +++ b/Tools/util.py @@ -6,11 +6,13 @@ from pathlib import Path from os import chdir from concurrent.futures import ThreadPoolExecutor import os +import re import subprocess from sys import stdout stdout.reconfigure(encoding='utf-8') + def sftp_exists(sftp, path) -> bool: try: sftp.stat(path) @@ -24,6 +26,7 @@ def run(cmd, cwd=Path.cwd()): if result.returncode != 0: raise RuntimeError(f"Failed to execute {cmd}") + def run_and_capture_output(cmd, cwd=Path.cwd()) -> str: result = subprocess.run(cmd, shell=True, cwd=cwd, stdout=subprocess.PIPE) if result.returncode != 0: @@ -31,14 +34,16 @@ def run_and_capture_output(cmd, cwd=Path.cwd()) -> str: if result.stdout is not None: return str(result.stdout.decode('utf-8')) return "" - + + def repo_root_path() -> str: # Root dir of the repository path = os.path.join(os.path.realpath(__file__), "../../") return os.path.realpath(path) + def cd_repo_root_path() -> str: - # Make sure the script is always started from the same + # Make sure the script is always started from the same # ScreenPlay root folder root_path = Path.cwd() if root_path.name == "Tools": @@ -47,6 +52,7 @@ def cd_repo_root_path() -> str: chdir(root_path) return root_path + def sha256(fname) -> str: hash_sha256 = hashlib.sha256() with open(fname, "rb") as f: @@ -55,7 +61,6 @@ def sha256(fname) -> str: return hash_sha256.hexdigest() - def zipdir(path, ziph): # ziph is zipfile handle for root, dirs, files in os.walk(path): @@ -102,3 +107,40 @@ def get_vs_env_dict(): raise ValueError(stderr.decode("mbcs")) 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 get_latest_git_tag(): + try: + tag = subprocess.check_output( + ["git", "describe", "--tags"]).decode("utf-8").strip() + return tag + except subprocess.CalledProcessError: + print("Error fetching the Git tag.") + return None + + +def parse_semver(tag): + # Regular expression to match semver + # Like V0.15.0-RC1-305-g18b8c402 + # Do NOT add a - between RC and the version number (1 in this example) + pattern = r'(?i)^v?(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?(?:-(\d+)-g([a-f0-9]+))?$' + match = re.match(pattern, tag) + if match: + major, minor, patch, pre_release, commits_since, commit_hash = match.groups() + return { + 'major': major, + 'minor': minor, + 'patch': patch, + 'pre_release': pre_release, + 'commits_since': commits_since, + 'commit_hash': commit_hash + } + else: + return None + + +def semver_to_string(semver_dict): + version_str = f"V{semver_dict['major']}.{semver_dict['minor']}.{semver_dict['patch']}" + if semver_dict['pre_release']: + version_str += f"-{semver_dict['pre_release']}" + return version_str From bdd613ab0161dcad794551211d32c79e8d6bcebb Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 12:30:59 +0200 Subject: [PATCH 08/36] Disable plausible for now --- ScreenPlay/main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenPlay/main.qml b/ScreenPlay/main.qml index 803be4f3..4ec06b04 100644 --- a/ScreenPlay/main.qml +++ b/ScreenPlay/main.qml @@ -65,7 +65,7 @@ ApplicationWindow { screenSize: Qt.size(root.width, root.height) domain: "app.screen-play.app" debug: false - enabled: App.settings.anonymousTelemetry + enabled: false } // Partial workaround for From 31f5fb7fa137ce9418a644a2248954fa4f4a96c6 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 12:32:20 +0200 Subject: [PATCH 09/36] Add release ci --- .gitlab-ci.yml | 3 +++ .gitlab/ci/build_release_jobs.yml | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d446915..aa18166e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,9 @@ stages: - build_steam # Git release tag builds - release_build + # Gitlab releases at: + # https://gitlab.com/kelteseth/ScreenPlay/-/releases + - release # Checks for source code formattings - check diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 685eae47..9a077747 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -22,6 +22,7 @@ steam_windows: paths: - build-x64-windows-release/ScreenPlay-Installer.exe - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip + steam_osx: stage: release_build extends: @@ -33,3 +34,24 @@ steam_osx: artifacts: paths: - build-64-osx-universal-release/ScreenPlay.app + +release_job: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: "$CI_COMMIT_TAG" # Run this job when a tag is created + when: on_success # Only when all previous jobs succeed + script: + - echo "Creating a GitLab release using release-cli." + release: + tag_name: $CI_COMMIT_TAG + name: "ScreenPlay $CI_COMMIT_TAG Released!" + description: "šŸŽ‰ A Wild ScreenPlay Release Appeard!" + assets: + links: + - name: Linux x64 build + url: "$CI_PIPELINE_URL/artifacts/download?job=steam_linux" + - name: Windows x64 build + url: "$CI_PIPELINE_URL/artifacts/download?job=steam_windows" + - name: OSX universal build + url: "$CI_PIPELINE_URL/artifacts/download?job=steam_osx" From 090e4aa75f0013d330a14a916093b4c26815d615 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 14:27:08 +0200 Subject: [PATCH 10/36] Fix missing - --- .gitlab/ci/build_release_jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 9a077747..c232671f 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -28,7 +28,7 @@ steam_osx: extends: - .base_osx_build script: - - python3 Tools/build.py --type=release --steam --use-aqt --deploy-version -sign_osx + - python3 Tools/build.py --type=release --steam --use-aqt --deploy-version --sign_osx rules: - if: "$CI_COMMIT_TAG" artifacts: From 52b47323604d813284e8916036a3cca796f10ac4 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 17:47:39 +0200 Subject: [PATCH 11/36] Fix release downloads --- .gitlab/ci/build_release_jobs.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index c232671f..3a85f219 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -20,7 +20,7 @@ steam_windows: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-x64-windows-release/ScreenPlay-Installer.exe + - build-x64-windows-release/ - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip steam_osx: @@ -33,7 +33,8 @@ steam_osx: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-64-osx-universal-release/ScreenPlay.app + - build-64-osx-universal-release/ + - build-64-osx-universal-release/bin/ScreenPlay.app release_job: stage: release @@ -43,15 +44,21 @@ release_job: when: on_success # Only when all previous jobs succeed script: - echo "Creating a GitLab release using release-cli." + artifacts: + paths: + - build-x64-linux-release/bin + - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip + - build-64-osx-universal-release/bin/ScreenPlay.app release: tag_name: $CI_COMMIT_TAG name: "ScreenPlay $CI_COMMIT_TAG Released!" - description: "šŸŽ‰ A Wild ScreenPlay Release Appeard!" + description: "šŸŽ‰ A Wild ScreenPlay Release Appeared!" + expire_in: never assets: links: - - name: Linux x64 build - url: "$CI_PIPELINE_URL/artifacts/download?job=steam_linux" - - name: Windows x64 build - url: "$CI_PIPELINE_URL/artifacts/download?job=steam_windows" - - name: OSX universal build - url: "$CI_PIPELINE_URL/artifacts/download?job=steam_osx" + - name: šŸ§ Linux x64 build + url: "$CI_PIPELINE_URL/artifacts/file/build-x64-linux-release/bin" + - name: šŸŖŸ Windows x64 build + url: "$CI_PIPELINE_URL/artifacts/file/build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" + - name: šŸ OSX universal build + url: "$CI_PIPELINE_URL/artifacts/file/build-64-osx-universal-release/bin/ScreenPlay.app" From b96990accb806067d10d1c3e17e225fe5c3eb2dd Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 17:56:50 +0200 Subject: [PATCH 12/36] Add pre-release flags --- .gitlab/ci/build_release_jobs.yml | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 3a85f219..1fa34fc1 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -39,26 +39,26 @@ steam_osx: release_job: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest - rules: - - if: "$CI_COMMIT_TAG" # Run this job when a tag is created - when: on_success # Only when all previous jobs succeed script: - - echo "Creating a GitLab release using release-cli." - artifacts: - paths: - - build-x64-linux-release/bin - - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip - - build-64-osx-universal-release/bin/ScreenPlay.app - release: - tag_name: $CI_COMMIT_TAG - name: "ScreenPlay $CI_COMMIT_TAG Released!" - description: "šŸŽ‰ A Wild ScreenPlay Release Appeared!" - expire_in: never - assets: - links: - - name: šŸ§ Linux x64 build - url: "$CI_PIPELINE_URL/artifacts/file/build-x64-linux-release/bin" - - name: šŸŖŸ Windows x64 build - url: "$CI_PIPELINE_URL/artifacts/file/build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" - - name: šŸ OSX universal build - url: "$CI_PIPELINE_URL/artifacts/file/build-64-osx-universal-release/bin/ScreenPlay.app" + - | + is_pre_release=false + if [[ "$CI_COMMIT_TAG" =~ -dev[0-9]+$ || "$CI_COMMIT_TAG" =~ -beta[0-9]+$ || "$CI_COMMIT_TAG" =~ -rc[0-9]+$ ]]; then + is_pre_release=true + fi + if $is_pre_release; then + release_name="ScreenPlay Pre-release $CI_COMMIT_TAG" + description="šŸŽ‰ A Wild ScreenPlay Pre-release Appeared!" + pre_release_flag="--pre-release" + else + release_name="ScreenPlay Release $CI_COMMIT_TAG" + description="šŸŽ‰ A Wild ScreenPlay Release Appeared!" + pre_release_flag="" + fi + release-cli create --name "$release_name" \ + --description "$description" \ + --tag-name $CI_COMMIT_TAG \ + --ref $CI_COMMIT_REF_NAME \ + $pre_release_flag \ + --assets-link '[{"name":"šŸ§ Linux x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-linux-release/bin"},{"name":"šŸŖŸ Windows x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip"},{"name":"šŸ OSX universal build","url":"$CI_PIPELINE_URL/artifacts/file/build-64-osx-universal-release/bin/ScreenPlay.app"}]' + rules: + - if: "$CI_COMMIT_TAG" From 7cf9dd1d80e312ac7956b4b424383ac181f0ea76 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 20:23:12 +0200 Subject: [PATCH 13/36] Change ci again to upload to getsp.de --- .gitlab/ci/build_release_jobs.yml | 60 +++++++++++++++++-------------- .gitlab/ci/check_jobs.yml | 3 ++ Tools/build.py | 11 +++--- Tools/publish_ci.py | 24 +++++++++++++ 4 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 Tools/publish_ci.py diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 1fa34fc1..f4be4076 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -8,7 +8,8 @@ steam_linux: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-x64-linux-release/bin + - build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip + - build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip.sha256.txt steam_windows: stage: release_build @@ -20,8 +21,8 @@ steam_windows: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-x64-windows-release/ - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip + - build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip.sha256.txt steam_osx: stage: release_build @@ -33,32 +34,39 @@ steam_osx: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-64-osx-universal-release/ - - build-64-osx-universal-release/bin/ScreenPlay.app + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip.sha256.txt release_job: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest - script: - - | - is_pre_release=false - if [[ "$CI_COMMIT_TAG" =~ -dev[0-9]+$ || "$CI_COMMIT_TAG" =~ -beta[0-9]+$ || "$CI_COMMIT_TAG" =~ -rc[0-9]+$ ]]; then - is_pre_release=true - fi - if $is_pre_release; then - release_name="ScreenPlay Pre-release $CI_COMMIT_TAG" - description="šŸŽ‰ A Wild ScreenPlay Pre-release Appeared!" - pre_release_flag="--pre-release" - else - release_name="ScreenPlay Release $CI_COMMIT_TAG" - description="šŸŽ‰ A Wild ScreenPlay Release Appeared!" - pre_release_flag="" - fi - release-cli create --name "$release_name" \ - --description "$description" \ - --tag-name $CI_COMMIT_TAG \ - --ref $CI_COMMIT_REF_NAME \ - $pre_release_flag \ - --assets-link '[{"name":"šŸ§ Linux x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-linux-release/bin"},{"name":"šŸŖŸ Windows x64 build","url":"$CI_PIPELINE_URL/artifacts/file/build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip"},{"name":"šŸ OSX universal build","url":"$CI_PIPELINE_URL/artifacts/file/build-64-osx-universal-release/bin/ScreenPlay.app"}]' rules: - - if: "$CI_COMMIT_TAG" + - if: "$CI_COMMIT_TAG" # Run this job when a tag is created + when: on_success # Only when all previous jobs succeed + script: + # 1. Combining sha256 files into a SHA512-SUMS.txt + - echo "Combining sha256 files into a SHA512-SUMS.txt" + - python3 Tools/publish_ci.py + # 2. Connect to kelteseth.com and handle the folder + - echo "Managing remote folder" + - apt-get update && apt-get install -y sshpass + - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@kelteseth.com "if [ -d /getsp.de/$CI_COMMIT_TAG ]; then rm -r /getsp.de/$CI_COMMIT_TAG; else mkdir /getsp.de/$CI_COMMIT_TAG; fi" + # 3. Upload files to the remote folder + - echo "Uploading files" + - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + + release: + tag_name: $CI_COMMIT_TAG + name: "ScreenPlay $CI_COMMIT_TAG Released!" + description: "šŸŽ‰ A Wild ScreenPlay Release Appeared!" + assets: + links: + - name: šŸ§ Linux x64 build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip" + - name: šŸŖŸ Windows x64 build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" + - name: šŸ OSX universal build + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip" diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 561c60c3..82e5f039 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -1,6 +1,9 @@ formatting: stage: check allow_failure: true + rules: + - if: $CI_COMMIT_TAG + when: never image: name: ubuntu:23.10 tags: diff --git a/Tools/build.py b/Tools/build.py index bcced70b..74f03713 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -111,12 +111,11 @@ def execute( build_installer_duration = time.time() - step_time print(f"ā±ļø build_installer_duration: {build_installer_duration}s") - # Create a zip file for scoop & chocolatey - if platform.system() == "Windows": - step_time = time.time() - build_result = zip(build_config, build_result) - zip_duration = time.time() - step_time - print(f"ā±ļø zip_duration: {zip_duration}s") + # Create a zip file of the build + step_time = time.time() + build_result = zip(build_config, build_result) + zip_duration = time.time() - step_time + print(f"ā±ļø zip_duration: {zip_duration}s") duration = time.time() - start_time print(f"ā±ļø Build completed in: {duration}s") diff --git a/Tools/publish_ci.py b/Tools/publish_ci.py new file mode 100644 index 00000000..579b9bd3 --- /dev/null +++ b/Tools/publish_ci.py @@ -0,0 +1,24 @@ +import hashlib +import os + + +def combine_sha256(): + files = [ + "build-x64-linux-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-linux-release.zip", + "build-x64-windows-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-windows-release.zip", + "build-64-osx-universal-release/ScreenPlay-" + + os.environ['CI_COMMIT_TAG'] + "-x64-osx-universal-release.zip" + ] + + with open('SHA512-SUMS.txt', 'w') as f_out: + for file in files: + with open(f"{file}.sha256.txt", 'r') as f_in: + sha256_hash = f_in.read().strip() + sha512_hash = hashlib.sha512(sha256_hash.encode()).hexdigest() + f_out.write(f"{sha512_hash} {file}\n") + + +if __name__ == "__main__": + combine_sha256() From 59cb5d0dc55129b03faa57a92a3aa97efd28d3dc Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 18 Aug 2023 20:23:33 +0200 Subject: [PATCH 14/36] Change to disable default content for now --- ScreenPlay/inc/public/ScreenPlay/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenPlay/inc/public/ScreenPlay/settings.h b/ScreenPlay/inc/public/ScreenPlay/settings.h index 6c6cbd97..85edc6a4 100644 --- a/ScreenPlay/inc/public/ScreenPlay/settings.h +++ b/ScreenPlay/inc/public/ScreenPlay/settings.h @@ -470,7 +470,7 @@ private: bool m_checkWallpaperVisible { false }; bool m_silentStart { false }; bool m_anonymousTelemetry { true }; - bool m_showDefaultContent { true }; + bool m_showDefaultContent { false }; QString m_decoder; ScreenPlay::FillMode::FillMode m_videoFillMode { ScreenPlay::FillMode::FillMode::Cover }; From c56fb682029d8a89e57836c1e922bfe257349956 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 19 Aug 2023 10:04:30 +0200 Subject: [PATCH 15/36] Fix build cmake parsing using lowercase v --- CMake/GetProjectVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/GetProjectVersion.cmake b/CMake/GetProjectVersion.cmake index 7a1564cc..f0f6011b 100644 --- a/CMake/GetProjectVersion.cmake +++ b/CMake/GetProjectVersion.cmake @@ -22,7 +22,7 @@ function(get_project_version VERSION_VAR) ) message(STATUS "Parsing git tag: ${GIT_VERSION}") - string(REPLACE "V" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'V' prefix + string(REPLACE "v" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'V' prefix string(REPLACE "-" ";" VERSION_LIST ${STRIPPED_VERSION}) list(GET VERSION_LIST 0 VERSION_STRING) From 9b1de7cadf6eac91dd0c796354d00e411fbc98ab Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 19 Aug 2023 12:11:06 +0200 Subject: [PATCH 16/36] Fix wrong base image not containing python --- .gitlab/ci/build_release_jobs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index f4be4076..0481a6b4 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -39,7 +39,7 @@ steam_osx: release_job: stage: release - image: registry.gitlab.com/gitlab-org/release-cli:latest + image: python:3.11 rules: - if: "$CI_COMMIT_TAG" # Run this job when a tag is created when: on_success # Only when all previous jobs succeed @@ -57,7 +57,6 @@ release_job: - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - release: tag_name: $CI_COMMIT_TAG name: "ScreenPlay $CI_COMMIT_TAG Released!" From e327f7381256130b7f908e8db78c9ebe2e59ee45 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 11:59:02 +0200 Subject: [PATCH 17/36] Fix all formatting scripts and format files They default to format but also can be used for checking --- .gitlab/ci/check_jobs.yml | 5 +- .vscode/tasks.json | 8 +- Content/wallpaper_qml/main.qml | 1 - Content/wallpaper_qml_particles/main.qml | 14 +-- Content/widget_digital_clock/main.qml | 33 ++++--- .../widget_rss_guardian_news/PostDelegate.qml | 17 ++-- Content/widget_rss_guardian_news/main.qml | 3 +- .../widget_rss_hackernews/PostDelegate.qml | 50 +++++------ Content/widget_rss_hackernews/main.qml | 11 ++- Content/widget_system_stats/main.qml | 13 ++- Content/widget_weather/main.qml | 41 ++++----- Content/widget_xkcd/main.qml | 51 ++++++----- Content/widget_year_count_down/main.qml | 26 ++---- ScreenPlay/CMakeLists.txt | 2 +- ScreenPlay/qml/Installed/ScreenPlayItem.qml | 1 - ScreenPlay/qml/Installed/Sidebar.qml | 2 +- ScreenPlay/qml/Settings/Settings.qml | 2 +- ScreenPlaySDK/src/screenplaysdk.cpp | 11 ++- ScreenPlayUtil/src/projectfile.cpp | 8 +- ScreenPlayWallpaper/qml/MultimediaView.qml | 15 ++-- ScreenPlayWallpaper/src/basewindow.cpp | 4 +- ScreenPlayWidget/main.cpp | 6 +- Tools/check_format_cmake.py | 56 ++++++++++++ Tools/check_format_cpp.py | 61 +++++++++++++ Tools/check_format_qml.py | 86 +++++++++++++++++++ Tools/clang_format.py | 36 -------- Tools/cmake_format.py | 31 ------- Tools/format_util.py | 43 ++++++---- Tools/qml_format.py | 40 --------- 29 files changed, 372 insertions(+), 305 deletions(-) create mode 100644 Tools/check_format_cmake.py create mode 100644 Tools/check_format_cpp.py create mode 100644 Tools/check_format_qml.py delete mode 100644 Tools/clang_format.py delete mode 100644 Tools/cmake_format.py delete mode 100644 Tools/qml_format.py diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 82e5f039..b190e2bf 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -15,5 +15,6 @@ formatting: - python -m pip install -U pip wheel --break-system-packages - python -m pip install -U cmakelang --break-system-packages - cd Tools - - python clang_format.py - - python cmake_format.py + - python check_format_cmake.py --check + - python check_format_cpp.py --check + - python check_format_qml.py --check diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c83832e7..a6b91c44 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -28,7 +28,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "clang_format.py" + "check_format_cpp.py" ] }, { @@ -46,7 +46,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "cmake_format.py" + "check_format_cmake.py" ] }, { @@ -64,7 +64,7 @@ "cwd": "${workspaceFolder}/Tools" }, "args": [ - "qml_format.py" + "check_format_qml.py" ] }, { @@ -87,7 +87,7 @@ }, { "type": "process", - "label": "Export ScreenPlay release, with deploy and steam enabled", + "label": "Build ScreenPlay release, with deploy and steam enabled", "command": "python3", "windows": { "command": "python" diff --git a/Content/wallpaper_qml/main.qml b/Content/wallpaper_qml/main.qml index 475be5a1..92e21a65 100644 --- a/Content/wallpaper_qml/main.qml +++ b/Content/wallpaper_qml/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts diff --git a/Content/wallpaper_qml_particles/main.qml b/Content/wallpaper_qml_particles/main.qml index 35febbda..9f2b561f 100644 --- a/Content/wallpaper_qml_particles/main.qml +++ b/Content/wallpaper_qml_particles/main.qml @@ -42,19 +42,19 @@ Item { anchors.fill: parent hoverEnabled: true Component.onCompleted: { - attractor.pointX = parent.width * .5 - attractor.pointY = 0 + attractor.pointX = parent.width * .5; + attractor.pointY = 0; } onPressed: { - attractor.enabled = true + attractor.enabled = true; } onPositionChanged: { - attractor.pointX = mouseX - attractor.pointY = mouseY + attractor.pointX = mouseX; + attractor.pointY = mouseY; } onReleased: { - attractor.enabled = false + attractor.enabled = false; } } @@ -119,7 +119,7 @@ Item { bottom: parent.bottom bottomMargin: -width * .65 } - SequentialAnimation on opacity { + SequentialAnimation on opacity { loops: Animation.Infinite OpacityAnimator { diff --git a/Content/widget_digital_clock/main.qml b/Content/widget_digital_clock/main.qml index 42fab09e..8af90611 100644 --- a/Content/widget_digital_clock/main.qml +++ b/Content/widget_digital_clock/main.qml @@ -8,32 +8,31 @@ Item { implicitHeight: 100 function timeChanged() { - var date = new Date - var hours = "" - var minutes = "" - var seconds = "" + var date = new Date; + var hours = ""; + var minutes = ""; + var seconds = ""; if (date.getHours() < 10) { - hours = "0" + date.getHours().toString() + hours = "0" + date.getHours().toString(); } else { - hours = date.getHours().toString() + hours = date.getHours().toString(); } if (date.getMinutes() < 10) { - minutes = "0" + date.getMinutes().toString() + minutes = "0" + date.getMinutes().toString(); } else { - minutes = date.getMinutes().toString() + minutes = date.getMinutes().toString(); } if (date.getSeconds() < 10) { - seconds = "0" + date.getSeconds().toString() + seconds = "0" + date.getSeconds().toString(); } else { - seconds = date.getSeconds().toString() + seconds = date.getSeconds().toString(); } - var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] - var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] - var day = days[date.getDay()] - var month = months[date.getMonth()] - txtClock.text = hours + ":" + minutes + ":" + seconds - txtDate.text = day + ", " + date.getDay( - ) + " " + month + ", " + date.getFullYear() + var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; + var day = days[date.getDay()]; + var month = months[date.getMonth()]; + txtClock.text = hours + ":" + minutes + ":" + seconds; + txtDate.text = day + ", " + date.getDay() + " " + month + ", " + date.getFullYear(); } Timer { diff --git a/Content/widget_rss_guardian_news/PostDelegate.qml b/Content/widget_rss_guardian_news/PostDelegate.qml index 5e3b1d61..83b46b1e 100644 --- a/Content/widget_rss_guardian_news/PostDelegate.qml +++ b/Content/widget_rss_guardian_news/PostDelegate.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -17,16 +16,16 @@ Item { property string link property string mediaContent onMediaContentChanged: { - print("src") - const src = parseItem(model.mediaContent, 'url="', '"') - print("src", src) + print("src"); + const src = parseItem(model.mediaContent, 'url="', '"'); + print("src", src); //img.source = src; } function parseItem(raw, startTag, endTag) { - var startIdx = raw.indexOf(startTag) + startTag.length - var endIdx = raw.indexOf(endTag, startIdx) - return raw.substring(startIdx, endIdx) + var startIdx = raw.indexOf(startTag) + startTag.length; + var endIdx = raw.indexOf(endTag, startIdx); + return raw.substring(startIdx, endIdx); } RowLayout { @@ -49,8 +48,8 @@ Item { MouseArea { anchors.fill: parent onClicked: { - print(model.category) - print(model.mediaContent) + print(model.category); + print(model.mediaContent); //Qt.openUrlExternally(model.link); } } diff --git a/Content/widget_rss_guardian_news/main.qml b/Content/widget_rss_guardian_news/main.qml index e54e55e4..f86de527 100644 --- a/Content/widget_rss_guardian_news/main.qml +++ b/Content/widget_rss_guardian_news/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls @@ -18,7 +17,7 @@ Item { query: "/rss/channel/item" onStatusChanged: { if (status === XmlListModel.Error) { - console.log("Error: " + errorString) + console.log("Error: " + errorString); } } diff --git a/Content/widget_rss_hackernews/PostDelegate.qml b/Content/widget_rss_hackernews/PostDelegate.qml index 275823d5..badb4bbc 100644 --- a/Content/widget_rss_hackernews/PostDelegate.qml +++ b/Content/widget_rss_hackernews/PostDelegate.qml @@ -12,41 +12,38 @@ Item { property string pubDate property string pubDateFormatted onPubDateChanged: { - var date = new Date(pubDate) - root.pubDateFormatted = date.toLocaleDateString( - Qt.locale(), - "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString( - Qt.locale(), "HH:mm:ss") + var date = new Date(pubDate); + root.pubDateFormatted = date.toLocaleDateString(Qt.locale(), "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString(Qt.locale(), "HH:mm:ss"); } property string description onDescriptionChanged: { - print("description") + print("description"); // See https://hnrss.org/frontpage content // We need to manually parse it here to get the points and comments - points = parsePoints(description) - commentCount = parseCommentCount(description) - print(points, commentCount) + points = parsePoints(description); + commentCount = parseCommentCount(description); + print(points, commentCount); } function parseCommentCount(raw) { - var commentPrefix = "

# Comments: " - var commentSuffix = "

" - var startIdx = raw.indexOf(commentPrefix) + var commentPrefix = "

# Comments: "; + var commentSuffix = "

"; + var startIdx = raw.indexOf(commentPrefix); if (startIdx === -1) - return "N/A" // return "N/A" if comment count is not found in the description - startIdx += commentPrefix.length - var endIdx = raw.indexOf(commentSuffix, startIdx) - return raw.substring(startIdx, endIdx) + return "N/A"; // return "N/A" if comment count is not found in the description + startIdx += commentPrefix.length; + var endIdx = raw.indexOf(commentSuffix, startIdx); + return raw.substring(startIdx, endIdx); } function parsePoints(raw) { - var pointsPrefix = "

Points: " - var pointsSuffix = "

" - var startIdx = raw.indexOf(pointsPrefix) + var pointsPrefix = "

Points: "; + var pointsSuffix = "

"; + var startIdx = raw.indexOf(pointsPrefix); if (startIdx === -1) - return "N/A" // return "N/A" if points are not found in the description - startIdx += pointsPrefix.length - var endIdx = raw.indexOf(pointsSuffix, startIdx) - return raw.substring(startIdx, endIdx) + return "N/A"; // return "N/A" if points are not found in the description + startIdx += pointsPrefix.length; + var endIdx = raw.indexOf(pointsSuffix, startIdx); + return raw.substring(startIdx, endIdx); } RowLayout { id: wrapper @@ -68,15 +65,14 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - Qt.openUrlExternally(model.link) + Qt.openUrlExternally(model.link); } } } Text { id: descriptionText - text: root.points + " Points ā€¢ " + root.commentCount - + " Comments šŸ”— " + "ā€¢ Published: " + root.pubDateFormatted + text: root.points + " Points ā€¢ " + root.commentCount + " Comments šŸ”— " + "ā€¢ Published: " + root.pubDateFormatted wrapMode: Text.WordWrap font.pointSize: 10 opacity: .7 @@ -85,7 +81,7 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - Qt.openUrlExternally(model.commentsLink) + Qt.openUrlExternally(model.commentsLink); } } } diff --git a/Content/widget_rss_hackernews/main.qml b/Content/widget_rss_hackernews/main.qml index 87708c2c..99ddc3a8 100644 --- a/Content/widget_rss_hackernews/main.qml +++ b/Content/widget_rss_hackernews/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -44,7 +43,7 @@ Item { } } onActivated: { - rssModel.source = combo.currentValue + rssModel.source = combo.currentValue; } } ToolButton { @@ -79,10 +78,10 @@ Item { source: combo.currentValue query: "/rss/channel/item" function load() { - print(":load") - var tempSource = rssModel.source - rssModel.source = "" - rssModel.source = tempSource + print(":load"); + var tempSource = rssModel.source; + rssModel.source = ""; + rssModel.source = tempSource; } XmlListModelRole { diff --git a/Content/widget_system_stats/main.qml b/Content/widget_system_stats/main.qml index abe23e9a..ec5fe20e 100644 --- a/Content/widget_system_stats/main.qml +++ b/Content/widget_system_stats/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -28,11 +27,11 @@ Item { } function stringListToString(list) { - let out = "" + let out = ""; for (var i = 0; i < list.length; i++) { - out += "\n" + list[i] + out += "\n" + list[i]; } - return out + return out; } RowLayout { @@ -57,8 +56,7 @@ Item { } } Text { - text: root.stringListToString( - ipAddress.privateIpV4AddressList) + text: root.stringListToString(ipAddress.privateIpV4AddressList) color: root.accentColor font { pointSize: 16 @@ -66,8 +64,7 @@ Item { } } Text { - text: root.stringListToString( - ipAddress.privateIpV6AddressList) + text: root.stringListToString(ipAddress.privateIpV6AddressList) color: root.accentColor font { pointSize: 16 diff --git a/Content/widget_weather/main.qml b/Content/widget_weather/main.qml index 4f934ada..42a061eb 100644 --- a/Content/widget_weather/main.qml +++ b/Content/widget_weather/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts @@ -20,56 +19,57 @@ Item { id: weather city: "Friedrichshafen" onReady: { - rp.model = weather.days + rp.model = weather.days; // Qt bug https://bugreports.qt.io/browse/QTBUG-105137 - test() + test(); } } - function test() {} + function test() { + } function mapWeatherCode(code) { - const weather_time = "" + const weather_time = ""; // or "-day", "-night" - const weather_prefix = "wi" + weather_time + "-" + const weather_prefix = "wi" + weather_time + "-"; // https://open-meteo.com/en/docs // WMO Weather interpretation codes (WW) // to https://erikflowers.github.io/weather-icons/ switch (code) { case 0: - return weather_prefix + "day-sunny" + return weather_prefix + "day-sunny"; case 1: case 2: case 3: - return weather_prefix + "cloud" + return weather_prefix + "cloud"; case 45: case 48: - return weather_prefix + "day-sunny" + return weather_prefix + "day-sunny"; case 51: case 53: case 55: - return weather_prefix + "rain-mix" + return weather_prefix + "rain-mix"; case 61: case 63: case 65: - return weather_prefix + "rain-mix" + return weather_prefix + "rain-mix"; case 71: case 73: case 75: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 77: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 80: case 81: case 82: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 85: case 86: - return weather_prefix + "snow" + return weather_prefix + "snow"; case 95: - return weather_prefix + "thunderstorm" + return weather_prefix + "thunderstorm"; case 96: case 99: - return weather_prefix + "storm-showers" + return weather_prefix + "storm-showers"; } } @@ -89,9 +89,7 @@ Item { Layout.alignment: Qt.AlignCenter horizontalAlignment: Text.AlignHCenter color: Material.primaryTextColor - text: "longtitude: " + weather.longtitude + " - latitude: " - + weather.latitude + " - elevation: " + weather.elevation - + "m - population: " + weather.population + text: "longtitude: " + weather.longtitude + " - latitude: " + weather.latitude + " - elevation: " + weather.elevation + "m - population: " + weather.population } RowLayout { @@ -129,8 +127,7 @@ Item { } Layout.alignment: Qt.AlignCenter horizontalAlignment: Image.AlignHCenter - source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode( - weatherCode) + ".svg" + source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(weatherCode) + ".svg" } TextItem { text: "Weather Code" diff --git a/Content/widget_xkcd/main.qml b/Content/widget_xkcd/main.qml index 377b6706..917c0cf0 100644 --- a/Content/widget_xkcd/main.qml +++ b/Content/widget_xkcd/main.qml @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls @@ -15,27 +14,27 @@ Item { property int defaultHeight: 200 function request(url, callback) { - var xhr = new XMLHttpRequest() + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = (function (myxhr) { - return function () { - if (myxhr.readyState === 4) - callback(myxhr) - } - })(xhr) - xhr.open('GET', url) - xhr.send('') + return function () { + if (myxhr.readyState === 4) + callback(myxhr); + }; + })(xhr); + xhr.open('GET', url); + xhr.send(''); } Component.onCompleted: { request("http://xkcd.com/info.0.json", function (o) { - if (o.status === 200) { - var d = eval('new Object(' + o.responseText + ')') - console.log(o.responseText) - img.source = d.img - } else { - console.log("Some error has occurred") - } - }) + if (o.status === 200) { + var d = eval('new Object(' + o.responseText + ')'); + console.log(o.responseText); + img.source = d.img; + } else { + console.log("Some error has occurred"); + } + }); } Image { @@ -45,22 +44,22 @@ Item { property size imgSize: Qt.size(root.defaultWidth, defaultHeight) onStatusChanged: { if (img.status !== Image.Ready) - return + return; if (img.sourceSize.width === 0 || img.sourceSize.height === 0) - return - root.implicitWidth = img.sourceSize.width - root.implicitHeight = img.sourceSize.height - print(img.status, img.sourceSize.width, img.sourceSize.height) - img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height) - print("img.size", img.imgSize) + return; + root.implicitWidth = img.sourceSize.width; + root.implicitHeight = img.sourceSize.height; + print(img.status, img.sourceSize.width, img.sourceSize.height); + img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height); + print("img.size", img.imgSize); } } MouseArea { anchors.fill: parent onClicked: { - root.state = root.state === "expanded" ? "normal" : "expanded" - print(root.state, root.implicitHeight, root.implicitWidth) + root.state = root.state === "expanded" ? "normal" : "expanded"; + print(root.state, root.implicitHeight, root.implicitWidth); } } diff --git a/Content/widget_year_count_down/main.qml b/Content/widget_year_count_down/main.qml index dfddb45e..39fab9d4 100644 --- a/Content/widget_year_count_down/main.qml +++ b/Content/widget_year_count_down/main.qml @@ -11,17 +11,9 @@ Item { implicitWidth: 240 implicitHeight: 120 property int totalHours: 24 - property int remainingHours: Math.max(0, Math.floor( - (new Date().setHours( - 24, 0, 0, - 0) - new Date()) / 3600000)) - property int totalDays: new Date(new Date().getFullYear() + 1, 0, - 1) - new Date() / (24 * 60 * 60 * 1000) - property int remainingDays: Math.max( - 0, Math.floor( - (new Date(new Date().getFullYear() + 1, - 0, - 1) - new Date()) / (24 * 60 * 60 * 1000))) + property int remainingHours: Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)) + property int totalDays: new Date(new Date().getFullYear() + 1, 0, 1) - new Date() / (24 * 60 * 60 * 1000) + property int remainingDays: Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))) Material.theme: Material.Dark Material.accent: Material.DeepOrange @@ -50,11 +42,7 @@ Item { running: true repeat: true onTriggered: { - remainingHours = Math.max( - 0, - Math.floor((new Date().setHours( - 24, 0, 0, - 0) - new Date()) / 3600000)) + remainingHours = Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)); } } } @@ -81,11 +69,7 @@ Item { running: true repeat: true onTriggered: { - remainingDays = Math.max(0, - Math.floor((new Date(new Date().getFullYear( - ) + 1, - 0, 1) - - new Date()) / (24 * 60 * 60 * 1000))) + remainingDays = Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))); } } } diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index fdafccf0..d2842184 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -138,6 +138,7 @@ set(RESOURCES assets/icons/icon_close.svg assets/icons/icon_code.svg assets/icons/icon_community.svg + assets/icons/icon_contains_audio.svg assets/icons/icon_delete.svg assets/icons/icon_document.svg assets/icons/icon_done.svg @@ -152,7 +153,6 @@ set(RESOURCES assets/icons/icon_installed.svg assets/icons/icon_launch.svg assets/icons/icon_minimize.svg - assets/icons/icon_contains_audio.svg assets/icons/icon_movie.svg assets/icons/icon_new_releases.svg assets/icons/icon_open_in_new.svg diff --git a/ScreenPlay/qml/Installed/ScreenPlayItem.qml b/ScreenPlay/qml/Installed/ScreenPlayItem.qml index be8aa23d..f22a4701 100644 --- a/ScreenPlay/qml/Installed/ScreenPlayItem.qml +++ b/ScreenPlay/qml/Installed/ScreenPlayItem.qml @@ -175,7 +175,6 @@ Item { } } - Image { id: icnType diff --git a/ScreenPlay/qml/Installed/Sidebar.qml b/ScreenPlay/qml/Installed/Sidebar.qml index a9bb26ea..96ce53cc 100644 --- a/ScreenPlay/qml/Installed/Sidebar.qml +++ b/ScreenPlay/qml/Installed/Sidebar.qml @@ -43,7 +43,7 @@ Item { const item = App.installedListModel.get(root.contentFolderName); txtHeadline.text = item.m_title; const previewGiFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_previewGIF); - const previewImageFilePath = Qt.resolvedUrl( item.m_absoluteStoragePath + "/" + item.m_preview); + const previewImageFilePath = Qt.resolvedUrl(item.m_absoluteStoragePath + "/" + item.m_preview); root.hasPreviewGif = App.util.fileExists(previewGiFilePath); if (hasPreviewGif) { animatedImagePreview.source = previewGiFilePath; diff --git a/ScreenPlay/qml/Settings/Settings.qml b/ScreenPlay/qml/Settings/Settings.qml index 4f02b98a..6e540746 100644 --- a/ScreenPlay/qml/Settings/Settings.qml +++ b/ScreenPlay/qml/Settings/Settings.qml @@ -82,7 +82,7 @@ Item { isChecked: App.settings.showDefaultContent onCheckboxChanged: function (checked) { App.settings.setShowDefaultContent(checked); - App.installedListModel.reset() + App.installedListModel.reset(); } } diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 20553e18..4caec706 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -186,20 +186,19 @@ void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType t // Also redirect to regular output if we debug // wallpaper or widgets directly - switch (type) - { + switch (type) { case QtDebugMsg: - qDebug() << msg; + qDebug() << msg; break; case QtWarningMsg: - qWarning() << msg; + qWarning() << msg; break; case QtCriticalMsg: case QtFatalMsg: - qCritical() << msg; + qCritical() << msg; break; case QtInfoMsg: - qInfo() << msg; + qInfo() << msg; break; default: break; diff --git a/ScreenPlayUtil/src/projectfile.cpp b/ScreenPlayUtil/src/projectfile.cpp index 401fcffa..d0e899bd 100644 --- a/ScreenPlayUtil/src/projectfile.cpp +++ b/ScreenPlayUtil/src/projectfile.cpp @@ -27,9 +27,9 @@ bool ProjectFile::init() return false; file = obj.value("file").toString(); - QFileInfo fileInfo(folder.path() + "/"+ file); - if(!fileInfo.exists()){ - qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!"; + QFileInfo fileInfo(folder.path() + "/" + file); + if (!fileInfo.exists()) { + qCritical() << "Requested file:" << fileInfo.absoluteFilePath() << "does not exist!"; return false; } @@ -107,7 +107,7 @@ bool ProjectFile::init() } } - if (type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper){ + if (type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) { QFileInfo audioFile(folder.absolutePath() + "/audio.mp3"); containsAudio = audioFile.exists(); } diff --git a/ScreenPlayWallpaper/qml/MultimediaView.qml b/ScreenPlayWallpaper/qml/MultimediaView.qml index 49101516..592462a7 100644 --- a/ScreenPlayWallpaper/qml/MultimediaView.qml +++ b/ScreenPlayWallpaper/qml/MultimediaView.qml @@ -49,7 +49,7 @@ Item { onPlaybackStateChanged: { if (mediaPlayer.playbackState == MediaPlayer.PlayingState && !fadeInDone) { fadeInDone = true; - startTimer.start() + startTimer.start(); } } loops: root.loops ? MediaPlayer.Infinite : 1 @@ -72,8 +72,7 @@ Item { id: pauseTimer interval: 100 onTriggered: { - mediaPlayer.pause() - + mediaPlayer.pause(); } } Connections { @@ -96,12 +95,12 @@ Item { } function onVisualsPausedChanged(visualsPaused) { - if(!Wallpaper.isPlaying) - return - if(visualsPaused) - pauseTimer.start() + if (!Wallpaper.isPlaying) + return; + if (visualsPaused) + pauseTimer.start(); else - mediaPlayer.play() + mediaPlayer.play(); } target: Wallpaper diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index b4119343..67231f16 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -60,8 +60,8 @@ ScreenPlay::WallpaperExitCode BaseWindow::setup() // We do not yet have implemented continue playing the audio.mp3 yet // so disable the checkWallpaperVisible for now - if(checkWallpaperVisible()){ - if(projectFile.containsAudio){ + if (checkWallpaperVisible()) { + if (projectFile.containsAudio) { qInfo() << "Disable wallpaper visible check, because it contains audio."; setCheckWallpaperVisible(false); } diff --git a/ScreenPlayWidget/main.cpp b/ScreenPlayWidget/main.cpp index 0445f60e..cffc4841 100644 --- a/ScreenPlayWidget/main.cpp +++ b/ScreenPlayWidget/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) QtWebEngineQuick::initialize(); #if defined(Q_OS_WIN) - // Workaround for Qt 6.5.1 crash https://bugreports.qt.io/browse/QTBUG-113832 + // Workaround for Qt 6.5.1 crash https://bugreports.qt.io/browse/QTBUG-113832 qputenv("QT_DISABLE_HW_TEXTURES_CONVERSION", "1"); qputenv("QT_MEDIA_BACKEND", "ffmpeg"); #endif @@ -55,8 +55,8 @@ int main(int argc, char* argv[]) // Lets center the widget const auto* screen = QGuiApplication::screens().at(0); - const int offset = - 200; - QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2)+offset); + const int offset = -200; + QPoint center((screen->size().width() / 2) + offset, (screen->size().height() / 2) + offset); WidgetWindow spwmw(projectPath, "appid", diff --git a/Tools/check_format_cmake.py b/Tools/check_format_cmake.py new file mode 100644 index 00000000..c3d1849a --- /dev/null +++ b/Tools/check_format_cmake.py @@ -0,0 +1,56 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +import os +import argparse +import util +from format_util import find_files +from format_util import execute_threaded +from sys import stdout + +stdout.reconfigure(encoding='utf-8') + + +def format_file_function(file): + executable = "cmake-format" + if os.name == 'nt': + executable += ".exe" + os.system(" %s -c ../.cmake-format.py -i %s" % (executable, file)) + print("Format: ", file) + + +def check_format_file_function(file): + executable = "cmake-format" + if os.name == 'nt': + executable += ".exe" + result = os.system(" %s -c ../.cmake-format.py --check %s" % + (executable, file)) + + # If the return code is non-zero, the file isn't formatted correctly + if result != 0: + print(f"{file} is not correctly formatted.") + return False + return True + + +def main(git_staged_only=False, check_only=False): + file_list = find_files( + ('CMakeLists.txt', '*.cmake'), util.repo_root_path(), git_staged_only) + + if check_only: + result = execute_threaded(file_list, check_format_file_function) + if not result: # Since result is a single boolean, you can directly check its value + print("Some files are not correctly formatted!") + exit(1) + else: + execute_threaded(file_list, format_file_function) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('-s', '--stage-only', action="store_true", dest="stage_only", default=False, + help="Check/format only staged files") + parser.add_argument('-c', '--check', action="store_true", dest="check_only", default=False, + help="Only check if files are correctly formatted without actually formatting them") + + args = parser.parse_args() + main(args.stage_only, args.check_only) diff --git a/Tools/check_format_cpp.py b/Tools/check_format_cpp.py new file mode 100644 index 00000000..793135f3 --- /dev/null +++ b/Tools/check_format_cpp.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +import os +import subprocess +import argparse +import util +from format_util import find_files +from format_util import execute_threaded +from sys import stdout + +stdout.reconfigure(encoding='utf-8') + + +def format_file_function(file): + executable = "clang-format" + if os.name == 'nt': + executable = "clang-format.exe" + process = subprocess.run(" %s -style=file -i %s" % + (executable, file), capture_output=True, shell=True) + print("Format: %s \t return: %s" % (file, process.returncode)) + + +def check_format_file_function(file): + executable = "clang-format" + if os.name == 'nt': + executable += ".exe" + result = subprocess.run(" %s -style=file --output-replacements-xml %s" % + (executable, file), capture_output=True, shell=True, text=True) + + # Check for opening replacement tag with attributes (a space after it indicates attributes) + if " Date: Sun, 20 Aug 2023 12:03:47 +0200 Subject: [PATCH 18/36] Fix qml format still containing test code --- Tools/check_format_qml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/check_format_qml.py b/Tools/check_format_qml.py index 0fe9664f..b8443e35 100644 --- a/Tools/check_format_qml.py +++ b/Tools/check_format_qml.py @@ -14,6 +14,7 @@ import shutil stdout.reconfigure(encoding='utf-8') +# Instead of comparing the direct outputs (which was leading to ambiguous results), this function uses a workaround that checks the file's MD5 hash before and after formatting. def format_qml_file(file): executable = "qmlformat" if os.name == 'nt': @@ -23,7 +24,7 @@ def format_qml_file(file): # Add -i for formatting in place process = subprocess.run( - [executable, "-i -l unix", file], capture_output=True, shell=True) + [executable, "-i", file], capture_output=True, shell=True) print("Format: %s \t return: %s" % (file, process.returncode)) From ae9390add3350f186978729108ee70a72d074093 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:04:34 +0200 Subject: [PATCH 19/36] Change comment position --- Tools/check_format_qml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/check_format_qml.py b/Tools/check_format_qml.py index b8443e35..f824c114 100644 --- a/Tools/check_format_qml.py +++ b/Tools/check_format_qml.py @@ -14,7 +14,6 @@ import shutil stdout.reconfigure(encoding='utf-8') -# Instead of comparing the direct outputs (which was leading to ambiguous results), this function uses a workaround that checks the file's MD5 hash before and after formatting. def format_qml_file(file): executable = "qmlformat" if os.name == 'nt': @@ -34,6 +33,8 @@ def compute_md5(file_path): return hashlib.md5(f.read()).hexdigest() +# Instead of comparing the direct outputs (which was leading to ambiguous results), +# this function uses a workaround that checks the file's MD5 hash before and after formatting. def check_format_qml_file(file): executable = "qmlformat" if os.name == 'nt': From f1facf2bfad6542559121e88e2f56f469bc3fd56 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:22:59 +0200 Subject: [PATCH 20/36] Add explicit dependencies --- .gitlab/ci/build_release_jobs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 0481a6b4..8ffede34 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -40,6 +40,10 @@ steam_osx: release_job: stage: release image: python:3.11 + dependencies: + - steam_linux + - steam_windows + - steam_osx rules: - if: "$CI_COMMIT_TAG" # Run this job when a tag is created when: on_success # Only when all previous jobs succeed From 72f44a6a1a85c688be0200080234629116979423 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:23:14 +0200 Subject: [PATCH 21/36] Fix git tag parsing --- Tools/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/util.py b/Tools/util.py index 6e79a641..4efa8c74 100644 --- a/Tools/util.py +++ b/Tools/util.py @@ -121,9 +121,9 @@ def get_latest_git_tag(): def parse_semver(tag): # Regular expression to match semver - # Like V0.15.0-RC1-305-g18b8c402 + # Like v0.15.1-RC1-305-g18b8c402 # Do NOT add a - between RC and the version number (1 in this example) - pattern = r'(?i)^v?(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?(?:-(\d+)-g([a-f0-9]+))?$' + pattern = r'(?i)^v?(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9]+))?(?:-(\d+)-g([a-f0-9]+))?$' match = re.match(pattern, tag) if match: major, minor, patch, pre_release, commits_since, commit_hash = match.groups() From 126af43f5ca52f6a3c927e3a435b3e930483f50c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:29:05 +0200 Subject: [PATCH 22/36] Add license SPDX checker script --- Tools/check_license_header.py | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Tools/check_license_header.py diff --git a/Tools/check_license_header.py b/Tools/check_license_header.py new file mode 100644 index 00000000..f76170d9 --- /dev/null +++ b/Tools/check_license_header.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +import argparse +from format_util import find_files +from format_util import execute_threaded +from sys import stdout +import util + +stdout.reconfigure(encoding='utf-8') + + +def check_license_header_file_function(file_path): + """ + Check if the given file has a license header in its first or second line. + + Parameters: + - file_path (str): Path to the file to be checked. + + Returns: + - bool: True if the license header is present, otherwise False. + """ + try: + with open(file_path, 'r') as f: + # Read the first two lines of the file + first_line = f.readline().strip() + second_line = f.readline().strip() + + # Check if either of the two lines has the required header + if "SPDX-License-Identifier:" in first_line or "SPDX-License-Identifier:" in second_line: + return True + else: + print(f"INVALID: {file_path}") + return False + except Exception as e: + print(f"Error reading the file: {e}") + return False + + +def main(git_staged_only=False): + + # Setting exclude_folders before calling the function + exclude_folders = ( + "ThirdParty", "ScreenPlayWorkshop/SteamSDK", "build-x64-windows-release") + file_endings = ('.cpp', '.h', '.qml') + file_list = find_files(file_endings_tuple=file_endings, + path=util.repo_root_path(), + git_staged_only=git_staged_only, + exclude_folders=exclude_folders) + result = execute_threaded(file_list, check_license_header_file_function) + if result is False: + print("At least one file is missing the license header!") + # Depending on your requirement, you can exit the script here + exit(1) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--s", '--stage-only', action="store_true", dest="stage_only", + default=False) + args = parser.parse_args() + main(args.stage_only) From befa765117ef716549b76cbde2bc9a1673fec6f3 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:44:38 +0200 Subject: [PATCH 23/36] Fix zip naming and hash creation --- Tools/publish_ci.py | 20 +++++++++++++------- Tools/util.py | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Tools/publish_ci.py b/Tools/publish_ci.py index 579b9bd3..562d384d 100644 --- a/Tools/publish_ci.py +++ b/Tools/publish_ci.py @@ -1,20 +1,26 @@ import hashlib import os +from pathlib import Path +import util def combine_sha256(): + tag = os.environ['CI_COMMIT_TAG'] + + # Get the repo root path as a Path object + root_path = Path(util.repo_root_path()) + files = [ - "build-x64-linux-release/ScreenPlay-" + - os.environ['CI_COMMIT_TAG'] + "-x64-linux-release.zip", - "build-x64-windows-release/ScreenPlay-" + - os.environ['CI_COMMIT_TAG'] + "-x64-windows-release.zip", - "build-64-osx-universal-release/ScreenPlay-" + - os.environ['CI_COMMIT_TAG'] + "-x64-osx-universal-release.zip" + Path( + f"{root_path}/build-x64-windows-release/ScreenPlay-{tag}-x64-windows-release.zip"), + Path( + f"{root_path}/build-x64-linux-release/ScreenPlay-{tag}-x64-linux-release.zip"), + Path(f"{root_path}/build-64-osx-universal-release/ScreenPlay-{tag}-64-osx-universal-release.zip") ] with open('SHA512-SUMS.txt', 'w') as f_out: for file in files: - with open(f"{file}.sha256.txt", 'r') as f_in: + with open(file.with_name(f"{file.name}.sha256.txt"), 'r') as f_in: sha256_hash = f_in.read().strip() sha512_hash = hashlib.sha512(sha256_hash.encode()).hexdigest() f_out.write(f"{sha512_hash} {file}\n") diff --git a/Tools/util.py b/Tools/util.py index 4efa8c74..5a24cca1 100644 --- a/Tools/util.py +++ b/Tools/util.py @@ -140,7 +140,7 @@ def parse_semver(tag): def semver_to_string(semver_dict): - version_str = f"V{semver_dict['major']}.{semver_dict['minor']}.{semver_dict['patch']}" + version_str = f"v{semver_dict['major']}.{semver_dict['minor']}.{semver_dict['patch']}" if semver_dict['pre_release']: version_str += f"-{semver_dict['pre_release']}" return version_str From e9f4948b7251790676571f7d0464ea52eec1ac4e Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 12:48:51 +0200 Subject: [PATCH 24/36] Fix osx arch namings --- .gitlab/ci/build_release_jobs.yml | 8 ++++---- Tools/{publish_ci.py => create_sha512.py} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename Tools/{publish_ci.py => create_sha512.py} (100%) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 8ffede34..7db9c26b 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -34,8 +34,8 @@ steam_osx: - if: "$CI_COMMIT_TAG" artifacts: paths: - - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip - - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip.sha256.txt + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip + - build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip.sha256.txt release_job: stage: release @@ -50,7 +50,7 @@ release_job: script: # 1. Combining sha256 files into a SHA512-SUMS.txt - echo "Combining sha256 files into a SHA512-SUMS.txt" - - python3 Tools/publish_ci.py + - python3 Tools/create_sha512.py # 2. Connect to kelteseth.com and handle the folder - echo "Managing remote folder" - apt-get update && apt-get install -y sshpass @@ -59,7 +59,7 @@ release_job: - echo "Uploading files" - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ release: tag_name: $CI_COMMIT_TAG diff --git a/Tools/publish_ci.py b/Tools/create_sha512.py similarity index 100% rename from Tools/publish_ci.py rename to Tools/create_sha512.py From 2a39f709646a607c3b41e6aa702924adfd0111eb Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 14:26:25 +0200 Subject: [PATCH 25/36] Fix ssh connection using ip to work around the host auth Fix folder creation logic Fix osx names --- .gitlab/ci/build_release_jobs.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 7db9c26b..da6aa1fd 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -54,13 +54,13 @@ release_job: # 2. Connect to kelteseth.com and handle the folder - echo "Managing remote folder" - apt-get update && apt-get install -y sshpass - - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@kelteseth.com "if [ -d /getsp.de/$CI_COMMIT_TAG ]; then rm -r /getsp.de/$CI_COMMIT_TAG; else mkdir /getsp.de/$CI_COMMIT_TAG; fi" + - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/$CI_COMMIT_TAG; mkdir /getsp.de/$CI_COMMIT_TAG;" # 3. Upload files to the remote folder - echo "Uploading files" - - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@kelteseth.com:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ release: tag_name: $CI_COMMIT_TAG name: "ScreenPlay $CI_COMMIT_TAG Released!" @@ -72,4 +72,6 @@ release_job: - name: šŸŖŸ Windows x64 build url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" - name: šŸ OSX universal build - url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-osx-universal-release.zip" + url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip" + - name: ā„¹ļø SHA512-SUMS.txt + url: "https://getsp.de/$CI_COMMIT_TAG/SHA512-SUMS.txt" From 7a00984b2781c27fdd5f7143667be71311c50f9c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 15:17:18 +0200 Subject: [PATCH 26/36] Remove dependencies --- .gitlab/ci/base_jobs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab/ci/base_jobs.yml b/.gitlab/ci/base_jobs.yml index 3c345ca0..35f2f686 100644 --- a/.gitlab/ci/base_jobs.yml +++ b/.gitlab/ci/base_jobs.yml @@ -1,4 +1,5 @@ .base_windows_build: + dependencies: [] before_script: - python -m pip install -U pip wheel - python -m pip install -r Tools/requirements.txt @@ -12,6 +13,7 @@ - build-x64-windows-release/ScreenPlay-Installer.exe .base_linux_build: + dependencies: [] before_script: # Otherwise libglib2 needs interaction - export DEBIAN_FRONTEND=noninteractive @@ -34,6 +36,7 @@ - build-x64-linux-release/bin/ .base_osx_build: + dependencies: [] before_script: - pip3 install -U pip - pip3 install -r Tools/requirements.txt From 9cf2e999b1071774db4cd7dc2f852eb72a747417 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 15:25:35 +0200 Subject: [PATCH 27/36] Fix job logic never executing --- .gitlab/ci/check_jobs.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index b190e2bf..5c0045b5 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -1,9 +1,6 @@ formatting: stage: check allow_failure: true - rules: - - if: $CI_COMMIT_TAG - when: never image: name: ubuntu:23.10 tags: From 81f6230d4dc57997ae2d31488b113877bbb1daa3 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 20 Aug 2023 15:30:09 +0200 Subject: [PATCH 28/36] Add missing ssh dependency --- .gitlab/ci/build_release_jobs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index da6aa1fd..f63e0743 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -51,9 +51,9 @@ release_job: # 1. Combining sha256 files into a SHA512-SUMS.txt - echo "Combining sha256 files into a SHA512-SUMS.txt" - python3 Tools/create_sha512.py - # 2. Connect to kelteseth.com and handle the folder + # 2. Connect and handle the folder - echo "Managing remote folder" - - apt-get update && apt-get install -y sshpass + - apt-get update && apt-get install -y sshpass ssh - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/$CI_COMMIT_TAG; mkdir /getsp.de/$CI_COMMIT_TAG;" # 3. Upload files to the remote folder - echo "Uploading files" From e933e0a50adb3a3223a69ec378e98cc1ebce2561 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Tue, 22 Aug 2023 16:36:02 +0200 Subject: [PATCH 29/36] Add ip to known hosts --- .gitlab/ci/build_release_jobs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index f63e0743..928ce8ff 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -53,7 +53,9 @@ release_job: - python3 Tools/create_sha512.py # 2. Connect and handle the folder - echo "Managing remote folder" - - apt-get update && apt-get install -y sshpass ssh + - apt update + - apt install -y sshpass ssh + - ssh-keyscan 91.204.46.10 >> ~/.ssh/known_hosts - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/$CI_COMMIT_TAG; mkdir /getsp.de/$CI_COMMIT_TAG;" # 3. Upload files to the remote folder - echo "Uploading files" From f5ab76186ab1288c1648c4039ae61cae596df4bc Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Tue, 22 Aug 2023 19:45:35 +0200 Subject: [PATCH 30/36] Fix missing release-cli Remove dependencies from check_jobs Remove qml format until qmlformat is installed --- .gitlab/ci/build_release_jobs.yml | 9 +++++---- .gitlab/ci/check_jobs.yml | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 928ce8ff..676f6a9f 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -49,12 +49,13 @@ release_job: when: on_success # Only when all previous jobs succeed script: # 1. Combining sha256 files into a SHA512-SUMS.txt - - echo "Combining sha256 files into a SHA512-SUMS.txt" - python3 Tools/create_sha512.py - # 2. Connect and handle the folder - - echo "Managing remote folder" + # 2. Install dependencies and handle the folder - apt update - - apt install -y sshpass ssh + - apt install -y sshpass ssh curl + - curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64" + - chmod +x /usr/local/bin/release-cli + - release-cli -v - ssh-keyscan 91.204.46.10 >> ~/.ssh/known_hosts - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/$CI_COMMIT_TAG; mkdir /getsp.de/$CI_COMMIT_TAG;" # 3. Upload files to the remote folder diff --git a/.gitlab/ci/check_jobs.yml b/.gitlab/ci/check_jobs.yml index 5c0045b5..f3890288 100644 --- a/.gitlab/ci/check_jobs.yml +++ b/.gitlab/ci/check_jobs.yml @@ -1,4 +1,5 @@ formatting: + dependencies: [] stage: check allow_failure: true image: @@ -14,4 +15,4 @@ formatting: - cd Tools - python check_format_cmake.py --check - python check_format_cpp.py --check - - python check_format_qml.py --check + #- python check_format_qml.py --check From 00ed9816e3e853e1b366e8b966c3f8d612ebaa68 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Wed, 23 Aug 2023 17:47:16 +0200 Subject: [PATCH 31/36] Fix release paths --- .gitlab/ci/build_release_jobs.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.gitlab/ci/build_release_jobs.yml b/.gitlab/ci/build_release_jobs.yml index 676f6a9f..b24cdc06 100644 --- a/.gitlab/ci/build_release_jobs.yml +++ b/.gitlab/ci/build_release_jobs.yml @@ -55,15 +55,13 @@ release_job: - apt install -y sshpass ssh curl - curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64" - chmod +x /usr/local/bin/release-cli - - release-cli -v - ssh-keyscan 91.204.46.10 >> ~/.ssh/known_hosts - - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/$CI_COMMIT_TAG; mkdir /getsp.de/$CI_COMMIT_TAG;" + - sshpass -p $GETSP_PASSWORD ssh $GETSP_USERNAME@91.204.46.10 "rm -rf /getsp.de/httpdocs/releases/$CI_COMMIT_TAG; mkdir /getsp.de/httpdocs/releases/$CI_COMMIT_TAG;" # 3. Upload files to the remote folder - - echo "Uploading files" - - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ - - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@91.204.46.10:/getsp.de/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-linux-release/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/httpdocs/releases/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-x64-windows-release/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/httpdocs/releases/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp build-64-osx-universal-release/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip $GETSP_USERNAME@91.204.46.10:/getsp.de/httpdocs/releases/$CI_COMMIT_TAG/ + - sshpass -p $GETSP_PASSWORD scp SHA512-SUMS.txt $GETSP_USERNAME@91.204.46.10:/getsp.de/httpdocs/releases/$CI_COMMIT_TAG/ release: tag_name: $CI_COMMIT_TAG name: "ScreenPlay $CI_COMMIT_TAG Released!" @@ -71,10 +69,10 @@ release_job: assets: links: - name: šŸ§ Linux x64 build - url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip" + url: "https://getsp.de/releases/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-linux-release.zip" - name: šŸŖŸ Windows x64 build - url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" + url: "https://getsp.de/releases/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-x64-windows-release.zip" - name: šŸ OSX universal build - url: "https://getsp.de/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip" + url: "https://getsp.de/releases/$CI_COMMIT_TAG/ScreenPlay-$CI_COMMIT_TAG-64-osx-universal-release.zip" - name: ā„¹ļø SHA512-SUMS.txt - url: "https://getsp.de/$CI_COMMIT_TAG/SHA512-SUMS.txt" + url: "https://getsp.de/releases/$CI_COMMIT_TAG/SHA512-SUMS.txt" From 716db7ac66f8de3473cdfb1f4e7472c1eec66799 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 24 Aug 2023 08:40:10 +0200 Subject: [PATCH 32/36] Fix sha using path instead of filename --- CMake/GetProjectVersion.cmake | 2 +- Tools/create_sha512.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/GetProjectVersion.cmake b/CMake/GetProjectVersion.cmake index f0f6011b..02f43d24 100644 --- a/CMake/GetProjectVersion.cmake +++ b/CMake/GetProjectVersion.cmake @@ -22,7 +22,7 @@ function(get_project_version VERSION_VAR) ) message(STATUS "Parsing git tag: ${GIT_VERSION}") - string(REPLACE "v" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'V' prefix + string(REPLACE "v" "" STRIPPED_VERSION "${GIT_VERSION}") # Remove the 'v' prefix string(REPLACE "-" ";" VERSION_LIST ${STRIPPED_VERSION}) list(GET VERSION_LIST 0 VERSION_STRING) diff --git a/Tools/create_sha512.py b/Tools/create_sha512.py index 562d384d..79ee704d 100644 --- a/Tools/create_sha512.py +++ b/Tools/create_sha512.py @@ -23,7 +23,7 @@ def combine_sha256(): with open(file.with_name(f"{file.name}.sha256.txt"), 'r') as f_in: sha256_hash = f_in.read().strip() sha512_hash = hashlib.sha512(sha256_hash.encode()).hexdigest() - f_out.write(f"{sha512_hash} {file}\n") + f_out.write(f"{sha512_hash} {file.name}\n") if __name__ == "__main__": From fdbf077f0e304bb96ab5c2f264113160a9df9f40 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 24 Aug 2023 16:02:43 +0200 Subject: [PATCH 33/36] WIP: Add mac .dmg installer This does not yet work with signing of the macos .dmg ScreenPlay-Installer.dmg: rejected (the code is valid but does not seem to be an app) --- CMake/CreateDmgInstaller.cmake | 22 +++++++++++++++++ CMakeLists.txt | 8 +++++-- Tools/build.py | 25 ++++++++++++------- Tools/macos_sign.py | 44 ++++++++++++++++++---------------- 4 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 CMake/CreateDmgInstaller.cmake diff --git a/CMake/CreateDmgInstaller.cmake b/CMake/CreateDmgInstaller.cmake new file mode 100644 index 00000000..15c87e64 --- /dev/null +++ b/CMake/CreateDmgInstaller.cmake @@ -0,0 +1,22 @@ +message(STATUS "[DMG INSTALLER ENABLED]: Configuring. This can take some time...") + +set(CPACK_GENERATOR "DragNDrop") +set(CPACK_DMG_FORMAT "UDBZ") +set(CPACK_DMG_VOLUME_NAME "ScreenPlay") +set(CPACK_SYSTEM_NAME "OSX") +set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/ScreenPlay/assets/icons/app.ico") + +set(CPACK_COMPONENTS_GROUPING IGNORE) +set(CPACK_PACKAGE_NAME "ScreenPlay") +set(CPACK_PACKAGE_FILE_NAME "ScreenPlay-Installer") +set(CPACK_PACKAGE_VENDOR "Elias Steurer") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}") + +include(CPack) + +# Install all files from /bin +install( + DIRECTORY "${CMAKE_BINARY_DIR}/bin/" + COMPONENT ScreenPlay + DESTINATION "./") \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b8677270..352059a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,8 +135,12 @@ if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() -if(${SCREENPLAY_INSTALLER} AND NOT APPLE) - include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CreateIFWInstaller.cmake) +if(${SCREENPLAY_INSTALLER}) + if(APPLE) + include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CreateDmgInstaller.cmake) + else() + include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CreateIFWInstaller.cmake) + endif() endif() message(STATUS "[PROJECT] PROJECT_VERSION = ${PROJECT_VERSION}") diff --git a/Tools/build.py b/Tools/build.py index 74f03713..76ba3469 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -104,18 +104,29 @@ def execute( package_duration = time.time() - step_time print(f"ā±ļø package_duration: {package_duration}s") + if platform.system() == "Darwin": + if (build_config.sign_osx): + print(f"Sign binary at: {build_config.bin_dir}") + macos_sign.sign(build_config=build_config) + # Creates a Qt InstallerFrameWork (IFW) installer if build_config.create_installer == "ON": step_time = time.time() build_installer(build_config, build_result) build_installer_duration = time.time() - step_time - print(f"ā±ļø build_installer_duration: {build_installer_duration}s") + print(f"ā±ļø build_installer_duration: {build_installer_duration}s") + + if platform.system() == "Darwin": + if (build_config.sign_osx): + print(f"Sign ScreenPlay-installer.dmg at: {build_config.bin_dir}") + macos_sign.sign_dmg(build_config=build_config) # Create a zip file of the build - step_time = time.time() - build_result = zip(build_config, build_result) - zip_duration = time.time() - step_time - print(f"ā±ļø zip_duration: {zip_duration}s") + if platform.system() != "Darwin": + step_time = time.time() + build_result = zip(build_config, build_result) + zip_duration = time.time() - step_time + print(f"ā±ļø zip_duration: {zip_duration}s") duration = time.time() - start_time print(f"ā±ļø Build completed in: {duration}s") @@ -247,10 +258,6 @@ def package(build_config: BuildConfig): run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path, build_bin_dir=build_bin_dir, app="ScreenPlayWidget"), cwd=cwd) - if (build_config.sign_osx): - print(f"Sign binary at: {build_config.bin_dir}") - macos_sign.sign(build_config=build_config) - if platform.system() == "Windows": print("Executing deploy commands...") run(build_config.package_command.format( diff --git a/Tools/macos_sign.py b/Tools/macos_sign.py index 6a1f9ab3..360dce00 100644 --- a/Tools/macos_sign.py +++ b/Tools/macos_sign.py @@ -7,6 +7,7 @@ import time stdout.reconfigure(encoding='utf-8') + def sign(build_config: BuildConfig): print("Run codedesign") #run("codesign -f -s 'Developer ID Application: Elias Steurer (V887LHYKRH)' --verbose --force --timestamp --options 'runtime' -f --entitlements '../../ScreenPlay/entitlements.plist' 'ScreenPlay.app/' ", @@ -17,6 +18,7 @@ def sign(build_config: BuildConfig): # run(base_sign_command.format(app="ffprobe"), cwd=build_config.bin_dir) run("codesign --deep -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --verbose --force --timestamp --options \"runtime\" --entitlements \"../../ScreenPlay/entitlements.plist\" \"ScreenPlay.app/\"", cwd=build_config.bin_dir) + print("Run codedesign verify") run("codesign --verify --verbose=4 'ScreenPlay.app/'", @@ -41,25 +43,27 @@ def sign(build_config: BuildConfig): print("Run spctl assess") run("spctl --assess --verbose 'ScreenPlay.app/'", cwd=build_config.bin_dir) - print("Remove *.app.zip files.") + print("Remove ScreenPlay.app.zip.") run("rm ScreenPlay.app.zip", cwd=build_config.bin_dir) + +def sign_dmg(build_config: BuildConfig): + # Sign the DMG + run("codesign -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) - - # We also need to sign the installer in osx: - if build_config.create_installer == "ON": - 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_config.build_folder) - run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", - cwd=build_config.build_folder) - run("xcnotary notarize ScreenPlay-Installer.dmg/ScreenPlay-Installer.app -d kelteseth@gmail.com -k ScreenPlay", - cwd=build_config.build_folder) - run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/\"", - cwd=build_config.build_folder) - - run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/\"", cwd=build_config.build_folder) - run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/\"", - cwd=build_config.build_folder) - run("xcnotary notarize ScreenPlay-Installer.dmg -d kelteseth@gmail.com -k ScreenPlay", - cwd=build_config.build_folder) - run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/\"", - cwd=build_config.build_folder) - + # Verify the DMG's signature + run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) + + # Pack the DMG for notarization + run("ditto -c -k --keepParent ScreenPlay-Installer.dmg ScreenPlay-Installer.dmg.zip", cwd=build_config.build_folder) + + # Notarize the DMG using notarytool + run("xcrun notarytool submit ScreenPlay-Installer.dmg.zip --keychain-profile 'ScreenPlay' --wait", cwd=build_config.build_folder) + + # Staple the notarization ticket to the DMG + run("xcrun stapler staple ScreenPlay-Installer.dmg", cwd=build_config.build_folder) + + # Check the notarization status for the DMG + run("spctl --assess --verbose \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) + + # Clean up the zip file + run("rm ScreenPlay-Installer.dmg.zip", cwd=build_config.build_folder) From 325c47f87bea690c4ba47ac271435f5f642039f8 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 24 Aug 2023 16:17:48 +0200 Subject: [PATCH 34/36] Move BuildConfig and BuildResult into dedicated files this fixed the circular dependency in the build_and_publish script than internally imports the macos_sign --- Tools/build.py | 58 ++++---------------------------------- Tools/build_and_publish.py | 6 ++-- Tools/build_config.py | 29 +++++++++++++++++++ Tools/build_result.py | 20 +++++++++++++ Tools/macos_sign.py | 47 ++++++++++++++++-------------- 5 files changed, 85 insertions(+), 75 deletions(-) create mode 100644 Tools/build_config.py create mode 100644 Tools/build_result.py diff --git a/Tools/build.py b/Tools/build.py index 76ba3469..6a91d87d 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -8,6 +8,8 @@ import argparse import time import zipfile import defines +from build_result import BuildResult +from build_config import BuildConfig from typing import Tuple from pathlib import Path import macos_sign @@ -25,55 +27,6 @@ def clean_build_dir(build_dir): build_dir.mkdir(parents=True, exist_ok=True) -class BuildResult: - # Windows example with absolute paths: - # [...]/build-x64-windows-release/ - build: Path - # [...]/build-x64-windows-release/bin - bin: Path - # [...]/build-x64-windows-release/ScreenPlay-Installer.exe - installer: Path - # [...]/build-x64-windows-release/ScreenPlay-Installer.zip - installer_zip: Path - # [...]/build-x64-windows-release/ScreenPlay-0.X.0-RCX-x64-windows-release.zip - build_zip: Path - # [...]/build-x64-windows-release/ScreenPlay-0.X.0-RCX-x64-windows-release.txt :sha256, needed for scoop - build_hash: Path - # x64, arm64, universal - build_arch: str - - -class BuildConfig: - root_path: str - cmake_osx_architectures: str - cmake_target_triplet: str - package: bool - osx_bundle: str - package_command: str - executable_file_ending: str - # qt_* use either aqt or from the maintenance tool - qt_path: str # C:\Qt - qt_bin_path: str # C:\Qt\6.3.2\msvc2019_64 - qt_version: str - qt_ifw_version: str - ifw_root_path: str - cmake_toolchain_file: str - aqt_install_qt_packages: str - aqt_install_tool_packages: str - executable_file_ending: str - build_folder: str - bin_dir: str - screenplay_version: str - # CMake variables need str: "ON" or "OFF" - build_steam: str - build_tests: str - build_deploy: str - build_type: str - build_architecture: str - create_installer: str - sign_osx: bool - - def execute( build_config: BuildConfig ) -> BuildResult: @@ -114,11 +67,12 @@ def execute( step_time = time.time() build_installer(build_config, build_result) build_installer_duration = time.time() - step_time - print(f"ā±ļø build_installer_duration: {build_installer_duration}s") - + print(f"ā±ļø build_installer_duration: {build_installer_duration}s") + if platform.system() == "Darwin": if (build_config.sign_osx): - print(f"Sign ScreenPlay-installer.dmg at: {build_config.bin_dir}") + print( + f"Sign ScreenPlay-installer.dmg at: {build_config.bin_dir}") macos_sign.sign_dmg(build_config=build_config) # Create a zip file of the build diff --git a/Tools/build_and_publish.py b/Tools/build_and_publish.py index 3ee955b2..a04b3df6 100644 --- a/Tools/build_and_publish.py +++ b/Tools/build_and_publish.py @@ -9,6 +9,8 @@ from pathlib import Path import platform import paramiko import defines +from build_result import BuildResult +from build_config import BuildConfig from util import sftp_exists, get_latest_git_tag, parse_semver, semver_to_string from sys import stdout @@ -51,9 +53,9 @@ if __name__ == "__main__": print("No git tags found.") exit(-1) - build_result = build.BuildResult() + build_result = BuildResult() - build_config = build.BuildConfig() + build_config = BuildConfig() build_config.qt_version = defines.QT_VERSION build_config.qt_ifw_version = defines.QT_IFW_VERSION build_config.build_steam = "ON" diff --git a/Tools/build_config.py b/Tools/build_config.py new file mode 100644 index 00000000..0241c29b --- /dev/null +++ b/Tools/build_config.py @@ -0,0 +1,29 @@ +class BuildConfig: + root_path: str + cmake_osx_architectures: str + cmake_target_triplet: str + package: bool + osx_bundle: str + package_command: str + executable_file_ending: str + # qt_* use either aqt or from the maintenance tool + qt_path: str # C:\Qt + qt_bin_path: str # C:\Qt\6.3.2\msvc2019_64 + qt_version: str + qt_ifw_version: str + ifw_root_path: str + cmake_toolchain_file: str + aqt_install_qt_packages: str + aqt_install_tool_packages: str + executable_file_ending: str + build_folder: str + bin_dir: str + screenplay_version: str + # CMake variables need str: "ON" or "OFF" + build_steam: str + build_tests: str + build_deploy: str + build_type: str + build_architecture: str + create_installer: str + sign_osx: bool diff --git a/Tools/build_result.py b/Tools/build_result.py new file mode 100644 index 00000000..d253123b --- /dev/null +++ b/Tools/build_result.py @@ -0,0 +1,20 @@ + +from pathlib import Path + + +class BuildResult: + # Windows example with absolute paths: + # [...]/build-x64-windows-release/ + build: Path + # [...]/build-x64-windows-release/bin + bin: Path + # [...]/build-x64-windows-release/ScreenPlay-Installer.exe + installer: Path + # [...]/build-x64-windows-release/ScreenPlay-Installer.zip + installer_zip: Path + # [...]/build-x64-windows-release/ScreenPlay-0.X.0-RCX-x64-windows-release.zip + build_zip: Path + # [...]/build-x64-windows-release/ScreenPlay-0.X.0-RCX-x64-windows-release.txt :sha256, needed for scoop + build_hash: Path + # x64, arm64, universal + build_arch: str diff --git a/Tools/macos_sign.py b/Tools/macos_sign.py index 360dce00..49ba8ce4 100644 --- a/Tools/macos_sign.py +++ b/Tools/macos_sign.py @@ -1,34 +1,32 @@ #!/usr/bin/python3 # SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only -from build import BuildConfig -from util import run +from build_config import BuildConfig +from util import run from sys import stdout -import time - stdout.reconfigure(encoding='utf-8') def sign(build_config: BuildConfig): print("Run codedesign") - #run("codesign -f -s 'Developer ID Application: Elias Steurer (V887LHYKRH)' --verbose --force --timestamp --options 'runtime' -f --entitlements '../../ScreenPlay/entitlements.plist' 'ScreenPlay.app/' ", + # run("codesign -f -s 'Developer ID Application: Elias Steurer (V887LHYKRH)' --verbose --force --timestamp --options 'runtime' -f --entitlements '../../ScreenPlay/entitlements.plist' 'ScreenPlay.app/' ", # cwd=build_config.bin_dir) # Do not use --deep https://developer.apple.com/forums/thread/129980 # base_sign_command = "codesign -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --verbose --force --timestamp --options \"runtime\" \"ScreenPlay.app/Contents/MacOS/{app}\"" # run(base_sign_command.format(app="ffmpeg"), cwd=build_config.bin_dir) # run(base_sign_command.format(app="ffprobe"), cwd=build_config.bin_dir) - run("codesign --deep -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --verbose --force --timestamp --options \"runtime\" --entitlements \"../../ScreenPlay/entitlements.plist\" \"ScreenPlay.app/\"", + run("codesign --deep -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --verbose --force --timestamp --options \"runtime\" --entitlements \"../../ScreenPlay/entitlements.plist\" \"ScreenPlay.app/\"", cwd=build_config.bin_dir) - print("Run codedesign verify") - run("codesign --verify --verbose=4 'ScreenPlay.app/'", + run("codesign --verify --verbose=4 'ScreenPlay.app/'", cwd=build_config.bin_dir) # Note the profile is the one name of the first step of (App Store Connect API) in the macOSSigning.md # xcrun notarytool submit "ScreenPlay.app.zip" --keychain-profile "ScreenPlay" --wait # xcrun stapler staple "ScreenPlay.app" print("Packing .apps for upload") - run("ditto -c -k --keepParent 'ScreenPlay.app' 'ScreenPlay.app.zip'", cwd=build_config.bin_dir) + run("ditto -c -k --keepParent 'ScreenPlay.app' 'ScreenPlay.app.zip'", + cwd=build_config.bin_dir) # run this if you get an error: # `xcrun notarytool log --apple-id "xxxxx@xxxx.com" --password "xxxx-xxxx-xxxx-xxxx" --team-id "xxxxxxxxxxx" ` @@ -36,7 +34,8 @@ def sign(build_config: BuildConfig): # id: xxxxxx-xxxxxx-xxxx-xxxxx-xxxxx # status: Invalid print("Run xcnotary submit") - run("xcrun notarytool submit --keychain-profile 'ScreenPlay' ScreenPlay.app.zip --wait", cwd=build_config.bin_dir) + run("xcrun notarytool submit --keychain-profile 'ScreenPlay' ScreenPlay.app.zip --wait", + cwd=build_config.bin_dir) print("Run stapler staple") run("xcrun stapler staple ScreenPlay.app", cwd=build_config.bin_dir) @@ -46,24 +45,30 @@ def sign(build_config: BuildConfig): print("Remove ScreenPlay.app.zip.") run("rm ScreenPlay.app.zip", cwd=build_config.bin_dir) + def sign_dmg(build_config: BuildConfig): # Sign the DMG run("codesign -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) - + # Verify the DMG's signature - run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) - + run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg\"", + cwd=build_config.build_folder) + # Pack the DMG for notarization - run("ditto -c -k --keepParent ScreenPlay-Installer.dmg ScreenPlay-Installer.dmg.zip", cwd=build_config.build_folder) - + run("ditto -c -k --keepParent ScreenPlay-Installer.dmg ScreenPlay-Installer.dmg.zip", + cwd=build_config.build_folder) + # Notarize the DMG using notarytool - run("xcrun notarytool submit ScreenPlay-Installer.dmg.zip --keychain-profile 'ScreenPlay' --wait", cwd=build_config.build_folder) - + run("xcrun notarytool submit ScreenPlay-Installer.dmg.zip --keychain-profile 'ScreenPlay' --wait", + cwd=build_config.build_folder) + # Staple the notarization ticket to the DMG - run("xcrun stapler staple ScreenPlay-Installer.dmg", cwd=build_config.build_folder) - + run("xcrun stapler staple ScreenPlay-Installer.dmg", + cwd=build_config.build_folder) + # Check the notarization status for the DMG - run("spctl --assess --verbose \"ScreenPlay-Installer.dmg\"", cwd=build_config.build_folder) - + run("spctl --assess --verbose \"ScreenPlay-Installer.dmg\"", + cwd=build_config.build_folder) + # Clean up the zip file run("rm ScreenPlay-Installer.dmg.zip", cwd=build_config.build_folder) From 4c0881ebfe747ffd4869660202f34bfa58650218 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 24 Aug 2023 16:43:46 +0200 Subject: [PATCH 35/36] Refactor script to only job is to upload to steam our ci does the rest --- Tools/build.py | 2 +- ..._publish.py => build_and_publish_steam.py} | 54 +++---------------- 2 files changed, 7 insertions(+), 49 deletions(-) rename Tools/{build_and_publish.py => build_and_publish_steam.py} (58%) diff --git a/Tools/build.py b/Tools/build.py index 6a91d87d..7f312a90 100755 --- a/Tools/build.py +++ b/Tools/build.py @@ -49,7 +49,7 @@ def execute( step_time = time.time() build_result = build(build_config, build_result) build_duration = time.time() - step_time - # print(f"ā±ļø build_duration (for {build_config.build_architecture}): {build_duration}s") + print(f"ā±ļø build_duration: {build_duration}s") # Copies all needed libraries and assets into the bin folder step_time = time.time() diff --git a/Tools/build_and_publish.py b/Tools/build_and_publish_steam.py similarity index 58% rename from Tools/build_and_publish.py rename to Tools/build_and_publish_steam.py index a04b3df6..d8773bd9 100644 --- a/Tools/build_and_publish.py +++ b/Tools/build_and_publish_steam.py @@ -20,9 +20,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser( description='Build and Package ScreenPlay') parser.add_argument('--skip_steam_publish', '-skstp', action="store_true", - dest="skip_publish", default=False, help="skip publish") - parser.add_argument('--skip_getspde_publish', '-skgsp', action="store_true", - dest="skip_getspde_publish", default=False, help="skip getsp.de publish") + dest="skip_steam_publish", default=False, help="skip publish") parser.add_argument('--skip_build', '-skb', action="store_true", dest="skip_build", default=False, help="skip build. If we already have a build and only want to upload it") parser.add_argument('--steam_password', '-sp', action="store", @@ -33,6 +31,10 @@ if __name__ == "__main__": dest="hosting_password", help="ssh password") args = parser.parse_args() + if not args.skip_steam_publish and args.steam_password is None: + print("Steam password is required.") + sys.exit(1) + # Script needs to run in the tools folder tools_path = Path.cwd() os.chdir(tools_path) @@ -61,14 +63,11 @@ if __name__ == "__main__": build_config.build_steam = "ON" build_config.build_tests = "OFF" build_config.build_deploy = "ON" - build_config.create_installer = "ON" + build_config.create_installer = "OFF" build_config.build_type = "release" build_config.screenplay_version = screenplay_version if platform.system() == "Darwin" and not args.skip_build: - # We do not yet support a standalone osx installer - build_config.create_installer = "OFF" - # We need to manually package here at the end after build_config.package = True build_config.sign_osx = True @@ -77,53 +76,12 @@ if __name__ == "__main__": build_result = build.execute(build_config) if platform.system() == "Windows" and not args.skip_build: - build_config.build_architecture = "x64" - - if not args.skip_getspde_publish: - # Steamless version first - build_config.build_steam = "OFF" - build_result = build.execute(build_config) - ssh = paramiko.SSHClient() - ssh.load_system_host_keys() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect('kelteseth.com', username=args.hosting_username, - password=args.hosting_password) - sftp = ssh.open_sftp() - release_folder = "/getsp.de/" + build_config.screenplay_version + "/" - 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) - print("Uploading files...") - - 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() - - # Now build the steam version - os.chdir(tools_path) - build_config.build_steam = "ON" - build_config.create_installer = "OFF" build_result = build.execute(build_config) if args.skip_steam_publish: print("Skip steam publishing.") sys.exit(0) - if args.steam_password is None: - print("Steam password is required.") - sys.exit(1) - # Make sure to reset to tools path os.chdir(tools_path) steam_publish.publish( From 22b3eb91dd0d30e577e6935c150a38e08946a859 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 24 Aug 2023 17:17:22 +0200 Subject: [PATCH 36/36] Add check if we can log in before compiling --- Tools/build_and_publish_steam.py | 7 +- Tools/requirements.txt | 1 - Tools/steam_publish.py | 122 ++++++++++++++++++++++--------- 3 files changed, 94 insertions(+), 36 deletions(-) diff --git a/Tools/build_and_publish_steam.py b/Tools/build_and_publish_steam.py index d8773bd9..4f45725c 100644 --- a/Tools/build_and_publish_steam.py +++ b/Tools/build_and_publish_steam.py @@ -7,11 +7,10 @@ import os import build from pathlib import Path import platform -import paramiko import defines from build_result import BuildResult from build_config import BuildConfig -from util import sftp_exists, get_latest_git_tag, parse_semver, semver_to_string +from util import get_latest_git_tag, parse_semver, semver_to_string from sys import stdout stdout.reconfigure(encoding='utf-8') @@ -35,6 +34,10 @@ if __name__ == "__main__": print("Steam password is required.") sys.exit(1) + if not steam_publish.check_steam_login("tachiom", args.steam_password): + print("Failed to login to Steam!") + exit(1) + # Script needs to run in the tools folder tools_path = Path.cwd() os.chdir(tools_path) diff --git a/Tools/requirements.txt b/Tools/requirements.txt index 99e4a8f3..9a567f28 100644 --- a/Tools/requirements.txt +++ b/Tools/requirements.txt @@ -1,3 +1,2 @@ cmake-format -paramiko aqtinstall \ No newline at end of file diff --git a/Tools/steam_publish.py b/Tools/steam_publish.py index 2385cc92..cf9d7ab6 100644 --- a/Tools/steam_publish.py +++ b/Tools/steam_publish.py @@ -5,6 +5,7 @@ import sys import subprocess import shutil import argparse +from pathlib import Path from sys import platform from execute_util import execute from datetime import datetime @@ -16,6 +17,67 @@ from sys import stdout stdout.reconfigure(encoding='utf-8') + +class PublishConfig: + vdf_config_name: str + depot_config_name: str + steamcmd_path: Path + + +def init_publish_config(): + config = PublishConfig() + + root_path = cd_repo_root_path() + tools_path = os.path.join(root_path, "Tools") + contentBuiler_path = os.path.join(tools_path, "Steam/ContentBuilder/") + + if platform.system() == "Windows": + config.vdf_config_name = "app_build_windows.vdf" + config.depot_config_name = "depot_build_windows.vdf" + config.steamcmd_path = os.path.join( + contentBuiler_path, "builder/steamcmd.exe") + elif platform.system() == "Darwin": + config.vdf_config_name = "app_build_mac.vdf" + config.depot_config_name = "depot_build_mac.vdf" + config.steamcmd_path = os.path.join( + contentBuiler_path, "builder_osx/steamcmd") + execute(f"chmod +x {config.steamcmd_path}") + elif platform.system() == "Linux": + config.vdf_config_name = "app_build_linux.vdf" + config.depot_config_name = "depot_build_linux.vdf" + config.steamcmd_path = os.path.join( + contentBuiler_path, "builder_linux/steamcmd.sh") + execute(f"chmod +x {config.steamcmd_path}") + + return config + + +def check_steam_login(username: str, password: str): + config = init_publish_config() + cmd = [config.steamcmd_path, "+login", username, password, "+quit"] + + try: + with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as process: + try: + stdout, stderr = process.communicate( + timeout=60) # 1 minute timeout + for line in stdout.splitlines(): + print(line) # Print the line for debugging purposes + + if "Logging in user" in line: + return True + elif "Steam Guard code" in line: + process.terminate() + return False + except subprocess.TimeoutExpired: + process.kill() + print("Steam login check timed out after 1 minute.") + return False + except Exception as e: + print(f"Error during Steam login check: {e}") + return False + + # Executes steamcmd with username and password. Changes the content of the config # for better readability in the steam builds tab # https://partner.steamgames.com/apps/builds/672870 @@ -27,6 +89,7 @@ def get_git_revision_short_hash(): def get_git_commit_text(): return subprocess.check_output(['git', 'log', '-1', '--pretty=%B']) + def publish( steam_username, steam_password, @@ -36,30 +99,13 @@ def publish( # Make sure the script is always started from the same folder root_path = cd_repo_root_path() tools_path = os.path.join(root_path, "Tools") - contentBuiler_path = os.path.join(tools_path, "Steam/ContentBuilder/") - vdf_config_name = "" - depot_config_name = "" - steamcmd_path = "" - if platform.system() == "Windows": - vdf_config_name = "app_build_windows.vdf" - depot_config_name = "depot_build_windows.vdf" - steamcmd_path = os.path.join(contentBuiler_path, "builder/steamcmd.exe") - steamcmd_path = steamcmd_path.replace("/","\\") - elif platform.system() == "Darwin": - vdf_config_name = "app_build_mac.vdf" - depot_config_name = "depot_build_mac.vdf" - steamcmd_path = os.path.join(contentBuiler_path, "builder_osx/steamcmd") - execute(f"chmod +x {steamcmd_path}") - elif platform.system() == "Linux": - vdf_config_name = "app_build_linux.vdf" - depot_config_name = "depot_build_linux.vdf" - steamcmd_path = os.path.join(contentBuiler_path, "builder_linux/steamcmd.sh") - execute(f"chmod +x {steamcmd_path}") + config = init_publish_config() - print(f"Set steamCmd path: {steamcmd_path}") + print(f"Set steamCmd path: {config.steamcmd_path}") - abs_vdf_path = os.path.join(tools_path,"Steam/steamcmd/" + vdf_config_name) + abs_vdf_path = os.path.join( + tools_path, "Steam/steamcmd/" + config.vdf_config_name) if not os.path.isfile(abs_vdf_path): print("Incorrect vdf name") @@ -71,15 +117,19 @@ def publish( git_hash = get_git_revision_short_hash().decode("utf-8").replace("\n", "") git_commit_text = get_git_commit_text().decode("utf-8").replace("\n", "") # Remove ' and " that can occour it is a merge commit - git_commit_text = git_commit_text.replace('\"','') - git_commit_text = git_commit_text.replace('\'','') + git_commit_text = git_commit_text.replace('\"', '') + git_commit_text = git_commit_text.replace('\'', '') current_date_time = datetime.now().strftime("%d/%m/%Y, %H:%M:%S") - 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) + 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(os.path.join(tools_path,tmp_steam_config_foldername)) + tmp_steam_config_dir = os.path.abspath( + os.path.join(tools_path, tmp_steam_config_foldername)) if os.path.isdir(tmp_steam_config_dir): print(f"Deleting tmp config {tmp_steam_config_dir}") @@ -87,24 +137,30 @@ def publish( os.mkdir(tmp_steam_config_dir) - f = open(os.path.abspath(tmp_steam_config_dir + "/" + vdf_config_name), "w") + f = open(os.path.abspath(tmp_steam_config_dir + + "/" + config.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.join(tools_path, "Steam/steamcmd/" + depot_config_name) - copyfile(abs_depot_path, tmp_steam_config_dir + "/" + depot_config_name) + abs_depot_path = os.path.join( + tools_path, "Steam/steamcmd/" + config.depot_config_name) + copyfile(abs_depot_path, tmp_steam_config_dir + + "/" + config.depot_config_name) - tmp_steam_config_path = "\"" + os.path.abspath(os.path.join(tmp_steam_config_dir,vdf_config_name) ) + "\"" + tmp_steam_config_path = "\"" + \ + os.path.abspath(os.path.join( + tmp_steam_config_dir, config.vdf_config_name)) + "\"" print("Execute steamcmd on: " + tmp_steam_config_path) - execute(f"{steamcmd_path} +login {steam_username} {steam_password} +run_app_build {tmp_steam_config_path} +quit") + execute(f"{config.steamcmd_path} +login {steam_username} {steam_password} +run_app_build {tmp_steam_config_path} +quit") print("Deleting tmp config") shutil.rmtree(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, @@ -129,4 +185,4 @@ if __name__ == "__main__": steam_username=args.steam_username, steam_password=args.steam_password, set_live_branch_name=set_live_branch_name - ) \ No newline at end of file + )