Skip to content

fix: derive SDK request headers from installed version #120

fix: derive SDK request headers from installed version

fix: derive SDK request headers from installed version #120

Workflow file for this run

name: ci
on: [push, pull_request, workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v7
with:
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Compile
run: poetry run mypy .
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
pydantic: [">=2,<3"]
include:
- python: "3.10"
pydantic: ">=1.10.26,<2"
- python: "3.12"
pydantic: ">=1.10.26,<2"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Build and install wheel
env:
PYDANTIC_REQUIREMENT: ${{ matrix.pydantic }}
run: |
python -m pip wheel --no-deps --wheel-dir dist .
python -m pip install dist/*.whl "pydantic$PYDANTIC_REQUIREMENT" "pytest>=8.2,<9" "pytest-asyncio>=1,<2" "pytest-xdist>=3.6.1,<4" "python-dateutil>=2.9,<3"
python -m pip check
- name: Test
run: python -m pytest -rP -n auto tests
- name: Install aiohttp extra
run: python -m pip install "$(find dist -name '*.whl')[aiohttp]"
- name: Test (aiohttp)
run: python -m pytest -rP -n auto -m aiohttp tests
- name: Verify installed package version and request headers
run: |
python - <<'PY'
import importlib.metadata
from vapi.core.client_wrapper import BaseClientWrapper
version = importlib.metadata.version("vapi_server_sdk")
headers = BaseClientWrapper(token="ci-test", base_url="https://api.vapi.ai").get_headers()
assert headers["X-Fern-SDK-Version"] == version
assert headers["User-Agent"] == f"vapi_server_sdk/{version}"
PY
publish:
needs: [compile, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v7
with:
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Verify tag matches package version
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
version="$(poetry version --short)"
if [ "$RELEASE_TAG" != "$version" ] && [ "$RELEASE_TAG" != "v$version" ]; then
echo "Tag $RELEASE_TAG does not match package version $version"
exit 1
fi
- name: Publish to pypi
run: |
poetry config repositories.remote https://upload.pypi.org/legacy/
poetry --no-interaction -v publish --build --repository remote --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD"
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}