1+ name : Auto Release when Tag
2+ on :
3+ push :
4+ tags :
5+ - ' v*'
6+ - ' test/v*'
7+
8+ concurrency :
9+ group : ${{ github.workflow }}-${{ github.ref }}
10+ cancel-in-progress : false
11+
12+ permissions :
13+ contents : read
14+
15+ jobs :
16+ release :
17+ runs-on : [self-hosted, trpc-agent-python-ci]
18+ timeout-minutes : 30
19+ steps :
20+ - name : Checkout
21+ uses : actions/checkout@v4
22+
23+ - name : Install release dependencies
24+ run : |
25+ python -m pip install --upgrade pip
26+ pip install -r requirements-test.txt
27+ pip install build twine flake8 yapf
28+
29+ - name : Validate tag version
30+ run : |
31+ TAG_VERSION="${GITHUB_REF_NAME#test/v}"
32+ TAG_VERSION="${TAG_VERSION#v}"
33+ PACKAGE_VERSION=$(python -c "from trpc_agent_sdk.version import __version__; print(__version__)")
34+ if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
35+ echo "::error::Tag version '$TAG_VERSION' does not match package version '$PACKAGE_VERSION'."
36+ exit 1
37+ fi
38+
39+ - name : Check formatting with YAPF
40+ run : |
41+ diff_output=$(yapf --diff --recursive trpc_agent_sdk) || true
42+ if [ -n "$diff_output" ]; then
43+ echo "$diff_output"
44+ echo "::error::Code formatting check failed. Run 'yapf -i -r trpc_agent_sdk' to fix."
45+ exit 1
46+ fi
47+
48+ - name : Lint with flake8
49+ run : |
50+ flake8 trpc_agent_sdk
51+
52+ - name : Run tests with coverage
53+ run : |
54+ pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term --cov-fail-under=80 tests/
55+
56+ - name : Build package
57+ run : |
58+ python -m build
59+
60+ - name : Check package
61+ run : |
62+ twine check dist/*
63+
64+ - name : Publish to PyPI
65+ if : startsWith(github.ref, 'refs/tags/v')
66+ run : |
67+ twine upload dist/*
68+ env :
69+ TWINE_USERNAME : __token__
70+ TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
0 commit comments