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",
|
||||
"permission": "src/modules/permission/permission.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",
|
||||
"set-version": "tools/set_version/set-version.json"
|
||||
},
|
||||
@ -21,6 +22,9 @@
|
||||
"sv": "cpl set-version",
|
||||
"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",
|
||||
"post-build": "cpl run post-build",
|
||||
|
||||
@ -30,9 +34,10 @@
|
||||
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
||||
"pre-dev": "cpl build",
|
||||
"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": "cpl build-docker; cpl compose;"
|
||||
|
||||
"docker-build": "cpl b; docker-compose down; docker build -t kdb-bot/kdb-bot:$(cpl gv) .",
|
||||
"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
|
||||
|
||||
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings
|
||||
from cpl_cli.configuration import WorkspaceSettings
|
||||
from cpl_core.application import StartupABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.console import Console
|
||||
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
@ -1,52 +1,52 @@
|
||||
{
|
||||
"name": "kdb-web",
|
||||
"version": "0.3.dev70",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts",
|
||||
"prestart": "npm run update-version",
|
||||
"start": "ng serve",
|
||||
"prebuild": "npm run update-version",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test",
|
||||
"build-docker": "ng build; docker build -t kdb-web:kdb-web ."
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^14.0.0",
|
||||
"@angular/common": "^14.0.0",
|
||||
"@angular/compiler": "^14.0.0",
|
||||
"@angular/core": "^14.0.0",
|
||||
"@angular/forms": "^14.0.0",
|
||||
"@angular/platform-browser": "^14.0.0",
|
||||
"@angular/platform-browser-dynamic": "^14.0.0",
|
||||
"@angular/router": "^14.0.0",
|
||||
"@auth0/angular-jwt": "^5.1.0",
|
||||
"@microsoft/signalr": "^6.0.9",
|
||||
"@ngx-translate/core": "^14.0.0",
|
||||
"@ngx-translate/http-loader": "^7.0.0",
|
||||
"@types/socket.io-client": "^3.0.0",
|
||||
"primeicons": "^6.0.1",
|
||||
"primeng": "^14.1.2",
|
||||
"rxjs": "~7.5.0",
|
||||
"socket.io-client": "^4.5.3",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^14.0.0",
|
||||
"@angular/cli": "~14.0.0",
|
||||
"@angular/compiler-cli": "^14.0.0",
|
||||
"@types/jasmine": "~4.0.0",
|
||||
"@types/node": "^18.8.3",
|
||||
"jasmine-core": "~4.1.0",
|
||||
"karma": "~6.3.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.0.0",
|
||||
"karma-jasmine-html-reporter": "~1.7.0",
|
||||
"ts-node": "~8.3.0",
|
||||
"typescript": "~4.7.2"
|
||||
}
|
||||
"name": "kdb-web",
|
||||
"version": "0.3.dev70",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts",
|
||||
"prestart": "npm run update-version",
|
||||
"start": "ng serve",
|
||||
"prebuild": "npm run update-version",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test",
|
||||
"docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION ."
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^14.0.0",
|
||||
"@angular/common": "^14.0.0",
|
||||
"@angular/compiler": "^14.0.0",
|
||||
"@angular/core": "^14.0.0",
|
||||
"@angular/forms": "^14.0.0",
|
||||
"@angular/platform-browser": "^14.0.0",
|
||||
"@angular/platform-browser-dynamic": "^14.0.0",
|
||||
"@angular/router": "^14.0.0",
|
||||
"@auth0/angular-jwt": "^5.1.0",
|
||||
"@microsoft/signalr": "^6.0.9",
|
||||
"@ngx-translate/core": "^14.0.0",
|
||||
"@ngx-translate/http-loader": "^7.0.0",
|
||||
"@types/socket.io-client": "^3.0.0",
|
||||
"primeicons": "^6.0.1",
|
||||
"primeng": "^14.1.2",
|
||||
"rxjs": "~7.5.0",
|
||||
"socket.io-client": "^4.5.3",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^14.0.0",
|
||||
"@angular/cli": "~14.0.0",
|
||||
"@angular/compiler-cli": "^14.0.0",
|
||||
"@types/jasmine": "~4.0.0",
|
||||
"@types/node": "^18.8.3",
|
||||
"jasmine-core": "~4.1.0",
|
||||
"karma": "~6.3.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.0.0",
|
||||
"karma-jasmine-html-reporter": "~1.7.0",
|
||||
"ts-node": "~8.3.0",
|
||||
"typescript": "~4.7.2"
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,15 @@ async function setVersion(version: SoftwareVersion) {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user