Skip to content

Commit

Permalink
Merge pull request #971 from vespa-engine/thomasht86/fix-vespacli-wor…
Browse files Browse the repository at this point in the history
…kflow

(ci) fix vespacli workflow
  • Loading branch information
thomasht86 authored Nov 18, 2024
2 parents bc19884 + 887f897 commit b38751d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release-vespacli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -114,6 +113,7 @@ jobs:
- name: Update latest version
run: |
python utils/update_version.py --version "${VERSION}"
shell: bash

- name: Install dependencies
run: |
Expand Down Expand Up @@ -178,3 +178,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
packages-dir: vespacli/dist/
7 changes: 6 additions & 1 deletion vespacli/utils/update_version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 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
from pathlib import Path
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):
Expand All @@ -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}")


Expand Down
9 changes: 3 additions & 6 deletions vespacli/vespacli/__init__.py
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -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)

Expand All @@ -42,6 +42,3 @@ def run_vespa_cli():
full_cmd = [binary_path, *args]
_result = subprocess.run(full_cmd)
return


__version__ = vespa_version
2 changes: 2 additions & 0 deletions vespacli/vespacli/_version_generated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is auto-generated by utils/update_version.py
__version__ = "8.dev"

0 comments on commit b38751d

Please sign in to comment.