From 084167a342a4ae6da6e38b11f861c2176afc3367 Mon Sep 17 00:00:00 2001 From: Rubel Date: Tue, 24 Sep 2024 13:47:37 +0200 Subject: [PATCH] init commit for citation. --- .github/workflows/check_citation.yaml | 55 +++++++++++++++++++++++++++ .github/workflows/publish.yml | 20 ++++++++++ pyproject.toml | 1 + src/pynxtools/__init__.py | 1 + 4 files changed, 77 insertions(+) create mode 100644 .github/workflows/check_citation.yaml diff --git a/.github/workflows/check_citation.yaml b/.github/workflows/check_citation.yaml new file mode 100644 index 000000000..0bb813e74 --- /dev/null +++ b/.github/workflows/check_citation.yaml @@ -0,0 +1,55 @@ +name: Version Check + +on: + push: + branches: + - 'main' + pull_request: + branches: + - 'main' + +jobs: + check-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + + # Check if the CITATION.cff file is valid + - name: Validate CITATION.cff + run: | + cffconvert --validate + - name: Package version + id: package_version + run: | + PACKAGE_VERSION=$(python -c "import pynxtools; print(pynxtools.__version__)") + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + echo "Version from __init__.py: $PACKAGE_VERSION" + + - name: Citation version + id: citation_version + run: | + # Parse the version from the CITATION.cff file) + CITATION_VERSION=$(grep '^version:' CITATION.cff | cut -d' ' -f2) + echo "CITATION_VERSION=$CITATION_VERSION" >> $GITHUB_ENV + echo "Version from CITATION.cff: $CITATION_VERSION" + + - name: Compare versions + run: | + if [ "$PACKAGE_VERSION" != "$CITATION_VERSION" ]; then + echo "Version mismatch: package version is $PACKAGE_VERSION, CITATION.cff version is $CITATION_VERSION" + exit 1 + fi + echo "All versions match: $GIT_TAG_VERSION" + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f38b3901d..b6980b279 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,6 +29,26 @@ jobs: run: | curl -LsSf https://astral.sh/uv/install.sh | sh uv pip install build + - name: Git tag version + id: git_tag_version + run: | + # Extract the version from the tag (e.g., 'v1.0.0' becomes '1.0.0') + GIT_TAG_VERSION=${GITHUB_REF#refs/tags/v} + echo "GIT_TAG_VERSION=$GIT_TAG_VERSION" >> $GITHUB_ENV + echo "Version from Git tag: $GIT_TAG_VERSION" + - name: Citation version + id: citation_version + run: | + # Parse the version from the CITATION.cff file + CITATION_VERSION=$(grep '^version:' CITATION.cff | cut -d' ' -f2) + echo "CITATION_VERSION=$CITATION_VERSION" >> $GITHUB_ENV + echo "Version from CITATION.cff: $CITATION_VERSION" + - name: Compare versions + run: | + if [ "$GIT_TAG_VERSION" != "$CITATION_VERSION" ]; then + echo "Version mismatch: Git tag version is $GIT_TAG_VERSION, CITATION.cff version is $CITATION_VERSION" + exit 1 + fi - name: Build package run: | git reset --hard HEAD diff --git a/pyproject.toml b/pyproject.toml index b2b22876d..c9461a5fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ dependencies = [ "importlib-metadata", "lxml>=4.9.1", "anytree", + "cffconvert", ] [project.urls] diff --git a/src/pynxtools/__init__.py b/src/pynxtools/__init__.py index f7db586be..491e0dcd1 100644 --- a/src/pynxtools/__init__.py +++ b/src/pynxtools/__init__.py @@ -25,6 +25,7 @@ from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version LOGGER_LEVELS_TO_HIGHLIGHT = (logging.WARNING, logging.ERROR) +__version__ = "0.7.2" class CustomFormatter(logging.Formatter):