From 40d6e8824e6c39c28b66124479546b0bea1e0cd1 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Thu, 29 May 2025 11:28:55 +0200 Subject: [PATCH 1/2] move bumpversion to pyproject, update workflow, add database configuration to config class --- .bumpversion.toml | 24 ---------------------- .gitea/workflows/build.yaml | 22 +++++++++----------- pyproject.toml | 22 ++++++++++++++++++++ src/komconfig/config.py | 41 ++++++++++++++++++++++++++++++++++++- 4 files changed, 72 insertions(+), 37 deletions(-) delete mode 100644 .bumpversion.toml diff --git a/.bumpversion.toml b/.bumpversion.toml deleted file mode 100644 index 0c2f608..0000000 --- a/.bumpversion.toml +++ /dev/null @@ -1,24 +0,0 @@ -[tool.bumpversion] -current_version = "0.1.6" -parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" -serialize = ["{major}.{minor}.{patch}"] -search = "{current_version}" -replace = "{new_version}" -regex = false -ignore_missing_version = false -ignore_missing_files = false -tag = true -sign_tags = false -tag_name = "v{new_version}" -tag_message = "Bump version: {current_version} → {new_version}" -allow_dirty = false -commit = true -message = "Bump version: {current_version} → {new_version}" -moveable_tags = [] -commit_args = "" -setup_hooks = [] -pre_commit_hooks = [] -post_commit_hooks = [] - -[[tool.bumpversion.files]] -filename = "pyproject.toml" diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index a77bb37..2e1af5c 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,10 +1,6 @@ on: workflow_dispatch: inputs: - release_notes: - description: Release notes (use \n for newlines) - type: string - required: false github_release: description: 'Create Gitea Release' default: true @@ -48,13 +44,15 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} - - name: Create release notes - run: | - mkdir release_notes - echo -e "${{ inputs.release_notes }}" >> release_notes/release_notes.md - echo "Release notes:" - cat release_notes/release_notes.md - echo "" + - name: Build Changelog + id: build_changelog + uses: https://github.com/mikepenz/release-changelog-builder-action@v5 + with: + platform: "gitea" + baseURL: "http://gitea:3000" + configuration: ".gitea/changelog-config.json" + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} - name: Build package run: uv build - name: Publish package @@ -70,7 +68,7 @@ jobs: with: tag_name: ${{ env.VERSION }} release_name: Release ${{ env.VERSION }} - body_path: release_notes/release_notes.md + body: ${{steps.build_changelog.outputs.changelog}} draft: false prerelease: false make_latest: true diff --git a/pyproject.toml b/pyproject.toml index bfea104..1adf1bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,3 +13,25 @@ build-backend = "hatchling.build" [dependency-groups] test = ["pytest>=8.3.4"] + +[tool.bumpversion] +current_version = "0.1.6" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" +serialize = ["{major}.{minor}.{patch}"] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +ignore_missing_files = false +tag = true +sign_tags = false +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" +allow_dirty = false +commit = true +message = "Bump version: {current_version} → {new_version}" +moveable_tags = [] +commit_args = "" +setup_hooks = [] +pre_commit_hooks = [] +post_commit_hooks = [] \ No newline at end of file diff --git a/src/komconfig/config.py b/src/komconfig/config.py index 0c3adad..12b2f7f 100644 --- a/src/komconfig/config.py +++ b/src/komconfig/config.py @@ -1,13 +1,48 @@ from dataclasses import dataclass -from typing import List, Optional +from typing import List, Optional, Union import os from omegaconf import OmegaConf, DictConfig from pathlib import Path from komconfig import CONFIG_PATH +from urllib.parse import quote_plus SETTINGS_PATH = os.path.join(CONFIG_PATH, "config.yaml") +@dataclass +class RemoteSettings: + url: str + port: int + user: str + password: str + database_name: str = "komcache" +@dataclass +class Cache: + mode: str + remote: dict[str, Union[str, int]] |RemoteSettings + local_path: str | Path + + + + def __post__init__(self): + if self.mode == "remote": + self.remote = RemoteSettings(**self.remote) + else: + self.remote = None + self.local_path = Path(self.local_path).expanduser() + + @property + def path(self): + if self.mode == "local": + return Path(self.local_path).expanduser() + else: + return f"{self.remote.url}:{self.remote.port}" + + @property + def url(self): + password = quote_plus(self.remote.password) if self.remote else "" + return f"mysql+pymysql://{self.remote.user}:{password}@{self.remote.url}:{self.remote.port}/{self.remote.database_name}" + @dataclass class Komga: """Komga server settings.""" @@ -328,6 +363,10 @@ class Settings: @property def komtagger(self): return KomTagger(**self._config.komtagger) + + @property + def cache(self): + return Cache(**self._config.cache) def komtagger_attr(self, name): return getattr(self.komtagger, name) -- 2.49.1 From 1ed1403c430be9631b03ad16506805e5f047733c Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Thu, 29 May 2025 11:30:24 +0200 Subject: [PATCH 2/2] allow dirty bumps, manually adjust version to match remote version --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1adf1bc..bf8398b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "komconfig" -version = "0.1.6" +version = "0.2.0" description = "A small library providing a config class that provides settings data for the KomSuite" readme = "README.md" authors = [{ name = "WorldTeacher", email = "coding_contact@pm.me" }] @@ -15,7 +15,7 @@ build-backend = "hatchling.build" test = ["pytest>=8.3.4"] [tool.bumpversion] -current_version = "0.1.6" +current_version = "0.2.0" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" @@ -27,7 +27,7 @@ tag = true sign_tags = false tag_name = "v{new_version}" tag_message = "Bump version: {current_version} → {new_version}" -allow_dirty = false +allow_dirty = true commit = true message = "Bump version: {current_version} → {new_version}" moveable_tags = [] -- 2.49.1