diff --git a/.github/workflows/release-vespacli.yml b/.github/workflows/release-vespacli.yml index 59bc7f35..0b3a2502 100644 --- a/.github/workflows/release-vespacli.yml +++ b/.github/workflows/release-vespacli.yml @@ -37,7 +37,6 @@ jobs: # Set the output variable echo "version=$version" >> $GITHUB_OUTPUT - check-and-update: runs-on: ubuntu-latest # Only run if we have a new version @@ -74,7 +73,6 @@ jobs: name: binaries path: vespacli/vespacli/go-binaries - test: runs-on: ${{ matrix.os }} # Only run if we have a new version @@ -86,7 +84,8 @@ jobs: VERSION: ${{ needs.prepare.outputs.version }} strategy: matrix: - os: [ubuntu-24.04, ubuntu-latest, windows-latest, macos-13, macos-latest] + os: + [ubuntu-24.04, ubuntu-latest, windows-latest, macos-13, macos-latest] python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 @@ -114,6 +113,7 @@ jobs: - name: Update latest version run: | python utils/update_version.py --version "${VERSION}" + shell: bash - name: Install dependencies run: | @@ -178,3 +178,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: print-hash: true + packages-dir: vespacli/dist/ diff --git a/vespacli/utils/update_version.py b/vespacli/utils/update_version.py index 7c36a766..015b3e3f 100644 --- a/vespacli/utils/update_version.py +++ b/vespacli/utils/update_version.py @@ -1,5 +1,4 @@ # This script should modify top level pyproject.toml to update the version of vespacli -# And modify vespacli/_version_generated.py to update the version of vespacli import toml import sys @@ -7,6 +6,7 @@ import argparse PYPROJECT_TOML_PATH = Path(__file__).parent.parent / "pyproject.toml" +VERSION_FILE_PATH = Path(__file__).parent.parent / "vespacli" / "_version_generated.py" def update_version(new_version: str): @@ -17,6 +17,11 @@ def update_version(new_version: str): with open("pyproject.toml", "w") as f: toml.dump(data, f) + # Also update version in vespacli/_version_generated.py + with open(VERSION_FILE_PATH, "w") as f: + # Write comment about auto-generation + f.write("# This file is auto-generated by utils/update_version.py\n") + f.write(f'__version__ = "{new_version}"\n') print(f"Updated version to {new_version}") diff --git a/vespacli/vespacli/__init__.py b/vespacli/vespacli/__init__.py index 62d64a62..cd3c1e00 100644 --- a/vespacli/vespacli/__init__.py +++ b/vespacli/vespacli/__init__.py @@ -1,9 +1,10 @@ import os +import sys import platform import subprocess -import sys +from ._version_generated import __version__ -from vespacli._version_generated import vespa_version +vespa_version = __version__ def get_binary_path(): @@ -26,7 +27,6 @@ def get_binary_path(): binary_dir_name = f"vespa-cli_{vespa_version}_{os_name}_{arch}" binary_path = os.path.join(go_binaries_path, binary_dir_name, "bin") - # Assuming the executable name is consistent and known executable_name = "vespa" if os_name != "windows" else "vespa.exe" full_executable_path = os.path.join(binary_path, executable_name) @@ -42,6 +42,3 @@ def run_vespa_cli(): full_cmd = [binary_path, *args] _result = subprocess.run(full_cmd) return - - -__version__ = vespa_version diff --git a/vespacli/vespacli/_version_generated.py b/vespacli/vespacli/_version_generated.py new file mode 100644 index 00000000..2a15b2b6 --- /dev/null +++ b/vespacli/vespacli/_version_generated.py @@ -0,0 +1,2 @@ +# This file is auto-generated by utils/update_version.py +__version__ = "8.dev"