From 266ad28ca60768fe7a1ed2b1f2d683f21330dff7 Mon Sep 17 00:00:00 2001 From: anashr18 Date: Thu, 18 Jul 2024 16:16:20 +0530 Subject: [PATCH 1/2] added python script to bump up the version --- .github/workflows/publish.yaml | 5 +++++ .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- update_pyproject_version.py | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 update_pyproject_version.py diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 347aa2f..2e9746d 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -17,6 +17,11 @@ jobs: # use it with caution when git is large with: fetch-depth: 0 + - name: Install dependencies + run: | + pip install toml + - name: Update pyproject.toml version + run: python update_pyproject_version.py - name: Tag the release version run: | git tag $(cat version.txt) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f22b76..cbd1738 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -83,7 +83,7 @@ repos: hooks: - id: mypy args: [--no-strict-optional, --ignore-missing-imports] - exclude: '^ruff_mypy/' + exclude: '^update_pyproject_version' - repo: https://github.com/pycqa/flake8 rev: "7.0.0" # pick a git hash / tag to point to diff --git a/pyproject.toml b/pyproject.toml index 2efd3c9..0d8691e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ line_length = 99 [tool.pylint."messages control"] -disable = ["line-too-long", "trailing-whitespace", "missing-function-docstring", "consider-using-f-string", "import-error", "too-few-public-methods", "redefined-outer-name", 'missing-module-docstring', 'pointless-statement', 'invalid-name', 'undefined-variable'] +disable = ["line-too-long", "trailing-whitespace", "missing-function-docstring", "consider-using-f-string", "import-error", "too-few-public-methods", "redefined-outer-name", 'missing-module-docstring', 'pointless-statement', 'invalid-name', 'undefined-variable', 'unspecified-encoding'] [tool.ruff] diff --git a/update_pyproject_version.py b/update_pyproject_version.py new file mode 100644 index 0000000..5dceaeb --- /dev/null +++ b/update_pyproject_version.py @@ -0,0 +1,23 @@ +import toml + + +def update_version(): + # Read version from version.txt + with open("version.txt", "r") as file: + version = file.read().strip() + + # Load the pyproject.toml file + with open("pyproject.toml", "r") as file: + data = toml.load(file) + + # Assuming you are managing the version under a tool section, + # for example, [tool.my_package] or similar + data["tool"]["my_package"]["version"] = version # Adjust the path as necessary + + # Save the updated pyproject.toml + with open("pyproject.toml", "w") as file: + toml.dump(data, file) + + +if __name__ == "__main__": + update_version() From f8c3eb3c0a3e8637b4ee80a71c453ca291f89dc5 Mon Sep 17 00:00:00 2001 From: anashr18 Date: Thu, 18 Jul 2024 16:27:12 +0530 Subject: [PATCH 2/2] fixed the version --to do version bump --- .github/workflows/publish.yaml | 4 ++-- pyproject.toml | 4 ++-- update_pyproject_version.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2e9746d..21469fe 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -20,8 +20,8 @@ jobs: - name: Install dependencies run: | pip install toml - - name: Update pyproject.toml version - run: python update_pyproject_version.py + # - name: Update pyproject.toml version + # run: python update_pyproject_version.py - name: Tag the release version run: | git tag $(cat version.txt) diff --git a/pyproject.toml b/pyproject.toml index 0d8691e..e579353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta" [project] name = "packaging-demo-anashr" -# version = "0.0.5" +version = "0.0.6" authors = [{ name = "Yug", email = "yugg@test.edu" }] description = "Demo for packaging" readme = "README.md" keywords = ["one", "two"] license = { text = "Apache" } dependencies = ["numpy"] -dynamic = ['version'] +# dynamic = ['version'] [project.optional-dependencies] test = ['pytest', 'pytest-cov'] diff --git a/update_pyproject_version.py b/update_pyproject_version.py index 5dceaeb..c2ef5c1 100644 --- a/update_pyproject_version.py +++ b/update_pyproject_version.py @@ -12,7 +12,7 @@ def update_version(): # Assuming you are managing the version under a tool section, # for example, [tool.my_package] or similar - data["tool"]["my_package"]["version"] = version # Adjust the path as necessary + data["project"]["version"] = version # Adjust the path as necessary # Save the updated pyproject.toml with open("pyproject.toml", "w") as file: