diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 3846e31..0bc122d 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -35,8 +35,6 @@ jobs: run: | python -m pip install --upgrade pip pip install build - - name: Mark version - run: python3 tags_marker.py - name: Build package run: python -m build - name: Store the distribution packages diff --git a/pyproject.toml b/pyproject.toml index 1f9c2bf..753a5fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=61.0", "setuptools_scm"] build-backend = "setuptools.build_meta" [project] name = "clipman" -version = "!!{PLACEHOLDER}!!" # PLEASE RUN tags_marker.py BEFORE PACKAGING +dynamic = ["version"] # setuptools_scm authors = [ {name="NikitaBeloglazov", email="nnikita.beloglazov@gmail.com"}, ] @@ -28,3 +28,13 @@ classifiers = [ [project.urls] "Homepage" = "https://github.com/NikitaBeloglazov/clipman" "Bug Tracker" = "https://github.com/NikitaBeloglazov/clipman/issues" + +[tool.setuptools_scm] +# DO NOT add numbers to version. I decide which version I need to post +version_scheme = "release-branch-semver" + +# get only tag, 3.2.0, not an 3.2.0.dev17+g2868326.d20240223abcdefghijklmnopqrstuvwxyz +git_describe_command = "git describe --tags main" + +# overwrites an fallback template +version_file = "src/clipman/__version__.py" diff --git a/src/clipman/__version__.py b/src/clipman/__version__.py index 8994925..b64b331 100644 --- a/src/clipman/__version__.py +++ b/src/clipman/__version__.py @@ -1,7 +1,10 @@ """ Created for storing version number. -The version number will be placed here based on the tag in Github using the tags_marker.py script. +The version number will be placed here based on the tag in Github using the setuptools_scm. +This file must be overwritten -Having "!!{PLACEHOLDER}!!" in final releases is NOT allowed. +Having 0.0.0 in final releases is NOT allowed. +If you see this comment, setuptools_scm was not started """ -__version__="!!{PLACEHOLDER}!!" +__version__ = version = '0.0.0' +__version_tuple__ = version_tuple = (0, 0, 0) diff --git a/tags_marker.py b/tags_marker.py deleted file mode 100644 index dfcf268..0000000 --- a/tags_marker.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -""" - * Copyright (C) 2023 Nikita Beloglazov - * - * This file is part of github.com/NikitaBeloglazov/clipman. - * - * NikitaBeloglazov/clipman is free software; you can redistribute it and/or - * modify it under the terms of the Mozilla Public License 2.0 - * published by the Mozilla Foundation. - * - * NikitaBeloglazov/clipman is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY. - * - * You should have received a copy of the Mozilla Public License 2.0 - * along with NikitaBeloglazov/clipman - * If not, see https://mozilla.org/en-US/MPL/2.0. - -- = - = - * Module Decsription: - In short, all it does is find the latest release number using git, - and replace the special placeholders (!!{PLACEHOLDER}!!) - with the latest release version number that it finds. - - This module is mostly designed for automatic assembly. - - [!!] Works only if the folder has the git system initialized. - (In simple, `git clone` and `.git` folder is required) - - # TODO?: Change this file name -""" - -# - DEBUG - -#import os -#os.system("tree -a") -#os.system("git fetch --tags") -#print(subprocess.check_output("git tag -n9", shell=True, encoding="UTF-8")) - -import subprocess - -# - Get current tag -tag = subprocess.check_output("git describe --tags", shell=True, encoding="UTF-8") -print("[TAG MARKER] git response: " + tag) - -# - Clear tag from junk, you need to get numbers with dots only -tag = tag.replace("\n", "").replace("v", "") -if tag.find("-") > 1: - tag = tag[0:tag.find("-")] -print("[TAG MARKER] FOUND TAG: " + tag) - -# - Mark pyproject.toml -print("[TAG MARKER] MARKING VERSION IN pyproject.toml") -with open('pyproject.toml', 'r+', encoding="utf-8") as file: - # Reading the contents of a file - content = file.read() - # Replace the desired part of the text using the replace method - new_content = content.replace('!!{PLACEHOLDER}!!', tag) - # Move the file pointer to the beginning (0) to overwrite - file.seek(0) - # Write the changed content back to the file - file.write(new_content) - # Trim the file if the new content is shorter than the old one to remove the remaining data - file.truncate() -print("[TAG MARKER] DONE") - -# - Mark src/clipman/__version__.py -print("[TAG MARKER] MARKING VERSION IN src/clipman/__version__.py") -with open('src/clipman/__version__.py', 'r+', encoding="utf-8") as file: - # Reading the contents of a file - content = file.read() - # Replace the desired part of the text using the replace method - new_content = content.replace('!!{PLACEHOLDER}!!', tag) - # Move the file pointer to the beginning (0) to overwrite - file.seek(0) - # Write the changed content back to the file - file.write(new_content) - # Trim the file if the new content is shorter than the old one to remove the remaining data - file.truncate() -print("[TAG MARKER] DONE") - -print("[TAG MARKER] Marking complete")