Skip to content

Commit 6e2b5ad

Browse files
committed
Add Automated release versioning
1 parent 7a19369 commit 6e2b5ad

7 files changed

Lines changed: 451 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
name: 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+
39
on:
410
push:
5-
branches: [ main, master ]
11+
branches: [ main, "release/*" ]
612
pull_request:
7-
branches: [ main, master ]
13+
branches: [ main, "release/*" ]
814

915
jobs:
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
@@ -110,7 +114,7 @@ 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+
PackageVersion=${{ needs.version-number.outputs.PACKAGE_VERSION }} uv build --all-packages --wheel
114118
115119
- name: Run unit tests
116120
run: |
@@ -143,7 +147,11 @@ jobs:
143147
path: ~/drop/python-${{ matrix.python-version }}.zip
144148

145149
- name: Publish
146-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changed-sdks.outputs.python-sdk == 'true'
150+
# Only publish when:
151+
# 1. It's a push event (not a PR)
152+
# 2. The branch is a release/* branch
153+
# 3. There are SDK changes
154+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') && needs.changed-sdks.outputs.python-sdk == 'true'
147155
run: |
148156
uv run twine upload --config-file .pypirc -r Agent365 dist/*
149157
continue-on-error: true

0 commit comments

Comments
 (0)