|
15 | 15 | curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 |
16 | 16 | - name: Install dependencies |
17 | 17 | run: poetry install |
| 18 | + - name: Release metadata check |
| 19 | + run: poetry run python scripts/check_release_workflow.py |
18 | 20 | - name: Compile |
19 | 21 | run: poetry run mypy . |
20 | 22 | test: |
|
35 | 37 | - name: Test |
36 | 38 | run: poetry run pytest -rP . |
37 | 39 |
|
| 40 | + compat-build: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Checkout repo |
| 44 | + uses: actions/checkout@v4 |
| 45 | + - name: Set up python |
| 46 | + uses: actions/setup-python@v4 |
| 47 | + with: |
| 48 | + python-version: 3.8 |
| 49 | + - name: Bootstrap poetry |
| 50 | + run: | |
| 51 | + curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 |
| 52 | + - name: Install primary package |
| 53 | + run: poetry install |
| 54 | + - name: Build and verify compatibility package |
| 55 | + run: | |
| 56 | + cd compat/agora-agent-server-sdk |
| 57 | + poetry build |
| 58 | + cd ../.. |
| 59 | + poetry run pip install compat/agora-agent-server-sdk/dist/*.whl |
| 60 | + poetry run python - <<'PY' |
| 61 | + import agora_agent |
| 62 | + from agora_agent_server_sdk_compat import Agora, Area, __version__ |
| 63 | +
|
| 64 | + assert Agora is agora_agent.Agora |
| 65 | + assert Area is agora_agent.Area |
| 66 | + assert __version__ == agora_agent.__version__ |
| 67 | + print("Compat shim re-exports verified.") |
| 68 | + PY |
| 69 | +
|
38 | 70 | publish: |
39 | | - needs: [compile, test] |
| 71 | + needs: [compile, test, compat-build] |
40 | 72 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
41 | 73 | runs-on: ubuntu-latest |
42 | 74 | steps: |
|
51 | 83 | curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 |
52 | 84 | - name: Install dependencies |
53 | 85 | run: poetry install |
54 | | - - name: Publish to pypi |
| 86 | + |
| 87 | + - name: Verify package versions match release tag |
| 88 | + run: | |
| 89 | + TAG_VERSION="${GITHUB_REF_NAME#v}" |
| 90 | + ROOT_VERSION="$(poetry version -s | sed 's/^v//')" |
| 91 | + COMPAT_VERSION="$(cd compat/agora-agent-server-sdk && poetry version -s | sed 's/^v//')" |
| 92 | + COMPAT_DEP_VERSION="$(python -c "import re, sys; from pathlib import Path; text = Path('compat/agora-agent-server-sdk/pyproject.toml').read_text(); match = re.search(r'^agora-agents\s*=\s*\"([^\"]+)\"', text, re.M); sys.exit('agora-agents dependency not found in compat pyproject.toml') if not match else None; print(match.group(1))")" |
| 93 | +
|
| 94 | + if [ "$ROOT_VERSION" != "$TAG_VERSION" ]; then |
| 95 | + echo "Root package version ($ROOT_VERSION) does not match tag version ($TAG_VERSION)." |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | +
|
| 99 | + if [ "$COMPAT_VERSION" != "$TAG_VERSION" ]; then |
| 100 | + echo "Compat package version ($COMPAT_VERSION) does not match tag version ($TAG_VERSION)." |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +
|
| 104 | + if [ "$COMPAT_DEP_VERSION" != ">=${TAG_VERSION},<3.0.0" ]; then |
| 105 | + echo "Compat package dependency on agora-agents ($COMPAT_DEP_VERSION) does not match >=${TAG_VERSION},<3.0.0." |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | +
|
| 109 | + - name: Publish primary package to pypi |
55 | 110 | run: | |
56 | 111 | poetry config repositories.remote https://upload.pypi.org/legacy/ |
57 | 112 | poetry --no-interaction -v publish --build --repository remote --username "__token__" --password "$PYPI_API_TOKEN" |
58 | 113 | env: |
59 | 114 | PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 115 | + |
| 116 | + - name: Wait for primary package on PyPI |
| 117 | + run: | |
| 118 | + TAG_VERSION="${GITHUB_REF_NAME#v}" |
| 119 | + PACKAGE="agora-agents" |
| 120 | + for attempt in $(seq 1 12); do |
| 121 | + if pip index versions "$PACKAGE" 2>/dev/null | grep -q "$TAG_VERSION"; then |
| 122 | + echo "$PACKAGE==$TAG_VERSION is available on PyPI." |
| 123 | + exit 0 |
| 124 | + fi |
| 125 | + echo "Waiting for $PACKAGE==$TAG_VERSION on PyPI (attempt $attempt/12)..." |
| 126 | + sleep 10 |
| 127 | + done |
| 128 | + echo "Timed out waiting for $PACKAGE==$TAG_VERSION on PyPI." |
| 129 | + exit 1 |
| 130 | +
|
| 131 | + - name: Publish compatibility package to pypi |
| 132 | + run: | |
| 133 | + cd compat/agora-agent-server-sdk |
| 134 | + poetry config repositories.remote https://upload.pypi.org/legacy/ |
| 135 | + for attempt in $(seq 1 3); do |
| 136 | + if poetry --no-interaction -v publish --build --repository remote --username "__token__" --password "$PYPI_API_TOKEN"; then |
| 137 | + exit 0 |
| 138 | + fi |
| 139 | + echo "Compat publish failed (attempt $attempt/3). Retrying in 15s..." |
| 140 | + sleep 15 |
| 141 | + done |
| 142 | + exit 1 |
| 143 | + env: |
| 144 | + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments