From 0bed14643597717b5205e0e0eb3872463e8ed693 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 17 Mar 2026 10:53:19 -0300 Subject: [PATCH 01/17] updated logic to update versions with scripts for nightly --- .github/workflows/nightly-build.yml | 72 +++++++++++++++++-------- scripts/ci/pypi_nightly_tag.py | 57 ++++++++++++++++++++ scripts/ci/update_pyproject_combined.py | 27 ++++++++++ scripts/ci/update_pyproject_name.py | 20 +++++++ scripts/ci/update_pyproject_version.py | 23 ++++++++ 5 files changed, 178 insertions(+), 21 deletions(-) create mode 100644 scripts/ci/pypi_nightly_tag.py create mode 100644 scripts/ci/update_pyproject_combined.py create mode 100644 scripts/ci/update_pyproject_name.py create mode 100644 scripts/ci/update_pyproject_version.py diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index de659e864..63fdac690 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -7,23 +7,54 @@ on: workflow_dispatch: jobs: - check-version: + create-nightly-tag: if: github.repository == 'langflow-ai/openrag' runs-on: ubuntu-latest + permissions: + contents: write outputs: - nightly_version: ${{ steps.vars.outputs.nightly_version }} + nightly_version: ${{ steps.generate_tag.outputs.nightly_tag }} steps: - - name: Determine Nightly Version - id: vars + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Install dependencies for tagging script + run: uv pip install requests packaging + + - name: Generate nightly tag + id: generate_tag + run: | + TAG=$(python3 scripts/ci/pypi_nightly_tag.py) + echo "nightly_tag=$TAG" >> $GITHUB_OUTPUT + echo "nightly_tag=$TAG" + + - name: Update pyproject.toml + run: | + python3 scripts/ci/update_pyproject_combined.py main ${{ steps.generate_tag.outputs.nightly_tag }} + + - name: Commit and push tag run: | - DATE_PART=$(date -u +%y%m%d) - # Use the GitHub run number to create a unique, auto-incrementing suffix - NIGHTLY_VERSION="nightly-${DATE_PART}.${{ github.run_number }}.${{ github.run_attempt }}" - echo "nightly_version=$NIGHTLY_VERSION" >> "$GITHUB_OUTPUT" - echo "Nightly version: $NIGHTLY_VERSION" + git config --global user.email "bot-nightly-builds@openrag.org" + git config --global user.name "OpenRAG Bot" + + git add pyproject.toml + git commit -m "Update version and project name for nightly ${{ steps.generate_tag.outputs.nightly_tag }}" + + git tag ${{ steps.generate_tag.outputs.nightly_tag }} + git push origin ${{ steps.generate_tag.outputs.nightly_tag }} build: - needs: check-version + needs: create-nightly-tag strategy: fail-fast: false matrix: @@ -107,7 +138,7 @@ jobs: path: service-${{ matrix.service }}-${{ matrix.arch }}.txt manifest: - needs: [build, check-version] + needs: [build, create-nightly-tag] runs-on: ubuntu-latest steps: - name: Download built service artifacts @@ -144,7 +175,7 @@ jobs: $NS/$SVC:$VERSION-arm64 done publish-pypi: - needs: [check-version] + needs: [create-nightly-tag] runs-on: ubuntu-latest if: github.repository == 'langflow-ai/openrag' steps: @@ -161,15 +192,14 @@ jobs: - name: Update version for nightly run: | - python3 -c " - import re - with open('pyproject.toml', 'r') as f: - content = f.read() - # Append .dev + run_number + run_attempt to the version (PEP 440 compliant and unique per attempt) - new_content = re.sub(r'^version = \"([^\"]+)\"', r'version = \"\1.dev${{ github.run_number }}${{ github.run_attempt }}\"', content, flags=re.M) - with open('pyproject.toml', 'w') as f: - f.write(new_content) - " + # The version has already been updated in create-nightly-tag job + # but we need to ensure we are on the correct tag/commit if needed. + # However, publish-pypi runs on the same branch by default. + # In the create-nightly-tag job we pushed a tag, here we should probably checkout that tag + # or just use the updated pyproject.toml if it's shared (it's not). + # So we need to checkout the tag. + git fetch origin ${{ needs.create-nightly-tag.outputs.nightly_version }} + git checkout ${{ needs.create-nightly-tag.outputs.nightly_version }} - name: Build wheel and source distribution run: | diff --git a/scripts/ci/pypi_nightly_tag.py b/scripts/ci/pypi_nightly_tag.py new file mode 100644 index 000000000..954672e73 --- /dev/null +++ b/scripts/ci/pypi_nightly_tag.py @@ -0,0 +1,57 @@ +import sys +import requests +from packaging.version import Version +from pathlib import Path +import tomllib + +PYPI_OPENRAG_NIGHTLY_URL = "https://pypi.org/pypi/openrag-nightly/json" +PYPI_OPENRAG_URL = "https://pypi.org/pypi/openrag/json" + +def get_latest_published_version(is_nightly: bool) -> Version: + url = PYPI_OPENRAG_NIGHTLY_URL if is_nightly else PYPI_OPENRAG_URL + res = requests.get(url, timeout=10) + if res.status_code == 404: + return None + res.raise_for_status() + try: + version_str = res.json()["info"]["version"] + except Exception as e: + msg = "Got unexpected response from PyPI" + raise RuntimeError(msg) from e + return Version(version_str) + +def create_tag(): + # Read version from pyproject.toml + pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml" + with open(pyproject_path, "rb") as f: + pyproject_data = tomllib.load(f) + + current_version_str = pyproject_data["project"]["version"] + current_version = Version(current_version_str) + + try: + current_nightly_version = get_latest_published_version(is_nightly=True) + except (requests.RequestException, KeyError, ValueError): + current_nightly_version = None + + build_number = "0" + latest_base_version = current_version.base_version + nightly_base_version = current_nightly_version.base_version if current_nightly_version else None + + if latest_base_version == nightly_base_version: + dev_number = (current_nightly_version.dev or -1) if current_nightly_version else -1 + build_number = str(dev_number + 1) + + new_nightly_version = f"v{latest_base_version}.dev{build_number}" + + # Verify PEP440 + Version(new_nightly_version) + return new_nightly_version + +if __name__ == "__main__": + try: + tag = create_tag() + print(tag) + except Exception as e: + print(f"Error creating tag: {e}", file=sys.stderr) + sys.exit(1) diff --git a/scripts/ci/update_pyproject_combined.py b/scripts/ci/update_pyproject_combined.py new file mode 100644 index 000000000..6d9a05f27 --- /dev/null +++ b/scripts/ci/update_pyproject_combined.py @@ -0,0 +1,27 @@ +import sys +from pathlib import Path +from update_pyproject_name import update_pyproject_name +from update_pyproject_version import update_pyproject_version + +# Add current dir to sys.path +current_dir = Path(__file__).resolve().parent +sys.path.append(str(current_dir)) + +def main(): + if len(sys.argv) != 3: + print("Usage: update_pyproject_combined.py main ") + sys.exit(1) + + mode = sys.argv[1] + main_tag = sys.argv[2] + + if mode != "main": + print("Only 'main' mode is supported") + sys.exit(1) + + # Update name and version for openrag + update_pyproject_name("pyproject.toml", "openrag-nightly") + update_pyproject_version("pyproject.toml", main_tag) + +if __name__ == "__main__": + main() diff --git a/scripts/ci/update_pyproject_name.py b/scripts/ci/update_pyproject_name.py new file mode 100644 index 000000000..9c7468f69 --- /dev/null +++ b/scripts/ci/update_pyproject_name.py @@ -0,0 +1,20 @@ +import re +import sys +from pathlib import Path + +def update_pyproject_name(file_path: str, new_name: str): + path = Path(file_path) + if not path.exists(): + print(f"File {file_path} not found") + return + + content = path.read_text() + new_content = re.sub(r'^name = "[^"]+"', f'name = "{new_name}"', content, flags=re.M) + path.write_text(new_content) + print(f"Updated name in {file_path} to {new_name}") + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: update_pyproject_name.py ") + sys.exit(1) + update_pyproject_name(sys.argv[1], sys.argv[2]) diff --git a/scripts/ci/update_pyproject_version.py b/scripts/ci/update_pyproject_version.py new file mode 100644 index 000000000..9ddbb4a7f --- /dev/null +++ b/scripts/ci/update_pyproject_version.py @@ -0,0 +1,23 @@ +import re +import sys +from pathlib import Path + +def update_version(new_version): + pyproject_path = Path("pyproject.toml") + with open(pyproject_path, "r") as f: + content = f.read() + + # Update the version field + # Removes 'v' prefix if present from tag + clean_version = new_version.lstrip('v') + new_content = re.sub(r'^version = "[^"]+"', f'version = "{clean_version}"', content, flags=re.M) + + with open(pyproject_path, "w") as f: + f.write(new_content) + print(f"Updated pyproject.toml version to {clean_version}") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python update_pyproject_version.py ") + sys.exit(1) + update_version(sys.argv[1]) From 1dea2adf0b354f1d0dff61ad7d1da159dcbb2196 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:14:46 -0300 Subject: [PATCH 02/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/ci/update_pyproject_name.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/update_pyproject_name.py b/scripts/ci/update_pyproject_name.py index 9c7468f69..33557fa21 100644 --- a/scripts/ci/update_pyproject_name.py +++ b/scripts/ci/update_pyproject_name.py @@ -6,7 +6,7 @@ def update_pyproject_name(file_path: str, new_name: str): path = Path(file_path) if not path.exists(): print(f"File {file_path} not found") - return + raise SystemExit(1) content = path.read_text() new_content = re.sub(r'^name = "[^"]+"', f'name = "{new_name}"', content, flags=re.M) From 2d031e556f309967760ab9d683aca2a5ed51d095 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:15:16 -0300 Subject: [PATCH 03/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/ci/pypi_nightly_tag.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/pypi_nightly_tag.py b/scripts/ci/pypi_nightly_tag.py index 954672e73..b80ca889f 100644 --- a/scripts/ci/pypi_nightly_tag.py +++ b/scripts/ci/pypi_nightly_tag.py @@ -3,11 +3,12 @@ from packaging.version import Version from pathlib import Path import tomllib +from typing import Optional PYPI_OPENRAG_NIGHTLY_URL = "https://pypi.org/pypi/openrag-nightly/json" PYPI_OPENRAG_URL = "https://pypi.org/pypi/openrag/json" -def get_latest_published_version(is_nightly: bool) -> Version: +def get_latest_published_version(is_nightly: bool) -> Optional[Version]: url = PYPI_OPENRAG_NIGHTLY_URL if is_nightly else PYPI_OPENRAG_URL res = requests.get(url, timeout=10) if res.status_code == 404: From 15d04ffb8ff7b7e82237a822605aab4967d6cfcc Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:15:53 -0300 Subject: [PATCH 04/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 63fdac690..6d4c751a1 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -198,7 +198,7 @@ jobs: # In the create-nightly-tag job we pushed a tag, here we should probably checkout that tag # or just use the updated pyproject.toml if it's shared (it's not). # So we need to checkout the tag. - git fetch origin ${{ needs.create-nightly-tag.outputs.nightly_version }} + git fetch origin "refs/tags/${{ needs.create-nightly-tag.outputs.nightly_version }}:refs/tags/${{ needs.create-nightly-tag.outputs.nightly_version }}" git checkout ${{ needs.create-nightly-tag.outputs.nightly_version }} - name: Build wheel and source distribution From 7d7c30e87b64094652f753ea52188a72fa309908 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:16:14 -0300 Subject: [PATCH 05/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 6d4c751a1..6c95bc04a 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -156,7 +156,7 @@ jobs: - name: Create and push multi-arch manifests run: | NS="langflowai" - VERSION=${{ needs.check-version.outputs.nightly_version }} + VERSION=${{ needs.create-nightly-tag.outputs.nightly_version }} # Derive the list of services from the artifacts produced by the build matrix mapfile -t SERVICES < <(find . -name 'service-*.txt' -print0 | xargs -0 cat | sort -u) From 7c37253e680835e8ceb723125a3f019c4fecbff9 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:11:22 -0300 Subject: [PATCH 06/17] update import --- scripts/ci/update_pyproject_combined.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/update_pyproject_combined.py b/scripts/ci/update_pyproject_combined.py index 6d9a05f27..5259b9145 100644 --- a/scripts/ci/update_pyproject_combined.py +++ b/scripts/ci/update_pyproject_combined.py @@ -1,7 +1,7 @@ import sys from pathlib import Path from update_pyproject_name import update_pyproject_name -from update_pyproject_version import update_pyproject_version +from update_pyproject_version import update_version # Add current dir to sys.path current_dir = Path(__file__).resolve().parent @@ -21,7 +21,7 @@ def main(): # Update name and version for openrag update_pyproject_name("pyproject.toml", "openrag-nightly") - update_pyproject_version("pyproject.toml", main_tag) + update_version("pyproject.toml", main_tag) if __name__ == "__main__": main() From 154b79e9aad7d5a8c2c150cbc050f5cbc5a3611b Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:11:33 -0300 Subject: [PATCH 07/17] remove pyproject from update version --- scripts/ci/update_pyproject_combined.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/update_pyproject_combined.py b/scripts/ci/update_pyproject_combined.py index 5259b9145..6155978d0 100644 --- a/scripts/ci/update_pyproject_combined.py +++ b/scripts/ci/update_pyproject_combined.py @@ -21,7 +21,7 @@ def main(): # Update name and version for openrag update_pyproject_name("pyproject.toml", "openrag-nightly") - update_version("pyproject.toml", main_tag) + update_version(main_tag) if __name__ == "__main__": main() From 983ef0562fcd90d61aa6861704dae90d81f07347 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:14:23 -0300 Subject: [PATCH 08/17] updated update_pyproject_name --- scripts/ci/update_pyproject_combined.py | 2 +- scripts/ci/update_pyproject_name.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/ci/update_pyproject_combined.py b/scripts/ci/update_pyproject_combined.py index 6155978d0..199f813cb 100644 --- a/scripts/ci/update_pyproject_combined.py +++ b/scripts/ci/update_pyproject_combined.py @@ -20,7 +20,7 @@ def main(): sys.exit(1) # Update name and version for openrag - update_pyproject_name("pyproject.toml", "openrag-nightly") + update_pyproject_name("openrag-nightly") update_version(main_tag) if __name__ == "__main__": diff --git a/scripts/ci/update_pyproject_name.py b/scripts/ci/update_pyproject_name.py index 33557fa21..37e50e15e 100644 --- a/scripts/ci/update_pyproject_name.py +++ b/scripts/ci/update_pyproject_name.py @@ -2,19 +2,19 @@ import sys from pathlib import Path -def update_pyproject_name(file_path: str, new_name: str): - path = Path(file_path) +def update_pyproject_name(new_name: str): + path = Path("pyproject.toml") if not path.exists(): - print(f"File {file_path} not found") + print("File pyproject.toml not found") raise SystemExit(1) content = path.read_text() new_content = re.sub(r'^name = "[^"]+"', f'name = "{new_name}"', content, flags=re.M) path.write_text(new_content) - print(f"Updated name in {file_path} to {new_name}") + print(f"Updated name in pyproject.toml to {new_name}") if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: update_pyproject_name.py ") + if len(sys.argv) != 2: + print("Usage: update_pyproject_name.py ") sys.exit(1) - update_pyproject_name(sys.argv[1], sys.argv[2]) + update_pyproject_name(sys.argv[1]) From a90582a7a0faab1085c08d19f3eb972bffc5b23f Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:16:48 -0300 Subject: [PATCH 09/17] updated nightly logic --- scripts/ci/pypi_nightly_tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/pypi_nightly_tag.py b/scripts/ci/pypi_nightly_tag.py index b80ca889f..7acdcb9bb 100644 --- a/scripts/ci/pypi_nightly_tag.py +++ b/scripts/ci/pypi_nightly_tag.py @@ -40,7 +40,7 @@ def create_tag(): nightly_base_version = current_nightly_version.base_version if current_nightly_version else None if latest_base_version == nightly_base_version: - dev_number = (current_nightly_version.dev or -1) if current_nightly_version else -1 + dev_number = (current_nightly_version.dev if current_nightly_version.dev is not None else -1) if current_nightly_version else -1 build_number = str(dev_number + 1) new_nightly_version = f"v{latest_base_version}.dev{build_number}" From 93f43dd0ed064fdff4c85648ee3a948dfe64a5c3 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:21:53 -0300 Subject: [PATCH 10/17] changed things for github --- .github/workflows/nightly-build.yml | 2 +- src/tui/utils/version_check.py | 17 ++++++++++------- src/utils/version_utils.py | 7 ++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 6c95bc04a..f3d7a34b4 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -123,7 +123,7 @@ jobs: file: ${{ matrix.file }} platforms: ${{ matrix.platform }} push: true - tags: langflowai/${{ matrix.service }}:${{ needs.check-version.outputs.nightly_version }}-${{ matrix.arch }} + tags: langflowai/${{ matrix.service }}:${{ needs.create-nightly-tag.outputs.nightly_version }}-${{ matrix.arch }} cache-from: type=gha,scope=nightly-${{ matrix.image }}-${{ matrix.arch }} cache-to: type=gha,mode=max,scope=nightly-${{ matrix.image }}-${{ matrix.arch }} diff --git a/src/tui/utils/version_check.py b/src/tui/utils/version_check.py index 16c5d884f..334832ac7 100644 --- a/src/tui/utils/version_check.py +++ b/src/tui/utils/version_check.py @@ -88,15 +88,18 @@ def get_current_version() -> str: Returns: Version string or "unknown" if not available """ - try: - from importlib.metadata import version - return version("openrag") - except Exception: + for dist_name in ["openrag", "openrag-nightly"]: try: - from tui import __version__ - return __version__ + from importlib.metadata import version + return version(dist_name) except Exception: - return "unknown" + continue + + try: + from tui import __version__ + return __version__ + except Exception: + return "unknown" def compare_versions(version1: str, version2: str) -> int: diff --git a/src/utils/version_utils.py b/src/utils/version_utils.py index 061db5b73..09c22a13a 100644 --- a/src/utils/version_utils.py +++ b/src/utils/version_utils.py @@ -8,7 +8,12 @@ def _get_openrag_version() -> str: from importlib.metadata import version, PackageNotFoundError try: - return version("openrag") + for dist_name in ["openrag", "openrag-nightly"]: + try: + return version(dist_name) + except PackageNotFoundError: + continue + raise PackageNotFoundError("openrag") except PackageNotFoundError: # Fallback: try to read from pyproject.toml if package not installed (dev mode) try: From 76129092ceadfb1ef42fb7ebb140d79846070d15 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 18 Mar 2026 22:23:49 -0300 Subject: [PATCH 11/17] fix github nitpicks --- scripts/ci/update_pyproject_name.py | 9 +++++++++ scripts/ci/update_pyproject_version.py | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/scripts/ci/update_pyproject_name.py b/scripts/ci/update_pyproject_name.py index 37e50e15e..20d46a261 100644 --- a/scripts/ci/update_pyproject_name.py +++ b/scripts/ci/update_pyproject_name.py @@ -10,6 +10,15 @@ def update_pyproject_name(new_name: str): content = path.read_text() new_content = re.sub(r'^name = "[^"]+"', f'name = "{new_name}"', content, flags=re.M) + + # Fail if the name pattern was not found / no substitution was made + if new_content == content: + print( + 'Error: Could not find a line matching `name = "..."` in pyproject.toml to update.', + file=sys.stderr, + ) + sys.exit(1) + path.write_text(new_content) print(f"Updated name in pyproject.toml to {new_name}") diff --git a/scripts/ci/update_pyproject_version.py b/scripts/ci/update_pyproject_version.py index 9ddbb4a7f..4503b720d 100644 --- a/scripts/ci/update_pyproject_version.py +++ b/scripts/ci/update_pyproject_version.py @@ -12,6 +12,14 @@ def update_version(new_version): clean_version = new_version.lstrip('v') new_content = re.sub(r'^version = "[^"]+"', f'version = "{clean_version}"', content, flags=re.M) + # Fail if the version pattern was not found / no substitution was made + if new_content == content: + print( + 'Error: Could not find a line matching `version = "..."` in pyproject.toml to update.', + file=sys.stderr, + ) + sys.exit(1) + with open(pyproject_path, "w") as f: f.write(new_content) print(f"Updated pyproject.toml version to {clean_version}") From 5b1fb9974427056c291d0bc9df68c38216f86f67 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:55:58 -0300 Subject: [PATCH 12/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/ci/pypi_nightly_tag.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/ci/pypi_nightly_tag.py b/scripts/ci/pypi_nightly_tag.py index 7acdcb9bb..63cb5b6ad 100644 --- a/scripts/ci/pypi_nightly_tag.py +++ b/scripts/ci/pypi_nightly_tag.py @@ -43,10 +43,14 @@ def create_tag(): dev_number = (current_nightly_version.dev if current_nightly_version.dev is not None else -1) if current_nightly_version else -1 build_number = str(dev_number + 1) - new_nightly_version = f"v{latest_base_version}.dev{build_number}" - + # Build PEP 440-compliant nightly version (without leading "v") + nightly_version_str = f"{latest_base_version}.dev{build_number}" + # Verify PEP440 - Version(new_nightly_version) + Version(nightly_version_str) + + # Git tag uses a leading "v" prefix + new_nightly_version = f"v{nightly_version_str}" return new_nightly_version if __name__ == "__main__": From 4a3f4794f784dabc454b97155f90b37265be788b Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:56:20 -0300 Subject: [PATCH 13/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-build.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index f3d7a34b4..c6d3997b7 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -13,7 +13,7 @@ jobs: permissions: contents: write outputs: - nightly_version: ${{ steps.generate_tag.outputs.nightly_tag }} + nightly_version: ${{ steps.ensure_unique_tag.outputs.nightly_tag }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -38,9 +38,22 @@ jobs: echo "nightly_tag=$TAG" >> $GITHUB_OUTPUT echo "nightly_tag=$TAG" + - name: Ensure unique nightly tag + id: ensure_unique_tag + run: | + BASE_TAG="${{ steps.generate_tag.outputs.nightly_tag }}" + TAG="$BASE_TAG" + # If the tag already exists on the remote, append a run-specific suffix + if git ls-remote --exit-code --tags origin "$TAG" >/dev/null 2>&1; then + SUFFIX="${GITHUB_RUN_ID:-0}" + TAG="${TAG}.run${SUFFIX}" + fi + echo "Resolved nightly tag: $TAG" + echo "nightly_tag=$TAG" >> "$GITHUB_OUTPUT" + - name: Update pyproject.toml run: | - python3 scripts/ci/update_pyproject_combined.py main ${{ steps.generate_tag.outputs.nightly_tag }} + python3 scripts/ci/update_pyproject_combined.py main ${{ steps.ensure_unique_tag.outputs.nightly_tag }} - name: Commit and push tag run: | @@ -48,10 +61,10 @@ jobs: git config --global user.name "OpenRAG Bot" git add pyproject.toml - git commit -m "Update version and project name for nightly ${{ steps.generate_tag.outputs.nightly_tag }}" + git commit -m "Update version and project name for nightly ${{ steps.ensure_unique_tag.outputs.nightly_tag }}" - git tag ${{ steps.generate_tag.outputs.nightly_tag }} - git push origin ${{ steps.generate_tag.outputs.nightly_tag }} + git tag ${{ steps.ensure_unique_tag.outputs.nightly_tag }} + git push origin ${{ steps.ensure_unique_tag.outputs.nightly_tag }} build: needs: create-nightly-tag From e6fe41e245ef2d27b18b89881e126d1996fe62e0 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:56:34 -0300 Subject: [PATCH 14/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/ci/update_pyproject_combined.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/ci/update_pyproject_combined.py b/scripts/ci/update_pyproject_combined.py index 199f813cb..01949123f 100644 --- a/scripts/ci/update_pyproject_combined.py +++ b/scripts/ci/update_pyproject_combined.py @@ -1,11 +1,14 @@ import sys from pathlib import Path -from update_pyproject_name import update_pyproject_name -from update_pyproject_version import update_version # Add current dir to sys.path current_dir = Path(__file__).resolve().parent -sys.path.append(str(current_dir)) +current_dir_str = str(current_dir) +if current_dir_str not in sys.path: + sys.path.append(current_dir_str) + +from update_pyproject_name import update_pyproject_name +from update_pyproject_version import update_version def main(): if len(sys.argv) != 3: From 481049700d747e031d12478a8e557ca46c143916 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 23:27:11 -0300 Subject: [PATCH 15/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-build.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index c6d3997b7..4036280e4 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -43,10 +43,25 @@ jobs: run: | BASE_TAG="${{ steps.generate_tag.outputs.nightly_tag }}" TAG="$BASE_TAG" - # If the tag already exists on the remote, append a run-specific suffix + # If the tag already exists on the remote, resolve collision using .devN suffixes (PEP 440 compliant) if git ls-remote --exit-code --tags origin "$TAG" >/dev/null 2>&1; then - SUFFIX="${GITHUB_RUN_ID:-0}" - TAG="${TAG}.run${SUFFIX}" + echo "Base tag '$TAG' already exists on remote. Searching for available .devN suffix..." + MAX_DEV=20 + FOUND=0 + i=1 + while [ "$i" -le "$MAX_DEV" ]; do + CANDIDATE="${BASE_TAG}.dev${i}" + if ! git ls-remote --exit-code --tags origin "$CANDIDATE" >/dev/null 2>&1; then + TAG="$CANDIDATE" + FOUND=1 + break + fi + i=$((i + 1)) + done + if [ "$FOUND" -ne 1 ]; then + echo "Error: Unable to find an available .devN tag for base tag '$BASE_TAG' after checking ${MAX_DEV} candidates." >&2 + exit 1 + fi fi echo "Resolved nightly tag: $TAG" echo "nightly_tag=$TAG" >> "$GITHUB_OUTPUT" From dc92fa0275e0745e9ac4905de9f7d8ea7743b548 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 23:27:42 -0300 Subject: [PATCH 16/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/ci/update_pyproject_version.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/ci/update_pyproject_version.py b/scripts/ci/update_pyproject_version.py index 4503b720d..d4bd29b91 100644 --- a/scripts/ci/update_pyproject_version.py +++ b/scripts/ci/update_pyproject_version.py @@ -1,17 +1,34 @@ import re import sys from pathlib import Path +from packaging.version import Version, InvalidVersion def update_version(new_version): pyproject_path = Path("pyproject.toml") with open(pyproject_path, "r") as f: content = f.read() - + # Update the version field # Removes 'v' prefix if present from tag clean_version = new_version.lstrip('v') - new_content = re.sub(r'^version = "[^"]+"', f'version = "{clean_version}"', content, flags=re.M) - + + # Validate that the resulting version is a valid PEP 440 version + try: + Version(clean_version) + except InvalidVersion: + print( + f"Error: '{clean_version}' is not a valid PEP 440 version after stripping any leading 'v'.", + file=sys.stderr, + ) + sys.exit(1) + + new_content = re.sub( + r'^version = "[^"]+"', + f'version = "{clean_version}"', + content, + flags=re.M, + ) + # Fail if the version pattern was not found / no substitution was made if new_content == content: print( @@ -19,7 +36,7 @@ def update_version(new_version): file=sys.stderr, ) sys.exit(1) - + with open(pyproject_path, "w") as f: f.write(new_content) print(f"Updated pyproject.toml version to {clean_version}") From 3c29f3a030c93722517aad00883cfceb4f637150 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Wed, 18 Mar 2026 23:28:19 -0300 Subject: [PATCH 17/17] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/nightly-build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 4036280e4..bac680e7b 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -132,8 +132,11 @@ jobs: runs-on: ${{ matrix.runs-on }} steps: - - name: Checkout + - name: Checkout nightly tag uses: actions/checkout@v4 + with: + ref: ${{ needs.create-nightly-tag.outputs.nightly_version }} + fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3