A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
First changes for using semver everywhere
Trenton Holmesdce4166bc8a6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex fe52da55d..8fe71ac9a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -260,8 +260,14 @@ jobs:ghcr.io/${{ github.repository }}name=paperlessngx/paperless-ngx,enable=${{ steps.docker-hub.outputs.enable }}tags: |+ # Tag branches with branch nametype=ref,event=branch+ # Tag tags with tag nametype=ref,event=tag+ # Process semver tags+ # For a tag x.y.z or vX.Y.Z, output an x.y.z and x.y image tag+ type=semver,pattern={{version}}+ type=semver,pattern={{major}}.{{minor}}-name: Checkoutuses: actions/checkout@v3diff --git a/docs/administration.rst b/docs/administration.rstindex 85f573460..1139c3a69 100644--- a/docs/administration.rst+++ b/docs/administration.rst@@ -117,6 +117,23 @@ Then you can start paperless-ngx with ``-d`` to have it run in the background.image: ghcr.io/paperless-ngx/paperless-ngx:latest+ .. note::+ In version 1.7.1 and onwards, the Docker image can now pinned to a release series.+ This is often combined with automatic updaters such as Watchtower to allow safer+ unattended upgrading to new bugfix releases only. It is still recommended to always+ review release notes before upgrading. To ping your install to a release series, edit+ the ``docker-compose.yml`` find the line that says++ .. code::++ image: ghcr.io/paperless-ngx/paperless-ngx:latest++ and replace the version with the series you want to track, for example:++ .. code::++ image: ghcr.io/paperless-ngx/paperless-ngx:1.7+Bare Metal Route================diff --git a/docs/conf.py b/docs/conf.pyindex 19efbbdf8..0f30772ea 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -2,6 +2,8 @@ import sphinx_rtd_theme__version__ = None+__full_version_str__ = None+__major_minor_version_str__ = Noneexec(open("../src/paperless/version.py").read())@@ -41,9 +43,9 @@ copyright = "2015-2022, Daniel Quinn, Jonas Winkler, and the paperless-ngx team"## The short X.Y version.-version = ".".join([str(_) for _ in __version__[:2]])+version = __major_minor_version_str__# The full version, including alpha/beta/rc tags.-release = ".".join([str(_) for _ in __version__[:3]])+release = __full_version_str__# The language for content autogenerated by Sphinx. Refer to documentation# for a list of supported languages.diff --git a/src/documents/views.py b/src/documents/views.pyindex 831e68b68..d29802394 100644--- a/src/documents/views.py+++ b/src/documents/views.py@@ -676,28 +676,33 @@ class RemoteVersionView(GenericAPIView):def get(self, request, format=None):remote_version = "0.0.0"is_greater_than_current = False+ current_version = packaging_version.parse(version.__full_version_str__)# TODO: this can likely be removed when frontend settings are saved to DBfeature_is_set = settings.ENABLE_UPDATE_CHECK != "default"if feature_is_set and settings.ENABLE_UPDATE_CHECK:try:- with urllib.request.urlopen(- "https://api.github.com/repos/"- + "paperless-ngx/paperless-ngx/releases/latest",- ) as response:+ req = urllib.request.Request(+ "https://api.github.com/repos/paperless-ngx/"+ "paperless-ngx/releases/latest",+ )+ # Ensure a JSON response+ req.add_header("Accept", "application/json")++ with urllib.request.urlopen(req) as response:remote = response.read().decode("utf-8")try:remote_json = json.loads(remote)- remote_version = remote_json["tag_name"].replace("ngx-", "")+ remote_version = remote_json["tag_name"].removeprefix("ngx-")except ValueError:- logger.debug("An error occured parsing remote version json")+ logger.debug("An error occurred parsing remote version json")except urllib.error.URLError:- logger.debug("An error occured checking for available updates")+ logger.debug("An error occurred checking for available updates")- current_version = ".".join([str(_) for _ in version.__version__[:3]])- is_greater_than_current = packaging_version.parse(- remote_version,- ) > packaging_version.parse(- current_version,+ is_greater_than_current = (+ packaging_version.parse(+ remote_version,+ )+ > current_version)return Response(diff --git a/src/paperless/middleware.py b/src/paperless/middleware.pyindex f82ba2435..ddf12812b 100644--- a/src/paperless/middleware.py+++ b/src/paperless/middleware.py@@ -11,6 +11,6 @@ class ApiVersionMiddleware:if request.user.is_authenticated:versions = settings.REST_FRAMEWORK["ALLOWED_VERSIONS"]response["X-Api-Version"] = versions[len(versions) - 1]- response["X-Version"] = ".".join([str(_) for _ in version.__version__])+ response["X-Version"] = version.__full_version_str__return responsediff --git a/src/paperless/version.py b/src/paperless/version.pyindex 8c908319f..44d20435a 100644--- a/src/paperless/version.py+++ b/src/paperless/version.py@@ -1 +1,8 @@-__version__ = (1, 7, 0)+from typing import Final+from typing import Tuple++__version__: Final[Tuple[int, int, int]] = (1, 7, 0)+# Version string like X.Y.Z+__full_version_str__: Final[str] = ".".join(map(str, __version__))+# Version string like X.Y+__major_minor_version_str__: Final[str] = ".".join(map(str, __version__[:-1]))