Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 84 additions & 27 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,94 @@
name: Build and Upload Python Package
name: Test, build and publish Python package

on:
pull_request:
push:
tags:
- '*'
branches: [main]
tags: ['*']

permissions:
contents: read

jobs:
build_and_publish:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
- name: Sync locked project and development tools
run: uv sync --locked
- name: Check Python lint and formatting
run: |
uv run --locked ruff check .
uv run --locked ruff format --check .
- name: Check release version
if: startsWith(github.ref, 'refs/tags/')
run: |
uv run --locked python - <<'PY'
import os
import tomllib
from pathlib import Path

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
version = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
tag = os.environ["GITHUB_REF_NAME"].removeprefix("v")
if tag != version:
raise SystemExit(f"Tag {tag!r} does not match package version {version!r}")
PY
- name: Build and validate distributions
run: |
uv build
uv run --locked twine check dist/*
- uses: actions/upload-artifact@v7.0.2
with:
name: distributions
path: dist/
if-no-files-found: error

- name: Build package
run: python -m build

- name: Install twine
run: |
python -m pip install --upgrade twine
test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14', '3.15']
steps:
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v8.0.2
with:
name: distributions
path: dist/
- name: Test project with locked dependencies
run: |
uv sync --locked
uv run --locked python -m unittest discover -s tests -v
- name: Install wheel in a clean environment and test public API
run: |
uv venv "$RUNNER_TEMP/client-test"
uv pip install --python "$RUNNER_TEMP/client-test/bin/python" dist/*.whl
uv pip check --python "$RUNNER_TEMP/client-test/bin/python"
"$RUNNER_TEMP/client-test/bin/python" -c 'import tu_ruc_python_client'
"$RUNNER_TEMP/client-test/bin/python" -m unittest discover -s tests -v

- name: Publish package
run: |
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
publish:
if: startsWith(github.ref, 'refs/tags/')
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
- uses: actions/download-artifact@v8.0.2
with:
name: distributions
path: dist/
- name: Publish tested distributions
run: uv publish dist/*
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.ruff_cache/
cover/

# Translations
Expand Down Expand Up @@ -122,6 +123,7 @@ celerybeat.pid
# Environments
.env
.venv
.venv-wheel/
env/
venv/
ENV/
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.15.0
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

## 0.1.0 — Sin publicar

- El mínimo pasa de Python 3.8 a Python 3.11; la CI verifica CPython 3.11–3.15.
- HTTPX (`httpx>=0.28.1,<1`) reemplaza a Requests como dependencia de ejecución.
Los errores de transporte pasan a la familia `httpx.RequestError`.
- Los nuevos `TuRucClient` y `AsyncTuRucClient` reutilizan conexiones y permiten
cerrarlas con `with`/`async with` o `close()`/`aclose()`. Admiten `base_url`
y `timeout`; el timeout predeterminado es de 10 segundos por fase.
- Las funciones existentes conservan sus parámetros y respuestas, las llamadas
aisladas sin timeout y el seguimiento de redirecciones.
- Las búsquedas conservan `&`, `+`, espacios y acentos mediante parámetros
HTTP codificados correctamente.
- uv 0.13.0 gestiona desarrollo, pruebas, construcción y publicación. Se añade
`uv.lock`, Python 3.15.0 en `.python-version` y un grupo `dev` para validar
distribuciones. Sustituye los archivos `requirements-build.in` y `.txt`.
- Ruff 0.17.0 unifica lint y formato de código fuente y pruebas,
con Python 3.11 como objetivo. La CI exige ambas comprobaciones antes de
construir; se normalizan imports y formato conservando la API pública.
- El empaquetado conserva el backend `setuptools`, la licencia MIT y las
versiones soportadas. El lock de desarrollo no restringe las dependencias
de quienes instalan el SDK.
- Las pruebas verifican el contrato público, las conexiones contra un servidor
local y el wheel instalado. La publicación de tags depende de esas comprobaciones.
Loading
Loading