mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #851 from paperless-ngx/feature-semver-tags
Feature: Use semver for release process
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/release-drafter.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/release-drafter.yml
									
									
									
									
										vendored
									
									
								
							| @@ -30,7 +30,6 @@ replacers: # Changes "Feature: Update checker" to "Update checker" | |||||||
|     replace: '' |     replace: '' | ||||||
| change-template: '- $TITLE @$AUTHOR (#$NUMBER)' | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' | ||||||
| change-title-escapes: '\<*_&#@' | change-title-escapes: '\<*_&#@' | ||||||
| tag-prefix: "ngx-" |  | ||||||
| template: | | template: | | ||||||
|   # Changelog |   # Changelog | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,8 +3,10 @@ name: ci | |||||||
| on: | on: | ||||||
|   push: |   push: | ||||||
|     tags: |     tags: | ||||||
|       - ngx-* |       # https://semver.org/#spec-item-2 | ||||||
|       - beta-* |       - 'v[0-9]+.[0-9]+.[0-9]+' | ||||||
|  |       # https://semver.org/#spec-item-9 | ||||||
|  |       - 'v[0-9]+.[0-9]+.[0-9]+-beta.rc[0-9]+' | ||||||
|     branches-ignore: |     branches-ignore: | ||||||
|       - 'translations**' |       - 'translations**' | ||||||
|   pull_request: |   pull_request: | ||||||
| @@ -53,7 +55,7 @@ jobs: | |||||||
|  |  | ||||||
|   prepare-docker-build: |   prepare-docker-build: | ||||||
|     name: Prepare Docker Pipeline Data |     name: Prepare Docker Pipeline Data | ||||||
|     if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature-') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' || startsWith(github.ref, 'refs/tags/ngx-') || startsWith(github.ref, 'refs/tags/beta-')) |     if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature-') || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' || contains(github.ref, 'beta.rc') || startsWith(github.ref, 'refs/tags/v')) | ||||||
|     runs-on: ubuntu-20.04 |     runs-on: ubuntu-20.04 | ||||||
|     needs: |     needs: | ||||||
|       - documentation |       - documentation | ||||||
| @@ -197,8 +199,12 @@ jobs: | |||||||
|             ghcr.io/${{ github.repository }} |             ghcr.io/${{ github.repository }} | ||||||
|             name=paperlessngx/paperless-ngx,enable=${{ steps.docker-hub.outputs.enable }} |             name=paperlessngx/paperless-ngx,enable=${{ steps.docker-hub.outputs.enable }} | ||||||
|           tags: | |           tags: | | ||||||
|  |             # Tag branches with branch name | ||||||
|             type=ref,event=branch |             type=ref,event=branch | ||||||
|             type=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: Checkout |         name: Checkout | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
| @@ -334,7 +340,7 @@ jobs: | |||||||
|     runs-on: ubuntu-20.04 |     runs-on: ubuntu-20.04 | ||||||
|     needs: |     needs: | ||||||
|       - build-release |       - build-release | ||||||
|     if: github.ref_type == 'tag' && (startsWith(github.ref_name, 'ngx-') || startsWith(github.ref_name, 'beta-')) |     if: github.ref_type == 'tag' && (startsWith(github.ref_name, 'v') || contains(github.ref_name, '-beta.rc')) | ||||||
|     steps: |     steps: | ||||||
|       - |       - | ||||||
|         name: Download release artifact |         name: Download release artifact | ||||||
| @@ -346,12 +352,11 @@ jobs: | |||||||
|         name: Get version |         name: Get version | ||||||
|         id: get_version |         id: get_version | ||||||
|         run: | |         run: | | ||||||
|           if [[ $GITHUB_REF == refs/tags/ngx-* ]]; then |           echo ::set-output name=version::${{ github.ref_name }} | ||||||
|             echo ::set-output name=version::${GITHUB_REF#refs/tags/ngx-} |           if [[ ${{ contains(github.ref_name, '-beta.rc') }} == 'true' ]]; then | ||||||
|             echo ::set-output name=prerelease::false |  | ||||||
|           elif [[ $GITHUB_REF == refs/tags/beta-* ]]; then |  | ||||||
|             echo ::set-output name=version::${GITHUB_REF#refs/tags/beta-} |  | ||||||
|             echo ::set-output name=prerelease::true |             echo ::set-output name=prerelease::true | ||||||
|  |           else | ||||||
|  |             echo ::set-output name=prerelease::false | ||||||
|           fi |           fi | ||||||
|       - |       - | ||||||
|         name: Create Release and Changelog |         name: Create Release and Changelog | ||||||
| @@ -359,7 +364,7 @@ jobs: | |||||||
|         uses: release-drafter/release-drafter@v5 |         uses: release-drafter/release-drafter@v5 | ||||||
|         with: |         with: | ||||||
|           name: Paperless-ngx ${{ steps.get_version.outputs.version }} |           name: Paperless-ngx ${{ steps.get_version.outputs.version }} | ||||||
|           tag: ngx-${{ steps.get_version.outputs.version }} |           tag: ${{ steps.get_version.outputs.version }} | ||||||
|           version: ${{ steps.get_version.outputs.version }} |           version: ${{ steps.get_version.outputs.version }} | ||||||
|           prerelease: ${{ steps.get_version.outputs.prerelease }} |           prerelease: ${{ steps.get_version.outputs.prerelease }} | ||||||
|           publish: true # ensures release is not marked as draft |           publish: true # ensures release is not marked as draft | ||||||
|   | |||||||
| @@ -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 |                 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 | Bare Metal Route | ||||||
| ================ | ================ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ import sphinx_rtd_theme | |||||||
|  |  | ||||||
|  |  | ||||||
| __version__ = None | __version__ = None | ||||||
|  | __full_version_str__ = None | ||||||
|  | __major_minor_version_str__ = None | ||||||
| exec(open("../src/paperless/version.py").read()) | exec(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. | # 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. | # 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 | # The language for content autogenerated by Sphinx. Refer to documentation | ||||||
| # for a list of supported languages. | # for a list of supported languages. | ||||||
|   | |||||||
| @@ -676,28 +676,33 @@ class RemoteVersionView(GenericAPIView): | |||||||
|     def get(self, request, format=None): |     def get(self, request, format=None): | ||||||
|         remote_version = "0.0.0" |         remote_version = "0.0.0" | ||||||
|         is_greater_than_current = False |         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 DB |         # TODO: this can likely be removed when frontend settings are saved to DB | ||||||
|         feature_is_set = settings.ENABLE_UPDATE_CHECK != "default" |         feature_is_set = settings.ENABLE_UPDATE_CHECK != "default" | ||||||
|         if feature_is_set and settings.ENABLE_UPDATE_CHECK: |         if feature_is_set and settings.ENABLE_UPDATE_CHECK: | ||||||
|             try: |             try: | ||||||
|                 with urllib.request.urlopen( |                 req = urllib.request.Request( | ||||||
|                     "https://api.github.com/repos/" |                     "https://api.github.com/repos/paperless-ngx/" | ||||||
|                     + "paperless-ngx/paperless-ngx/releases/latest", |                     "paperless-ngx/releases/latest", | ||||||
|                 ) as response: |                 ) | ||||||
|  |                 # Ensure a JSON response | ||||||
|  |                 req.add_header("Accept", "application/json") | ||||||
|  |  | ||||||
|  |                 with urllib.request.urlopen(req) as response: | ||||||
|                     remote = response.read().decode("utf-8") |                     remote = response.read().decode("utf-8") | ||||||
|                 try: |                 try: | ||||||
|                     remote_json = json.loads(remote) |                     remote_json = json.loads(remote) | ||||||
|                     remote_version = remote_json["tag_name"].replace("ngx-", "") |                     remote_version = remote_json["tag_name"].removeprefix("ngx-") | ||||||
|                 except ValueError: |                 except ValueError: | ||||||
|                     logger.debug("An error occured parsing remote version json") |                     logger.debug("An error occurred parsing remote version json") | ||||||
|             except urllib.error.URLError: |             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 = ( | ||||||
|             is_greater_than_current = packaging_version.parse( |                 packaging_version.parse( | ||||||
|                     remote_version, |                     remote_version, | ||||||
|             ) > packaging_version.parse( |                 ) | ||||||
|                 current_version, |                 > current_version | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|         return Response( |         return Response( | ||||||
|   | |||||||
| @@ -11,6 +11,6 @@ class ApiVersionMiddleware: | |||||||
|         if request.user.is_authenticated: |         if request.user.is_authenticated: | ||||||
|             versions = settings.REST_FRAMEWORK["ALLOWED_VERSIONS"] |             versions = settings.REST_FRAMEWORK["ALLOWED_VERSIONS"] | ||||||
|             response["X-Api-Version"] = versions[len(versions) - 1] |             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 response |         return response | ||||||
|   | |||||||
| @@ -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])) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Quinn Casey
					Quinn Casey