From 6ed3c87adb24176ae9f1b8718b9d59caecbf77f5 Mon Sep 17 00:00:00 2001 From: Jeff Goeders Date: Mon, 12 Feb 2024 11:24:07 -0700 Subject: [PATCH] versioning --- .github/Makefile | 14 ++++++++++++++ .github/compare_versions.py | 13 +++++++++++++ .github/print_version.py | 4 ++++ .github/workflows/versioning.yml | 19 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 .github/Makefile create mode 100644 .github/compare_versions.py create mode 100644 .github/print_version.py create mode 100644 .github/workflows/versioning.yml diff --git a/.github/Makefile b/.github/Makefile new file mode 100644 index 0000000..fb164d8 --- /dev/null +++ b/.github/Makefile @@ -0,0 +1,14 @@ +IN_ENV := . .venv/bin/activate; + +env: + python3 -m venv .venv + +check_version_increase: + $(IN_ENV) pip uninstall -y yinstruments + $(IN_ENV) pip install yinstruments + $(IN_ENV) echo `python print_version.py` > pypi_version.txt + $(IN_ENV) pip uninstall -y yinstruments + $(IN_ENV) pip install .. + $(IN_ENV) echo `python print_version.py` > current_version.txt + $(IN_ENV) pip uninstall -y yinstruments + $(IN_ENV) python compare_versions.py pypi_version.txt current_version.txt \ No newline at end of file diff --git a/.github/compare_versions.py b/.github/compare_versions.py new file mode 100644 index 0000000..6a300d8 --- /dev/null +++ b/.github/compare_versions.py @@ -0,0 +1,13 @@ +import sys +from packaging import version + +pypi_version_path = sys.argv[1] +this_version_path = sys.argv[2] + +pypi_version = version.parse(open(pypi_version_path).read()) +this_version = version.parse(open(this_version_path).read()) + +if this_version <= pypi_version: + raise Exception( + f"This version ({this_version}) is not greater than the pypi version ({pypi_version})" + ) diff --git a/.github/print_version.py b/.github/print_version.py new file mode 100644 index 0000000..a32feb9 --- /dev/null +++ b/.github/print_version.py @@ -0,0 +1,4 @@ +import pkg_resources # part of setuptools + +version = pkg_resources.require("yaccounts")[0].version +print(version) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml new file mode 100644 index 0000000..dd6e4d7 --- /dev/null +++ b/.github/workflows/versioning.yml @@ -0,0 +1,19 @@ +name: Versioning Check + +on: + pull_request: + + +jobs: + version_check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Environment + run: cd .github && make env + + - name: Check version increase + run: cd .github && make check_version_increase + \ No newline at end of file