forked from sh-edraft.de/sh_discord_bot
Added get version stuff to build docker #70
This commit is contained in:
26
kdb-bot/tools/get_version/__init__.py
Normal file
26
kdb-bot/tools/get_version/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
get-version CPL internal tool to set version from branch name
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
CPL internal tool to set version from branch name
|
||||
|
||||
:copyright: (c) 2022 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'get_version'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||
__version__ = '1.0.0'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='1', minor='0', micro='0')
|
19
kdb-bot/tools/get_version/application.py
Normal file
19
kdb-bot/tools/get_version/application.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from cpl_cli.configuration import ProjectSettings
|
||||
from cpl_core.application.application_abc import ApplicationABC
|
||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl_core.console import Console
|
||||
from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
self._ps: ProjectSettings = config.get_configuration(ProjectSettings)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
Console.write_line(self._ps.version.to_str())
|
44
kdb-bot/tools/get_version/get-version.json
Normal file
44
kdb-bot/tools/get_version/get-version.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "get-version",
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
"Description": "CPL internal tool to set version from branch name",
|
||||
"LongDescription": "CPL internal tool to set version from branch name",
|
||||
"URL": "https://www.sh-edraft.de",
|
||||
"CopyrightDate": "2022",
|
||||
"CopyrightName": "sh-edraft.de",
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core==2022.10.0.post7"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2022.10.0"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "set_version.main",
|
||||
"EntryPoint": "set-version",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
14
kdb-bot/tools/get_version/main.py
Normal file
14
kdb-bot/tools/get_version/main.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl_core.application import ApplicationBuilder
|
||||
|
||||
from get_version.application import Application
|
||||
from get_version.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
24
kdb-bot/tools/get_version/startup.py
Normal file
24
kdb-bot/tools/get_version/startup.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
from cpl_cli.configuration import WorkspaceSettings
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, '../../')))
|
||||
configuration.add_json_file(f'cpl-workspace.json', optional=False, output=False)
|
||||
ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings)
|
||||
configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False)
|
||||
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
return services.build_service_provider()
|
Reference in New Issue
Block a user