* Only install Python deps with deps script * Remove hard-coded Qt version in CI * Add example .env * Improve comments in .env file * Simplify config reader and Choco CI config * Actually return the config value * Move deps before Qt version env call * Remove `self.` * Move venv ensure to main * Fixed arg * Move config import to function * Move ensure_module to function * Simplify over-complicated `Version.cmake` * Move code to `github` module * Use `symless/next-version-action` * Make CMake version file even simpler * Set version from tag * Create release when master or release branch * Don't run CI on master push, only release * Fixed bac macro * Use new version values * Handle empty version env var * Also strip version file value * Remove quotes * Add @master to action * Read version from file * Simplify version file read * Fixed typo in env var * Remove unused var * Delete legacy build number action * Fixed env var * Version file read shouldn't be needed * Remove weird and unnecessary include path * Update ChangeLog * Remove unused config value * Better name for changelog check * Delete broken Flatpak CI * Run stale issue cron at midnight * Update ChangeLog * Add version input for manual run * Print next version * Fetch all tags * Use more idiomatic approach * Set to pre-release when master * Remove unnecessary `commitish` * Fixed wrong ID * More specific IDs * Reduce config needed for upload * Only /release can be non-pre-release * More discreet package path for gdrive * Try without setting path * Remove seemly unused step * Better name for Qt version step * Fixed bad var ref * Better name for package dir * Fixed bad input name * Add missing shell * Workflow to test upload action * Remove fetch tags * Use bash to cut version * Remove name and make conditional * Replace deprecated set-output * Fixed env var name * Missing dir sep char * Add comment to test workflow * Improve input descriptions * Replace deprecated set-output
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
from lib import env, cmd_utils
|
|
|
|
config_file = "config.yml"
|
|
root_key = "config"
|
|
deps_key = "dependencies"
|
|
|
|
|
|
class ConfigKeyError(RuntimeError):
|
|
def __init__(self, config_file, key):
|
|
self.config_file = config_file
|
|
self.key = key
|
|
|
|
def __str__(self):
|
|
return f"Not found in {self.config_file}: {self.key}"
|
|
|
|
|
|
def _get(dict, key, key_parent=None):
|
|
value = dict.get(key)
|
|
|
|
if not value:
|
|
key_path = f"{root_key}:{key_parent}:{key}" if key_parent else key
|
|
raise ConfigKeyError(f"Missing key in {config_file}: {key_path}")
|
|
|
|
return value
|
|
|
|
|
|
class Config:
|
|
"""Reads the project configuration YAML file."""
|
|
|
|
def __init__(self):
|
|
env.ensure_module("yaml", "pyyaml")
|
|
import yaml
|
|
|
|
with open(config_file, "r") as f:
|
|
data = yaml.safe_load(f)
|
|
|
|
self.os_name = env.get_os()
|
|
root = _get(data, root_key)
|
|
self.os = _get(root, self.os_name)
|
|
|
|
def get_os_value(self, key):
|
|
return _get(self.os, key, f"{self.os_name}:{key}")
|
|
|
|
def get_qt_config(self):
|
|
qt_key = "qt"
|
|
qt = self.get_os_deps_value(qt_key)
|
|
|
|
parent_key = f"{self.os_name}:{deps_key}"
|
|
mirror_url = _get(qt, "mirror", parent_key)
|
|
version = _get(qt, "version", parent_key)
|
|
base_dir = _get(qt, "install-dir", parent_key)
|
|
|
|
return mirror_url, version, base_dir
|
|
|
|
def get_os_deps_value(self, key):
|
|
deps = self.get_os_value(deps_key)
|
|
return _get(deps, key, f"{self.os_name}:{deps_key}")
|
|
|
|
def get_deps_command(self):
|
|
deps = self.get_os_value(deps_key)
|
|
command = _get(deps, "command", f"{self.os_name}:{deps_key}")
|
|
return cmd_utils.strip_continuation_sequences(command)
|
|
|
|
def get_linux_deps_command(self, distro):
|
|
distro_data = self.get_os_value(distro)
|
|
deps = _get(distro_data, deps_key, f"{self.os_name}:{distro}")
|
|
command = _get(deps, "command", f"{self.os_name}:{distro}:{deps_key}")
|
|
return cmd_utils.strip_continuation_sequences(command)
|
|
|
|
def get_choco_ci_config(self):
|
|
choco_ci_key = "choco-ci"
|
|
choco_ci = self.get_os_deps_value(choco_ci_key)
|
|
|
|
choco_ci_path = f"{self.os_name}:{deps_key}:{choco_ci_key}"
|
|
edit_config = _get(choco_ci, "edit-config", choco_ci_path)
|
|
skip_packages = _get(choco_ci, "skip-packages", choco_ci_path)
|
|
|
|
return edit_config, skip_packages
|