use more predictable version numbers

This commit is contained in:
sebthom
2024-01-12 01:41:18 +01:00
parent 7b2dfd8559
commit a87e12bf1b
4 changed files with 21 additions and 7 deletions

View File

@@ -71,7 +71,7 @@ ENV PATH="/opt/upx:${PATH}"
COPY kleinanzeigen_bot /opt/app/kleinanzeigen_bot COPY kleinanzeigen_bot /opt/app/kleinanzeigen_bot
COPY .git /opt/app/.git COPY .git /opt/app/.git
COPY README.md pdm.lock pyinstaller.spec pyproject.toml /opt/app/ COPY README.md pdm.lock pyinstaller.spec pyproject.toml version.py /opt/app/
RUN <<EOF RUN <<EOF

View File

@@ -63,7 +63,7 @@ class KleinanzeigenBot(SeleniumMixin):
self.webdriver = None self.webdriver = None
def get_version(self) -> str: def get_version(self) -> str:
return importlib.metadata.version(__package__) return importlib.metadata.version(__package__).removesuffix(".editable")
def run(self, args:list[str]) -> None: def run(self, args:list[str]) -> None:
self.parse_args(args) self.parse_args(args)

View File

@@ -5,9 +5,9 @@
# SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/ # SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
# #
[build-system] [build-system] # https://backend.pdm-project.org/
requires = ["pdm-pep517"] requires = ["pdm-backend"]
build-backend = "pdm.pep517.api" build-backend = "pdm.backend"
[project] [project]
name = "kleinanzeigen-bot" name = "kleinanzeigen-bot"
@@ -52,8 +52,9 @@ Issues = "https://github.com/Second-Hand-Friends/kleinanzeigen-bot/issues"
##################### #####################
# pdm https://github.com/pdm-project/pdm/ # pdm https://github.com/pdm-project/pdm/
##################### #####################
[tool.pdm] [tool.pdm.version] # https://backend.pdm-project.org/metadata/#dynamic-project-version
version = {use_scm = true} source = "call"
getter = "version:get_version"
[tool.pdm.dev-dependencies] [tool.pdm.dev-dependencies]
dev = [ dev = [

13
version.py Normal file
View File

@@ -0,0 +1,13 @@
"""
SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
"""
from datetime import datetime
import subprocess
# used in pyproject.toml [tool.pdm.version]
def get_version() -> str:
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode().strip()
return f"{datetime.now().year}+{commit_hash}"