Skip to content

v2.16.4 — npm keywords + description refresh #24

v2.16.4 — npm keywords + description refresh

v2.16.4 — npm keywords + description refresh #24

Workflow file for this run

name: Publish Python SDK to PyPI
on:
release:
types: [created]
workflow_dispatch:
inputs:
environment:
description: 'Environment'
required: true
default: 'test'
type: choice
options:
- test
- prod
jobs:
publish-testpypi:
if: github.event.inputs.environment == 'test' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'test')
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/projects/a3m-router
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install build twine toml
- name: Get version
id: version
run: |
VERSION=$(python -c "import toml; print(toml.load('python/pyproject.toml')['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if version exists on Test PyPI
id: exists-testpypi
run: |
EXISTS=$(curl -s "https://test.pypi.org/pypi/a3m-router/${{ steps.version.outputs.version }}/json" | python3 -c "import sys,json; d=json.load(sys.stdin); print('yes' if d.get('info',{}).get('version') == '${{ steps.version.outputs.version }}' else 'no')" 2>/dev/null || echo "no")
echo "exists=$EXISTS" >> $GITHUB_OUTPUT
echo "Version ${{ steps.version.outputs.version }} on Test PyPI: $EXISTS"
if [ "$EXISTS" == "yes" ]; then
echo "SKIP_UPLOAD=true" >> $GITHUB_OUTPUT
fi
- name: Build package
if: steps.exists-testpypi.outputs.SKIP_UPLOAD != 'true'
run: |
cd python
python -m build
- name: Publish to Test PyPI
if: steps.exists-testpypi.outputs.SKIP_UPLOAD != 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
cd python
python -m twine upload --repository testpypi dist/*
- name: Already published notice
if: steps.exists-testpypi.outputs.SKIP_UPLOAD == 'true'
run: echo "Version ${{ steps.version.outputs.version }} already exists on Test PyPI — skipping upload"
publish-pypi:
if: github.event.inputs.environment == 'prod' || github.event_name == 'release'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/projects/a3m-router
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install build twine toml
- name: Get version
id: version
run: |
VERSION=$(python -c "import toml; print(toml.load('python/pyproject.toml')['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if version exists on PyPI
id: exists-pypi
run: |
EXISTS=$(curl -s "https://pypi.org/pypi/a3m-router/${{ steps.version.outputs.version }}/json" | python3 -c "import sys,json; d=json.load(sys.stdin); print('yes' if d.get('info',{}).get('version') == '${{ steps.version.outputs.version }}' else 'no')" 2>/dev/null || echo "no")
echo "exists=$EXISTS" >> $GITHUB_OUTPUT
echo "Version ${{ steps.version.outputs.version }} on PyPI: $EXISTS"
if [ "$EXISTS" == "yes" ]; then
echo "SKIP_UPLOAD=true" >> $GITHUB_OUTPUT
fi
- name: Build package
if: steps.exists-pypi.outputs.SKIP_UPLOAD != 'true'
run: |
cd python
python -m build
- name: Publish to PyPI
if: steps.exists-pypi.outputs.SKIP_UPLOAD != 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
cd python
python -m twine upload dist/*
- name: Already published notice
if: steps.exists-pypi.outputs.SKIP_UPLOAD == 'true'
run: echo "Version ${{ steps.version.outputs.version }} already exists on PyPI — skipping upload"
test-package:
runs-on: ubuntu-latest
needs: publish-testpypi
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install from Test PyPI
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
pip install --index-url https://test.pypi.org/simple/ a3m-router
- name: Test import
run: |
python -c "from a3m import A3MRouter, __version__; print(f'A3M Router SDK v{__version__} installed successfully!')"