Files
iofficeai--officecli/.github/workflows/publish-pypi.yml
T
wehub-resource-sync 8cb1f9f479
Publish SDK (PyPI) / publish (push) Waiting to run
Publish SDK (npm) / publish (@aionui/officecli-sdk) (push) Waiting to run
Publish SDK (npm) / publish (@officecli/officecli-sdk) (push) Waiting to run
Publish SDK (npm) / publish (@officecli/sdk) (push) Waiting to run
Publish SDK (npm) / publish (officecli-sdk) (push) Waiting to run
SDK smoke / smoke (windows-latest) (push) Waiting to run
SDK smoke / smoke (macos-latest) (push) Waiting to run
SDK smoke / smoke (ubuntu-latest) (push) Waiting to run
Skill parity / diff (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:09:29 +08:00

64 lines
2.2 KiB
YAML

name: Publish SDK (PyPI)
# Publishes officecli-sdk (sdk/python) to PyPI on its OWN cadence — same model as
# publish-sdk.yml for npm. Triggers on a push touching sdk/python/** (or manual
# dispatch); a guard skips when that version is already on PyPI, so only a
# version bump in pyproject.toml actually publishes. A CLI release does NOT
# republish the SDK.
#
# Auth: PyPI Trusted Publishing (OIDC), no token / no API key. Configure the
# trusted publisher for the officecli-sdk project on pypi.org:
# owner: iOfficeAI repo: OfficeCLI workflow: publish-pypi.yml
# (officecli-sdk already exists on PyPI, so the publisher can be added directly.)
on:
push:
branches: [main]
paths:
- 'sdk/python/**'
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write # OIDC token for PyPI trusted publishing
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Resolve version and check if already on PyPI
id: ver
working-directory: sdk/python
run: |
NAME=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['name'])")
VERSION=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
echo "Publishing candidate: $NAME==$VERSION"
CODE=$(curl -s -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/$NAME/$VERSION/json")
if [ "$CODE" = "200" ]; then
echo "already=true" >> "$GITHUB_OUTPUT"
echo "$NAME==$VERSION is already on PyPI — nothing to publish (bump the version to release)."
else
echo "already=false" >> "$GITHUB_OUTPUT"
fi
- name: Build sdist + wheel
if: steps.ver.outputs.already == 'false'
working-directory: sdk/python
run: |
python -m pip install --upgrade build
python -m build
- name: Publish to PyPI
if: steps.ver.outputs.already == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: sdk/python/dist