forked from sh-edraft.de/sh_discord_bot
Added get version stuff to build docker #70
This commit is contained in:
parent
47f294a982
commit
46ed616560
@ -13,6 +13,7 @@
|
|||||||
"moderator": "src/modules/moderator/moderator.json",
|
"moderator": "src/modules/moderator/moderator.json",
|
||||||
"permission": "src/modules/permission/permission.json",
|
"permission": "src/modules/permission/permission.json",
|
||||||
"bot-api": "src/bot_api/bot-api.json",
|
"bot-api": "src/bot_api/bot-api.json",
|
||||||
|
"get-version": "tools/get_version/get-version.json",
|
||||||
"post-build": "tools/post_build/post-build.json",
|
"post-build": "tools/post_build/post-build.json",
|
||||||
"set-version": "tools/set_version/set-version.json"
|
"set-version": "tools/set_version/set-version.json"
|
||||||
},
|
},
|
||||||
@ -21,6 +22,9 @@
|
|||||||
"sv": "cpl set-version",
|
"sv": "cpl set-version",
|
||||||
"set-version": "cpl run set-version $ARGS; echo '';",
|
"set-version": "cpl run set-version $ARGS; echo '';",
|
||||||
|
|
||||||
|
"gv": "cpl get-version",
|
||||||
|
"get-version": "export VERSION=$(cpl run get-version); echo $VERSION;",
|
||||||
|
|
||||||
"pre-build": "cpl set-version $ARGS",
|
"pre-build": "cpl set-version $ARGS",
|
||||||
"post-build": "cpl run post-build",
|
"post-build": "cpl run post-build",
|
||||||
|
|
||||||
@ -30,9 +34,10 @@
|
|||||||
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
||||||
"pre-dev": "cpl build",
|
"pre-dev": "cpl build",
|
||||||
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
||||||
"build-docker": "cpl b; docker-compose down; docker build -t kdb:kdb .",
|
|
||||||
"compose": "docker-compose up -d",
|
"docker-build": "cpl b; docker-compose down; docker build -t kdb-bot/kdb-bot:$(cpl gv) .",
|
||||||
"docker": "cpl build-docker; cpl compose;"
|
"docker-compose": "docker-compose up -d",
|
||||||
|
"docker": "cpl docker-build; cpl docker-compose;"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
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()
|
@ -1,9 +1,8 @@
|
|||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings
|
from cpl_cli.configuration import WorkspaceSettings
|
||||||
from cpl_core.application import StartupABC
|
from cpl_core.application import StartupABC
|
||||||
from cpl_core.configuration import ConfigurationABC
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.console import Console
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
from cpl_core.environment import ApplicationEnvironment
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"build-docker": "ng build; docker build -t kdb-web:kdb-web ."
|
"docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION ."
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -57,6 +57,15 @@ async function setVersion(version: SoftwareVersion) {
|
|||||||
fs.writeFile(jsonFilePath, JSON.stringify(settings, null, 4), "utf8", () => {
|
fs.writeFile(jsonFilePath, JSON.stringify(settings, null, 4), "utf8", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
fs.readFile('./package.json', "utf8", (err: Error, data: string) => {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
const settings = JSON.parse(data);
|
||||||
|
settings.version = version.getVersionString();
|
||||||
|
fs.writeFile('./package.json', JSON.stringify(settings, null, 4), "utf8", () => {
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Main();
|
Main();
|
||||||
|
Loading…
Reference in New Issue
Block a user