1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Change CI to split into multile sections

Change version to be only set via git tags
This commit is contained in:
Elias Steurer 2023-08-11 17:00:24 +02:00
parent 1d3847e9b7
commit efc70e9fc0
9 changed files with 221 additions and 146 deletions

View File

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

46
.gitlab/ci/base_jobs.yml Normal file
View File

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

34
.gitlab/ci/build_jobs.yml Normal file
View File

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

View File

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

16
.gitlab/ci/check_jobs.yml Normal file
View File

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

View File

@ -2,6 +2,7 @@ project(CMake)
set(FILES
CMakeVariables.h.in
GetProjectVersion.cmake
GenerateCMakeVariableHeader.cmake
CopyRecursive.cmake
CreateIFWInstaller.cmake)

View File

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

View File

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

View File

@ -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')
@ -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
@ -95,7 +96,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 (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,7 +163,7 @@ 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"
@ -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