diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0e0166c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + push: + branches: [main] + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository == 'JustinZeus/scholarr' + permissions: + contents: write + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: pip install python-semantic-release + - name: Semantic Release + id: release + run: semantic-release publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/app/services/crossref/application.py b/app/services/crossref/application.py index 9b7076c..a9e46d5 100644 --- a/app/services/crossref/application.py +++ b/app/services/crossref/application.py @@ -5,16 +5,19 @@ import logging import re import threading import time +from importlib.metadata import version as pkg_version from typing import TYPE_CHECKING from crossref.restful import Etiquette, Works from app.logging_utils import structured_log -from app.services.domains.doi.normalize import normalize_doi +from app.services.doi.normalize import normalize_doi from app.settings import settings +_APP_VERSION = pkg_version("scholarr") + if TYPE_CHECKING: - from app.services.domains.publications.types import PublicationListItem, UnreadPublicationItem + from app.services.publications.types import PublicationListItem, UnreadPublicationItem TOKEN_RE = re.compile(r"[a-z0-9]+") NON_ALNUM_RE = re.compile(r"[^a-z0-9\\s]+") @@ -292,7 +295,7 @@ def _best_candidate_doi( def _works_client(email: str | None) -> Works: if email: - etiquette = Etiquette(settings.app_name, "0.1.0", "https://scholarr.local", email) + etiquette = Etiquette(settings.app_name, _APP_VERSION, "https://scholarr.local", email) return Works(etiquette=etiquette) return Works() diff --git a/pyproject.toml b/pyproject.toml index 79c61b1..2a0c15f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ dev = [ "pytest>=8.3,<9.0", "pytest-asyncio>=0.25,<0.26", + "python-semantic-release>=9.0,<10.0", "ruff>=0.9", "mypy>=1.14", ] @@ -61,6 +62,13 @@ ignore_missing_imports = true check_untyped_defs = false warn_unused_ignores = true +[tool.semantic_release] +version_toml = ["pyproject.toml:project.version"] +version_variables = ["frontend/package.json:version"] +branch = "main" +build_command = "" +commit_message = "chore(release): v{version}" + [tool.setuptools] include-package-data = true