11name : CI - Build, Test, and Publish SDKs
22
3+ # This workflow builds, tests, and publishes Python SDK packages
4+ # - Builds and tests run on all branches (main, release/*)
5+ # - Publishing to package repository ONLY happens on release/* branches
6+ # - Development versions (with 'dev' suffix) are created on all non-tagged commits
7+ # - Official releases (without 'dev' suffix) require a Git tag on a release/* branch
8+
39on :
410 push :
5- branches : [ main, master ]
11+ branches : [ main, "release/*" ]
612 pull_request :
7- branches : [ main, master ]
13+ branches : [ main, "release/*" ]
814
915jobs :
1016 version-number :
1117 runs-on : ubuntu-latest
1218 steps :
13- - name : Set current date in UTC as env variable
14- run : |
15- export CURRENT_DATE="$(date -u +'%Y.%m.%d')"
16- echo "Current date is ${CURRENT_DATE}"
17- echo "CURRENT_DATE=${CURRENT_DATE}" >> $GITHUB_ENV
19+ - name : Checkout repository
20+ uses : actions/checkout@v4
21+ with :
22+ fetch-depth : 0 # Need full history for git versioning
23+
24+ - name : Set up Python
25+ uses : actions/setup-python@v5
26+ with :
27+ python-version : ' 3.11'
1828
19- - id : build_version
20- name : Generate Build Version
29+ - name : Install setuptools-git-versioning
2130 run : |
22- export BUILD_VERSION="$CURRENT_DATE.${{ github.run_number }}"
23- echo "Build version is ${BUILD_VERSION}"
24- echo "BUILD_VERSION=${BUILD_VERSION}" >> $GITHUB_OUTPUT
31+ python -m pip install --upgrade pip
32+ python -m pip install setuptools-git-versioning
2533
2634 - id : package_version
27- name : Generate Package Version
35+ name : Calculate Package Version
2836 run : |
29- export PACKAGE_VERSION="$CURRENT_DATE-preview.${{ github.run_number }}"
30- echo "Package version is ${PACKAGE_VERSION}"
31- echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
32- export PYTHON_PACKAGE_VERSION="$CURRENT_DATE+preview.${{ github.run_number }}"
33- echo "Python package version is ${PYTHON_PACKAGE_VERSION}"
34- echo "PYTHON_PACKAGE_VERSION=${PYTHON_PACKAGE_VERSION}" >> $GITHUB_OUTPUT
37+ cd ./versioning
38+ version=$(python -m setuptools_git_versioning)
39+ echo "Package version calculated: $version"
40+ echo "PACKAGE_VERSION=$version" >> $GITHUB_OUTPUT
3541
3642 outputs :
37- BUILD_VERSION : ${{ steps.build_version.outputs.BUILD_VERSION }}
3843 PACKAGE_VERSION : ${{ steps.package_version.outputs.PACKAGE_VERSION }}
39- PYTHON_PACKAGE_VERSION : ${{ steps.package_version.outputs.PYTHON_PACKAGE_VERSION }}
4044
4145 changed-sdks :
4246 name : Determine Changed SDKs
6367 - id : check_python_sdk
6468 name : Check Python SDK changes
6569 run : |
66- if git diff --name-only "${{ steps.git_refs.outputs.base }}" "${{ steps.git_refs.outputs.head }}" -- 'python /**' | grep -q .; then
70+ if git diff --name-only "${{ steps.git_refs.outputs.base }}" "${{ steps.git_refs.outputs.head }}" -- 'libraries/**' 'setup.py' 'pyproject.toml' 'versioning /**' | grep -q .; then
6771 echo "Python SDK changes detected"
6872 echo "changed=true" >> $GITHUB_OUTPUT
6973 else
@@ -110,22 +114,25 @@ jobs:
110114
111115 - name : Build package
112116 run : |
113- A365_SDK_VERSION=${{ needs.version-number.outputs.PYTHON_PACKAGE_VERSION }} uv build --all-packages --wheel
117+ AGENT365_PYTHON_SDK_PACKAGE_VERSION=${{ needs.version-number.outputs.PACKAGE_VERSION }} uv build --all-packages --wheel
118+ env :
119+ AGENT365_PYTHON_SDK_PACKAGE_VERSION : ${{ needs.version-number.outputs.PACKAGE_VERSION }}
114120
115121 - name : Run unit tests
116122 run : |
117- uv run --frozen python -m pytest tests/ -v --tb=short -m "not integration"
123+ uv run --frozen pytest tests/ -v --tb=short -m "not integration"
118124
119125 - name : Run integration tests
120126 # Only run integration tests if secrets are available
121127 if : ${{ vars.RUN_INTEGRATION_TESTS == 'true' }}
122128 run : |
123- uv run --frozen python -m pytest tests/ integration/ -v --tb=short -m integration
129+ uv run --frozen pytest -m integration -v --tb=short
124130 env :
125131 AZURE_OPENAI_API_KEY : ${{ secrets.AZURE_OPENAI_API_KEY }}
126132 AZURE_OPENAI_ENDPOINT : ${{ vars.AZURE_OPENAI_ENDPOINT }}
127133 AZURE_OPENAI_DEPLOYMENT : ${{ vars.AZURE_OPENAI_DEPLOYMENT }}
128134 AZURE_OPENAI_API_VERSION : ${{ vars.AZURE_OPENAI_API_VERSION }}
135+ ENABLE_OBSERVABILITY : true
129136
130137 # Copy package and samples to drop folder
131138 - name : Copy package and samples to drop folder
@@ -143,7 +150,11 @@ jobs:
143150 path : ~/drop/python-${{ matrix.python-version }}.zip
144151
145152 - name : Publish
146- if : github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changed-sdks.outputs.python-sdk == 'true'
153+ # Only publish when:
154+ # 1. It's a push event (not a PR)
155+ # 2. The branch is a release/* branch
156+ # 3. There are SDK changes
157+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') && needs.changed-sdks.outputs.python-sdk == 'true'
147158 run : |
148159 uv run twine upload --config-file .pypirc -r Agent365 dist/*
149160 continue-on-error : true
0 commit comments