66 - main
77 paths :
88 - ' codeflash/version.py'
9+ - ' codeflash-benchmark/codeflash_benchmark/version.py'
910
1011jobs :
11- publish :
12+ detect-changes :
13+ runs-on : ubuntu-latest
14+ outputs :
15+ codeflash : ${{ steps.filter.outputs.codeflash }}
16+ benchmark : ${{ steps.filter.outputs.benchmark }}
17+ steps :
18+ - name : Checkout
19+ uses : actions/checkout@v5
20+ with :
21+ fetch-depth : 2
22+
23+ - name : Detect which packages changed
24+ id : filter
25+ run : |
26+ if git diff --name-only HEAD~1 HEAD | grep -q '^codeflash/version.py$'; then
27+ echo "codeflash=true" >> $GITHUB_OUTPUT
28+ else
29+ echo "codeflash=false" >> $GITHUB_OUTPUT
30+ fi
31+ if git diff --name-only HEAD~1 HEAD | grep -q '^codeflash-benchmark/codeflash_benchmark/version.py$'; then
32+ echo "benchmark=true" >> $GITHUB_OUTPUT
33+ else
34+ echo "benchmark=false" >> $GITHUB_OUTPUT
35+ fi
36+
37+ publish-codeflash :
38+ needs : detect-changes
39+ if : needs.detect-changes.outputs.codeflash == 'true'
1240 runs-on : ubuntu-latest
1341 environment :
1442 name : pypi
1543 permissions :
1644 id-token : write
17- contents : write # Changed from 'read' to 'write' to allow tag creation
45+ contents : write
1846 steps :
1947 - name : Checkout
2048 uses : actions/checkout@v5
2149 with :
22- fetch-depth : 0 # Fetch all history for proper versioning
50+ fetch-depth : 0
2351
2452 - name : Extract version from version.py
2553 id : extract_version
@@ -76,4 +104,76 @@ jobs:
76104 prerelease : false
77105 generate_release_notes : true
78106 files : |
79- dist/*
107+ dist/*
108+
109+ publish-benchmark :
110+ needs : detect-changes
111+ if : needs.detect-changes.outputs.benchmark == 'true'
112+ runs-on : ubuntu-latest
113+ environment :
114+ name : pypi
115+ permissions :
116+ id-token : write
117+ contents : write
118+ steps :
119+ - name : Checkout
120+ uses : actions/checkout@v5
121+ with :
122+ fetch-depth : 0
123+
124+ - name : Extract version from version.py
125+ id : extract_version
126+ run : |
127+ VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash-benchmark/codeflash_benchmark/version.py)
128+ echo "version=$VERSION" >> $GITHUB_OUTPUT
129+ echo "tag=benchmark-v$VERSION" >> $GITHUB_OUTPUT
130+ echo "Extracted version: $VERSION"
131+
132+ - name : Check if tag already exists
133+ id : check_tag
134+ run : |
135+ if git rev-parse "${{ steps.extract_version.outputs.tag }}" >/dev/null 2>&1; then
136+ echo "exists=true" >> $GITHUB_OUTPUT
137+ echo "Tag ${{ steps.extract_version.outputs.tag }} already exists, skipping release"
138+ else
139+ echo "exists=false" >> $GITHUB_OUTPUT
140+ echo "Tag ${{ steps.extract_version.outputs.tag }} does not exist, proceeding with release"
141+ fi
142+
143+ - name : Create and push git tag
144+ if : steps.check_tag.outputs.exists == 'false'
145+ run : |
146+ git config user.name "github-actions[bot]"
147+ git config user.email "github-actions[bot]@users.noreply.github.com"
148+ git tag -a "${{ steps.extract_version.outputs.tag }}" -m "Release ${{ steps.extract_version.outputs.tag }}"
149+ git push origin "${{ steps.extract_version.outputs.tag }}"
150+
151+ - name : Install uv
152+ if : steps.check_tag.outputs.exists == 'false'
153+ uses : astral-sh/setup-uv@v6
154+
155+ - name : Build
156+ if : steps.check_tag.outputs.exists == 'false'
157+ run : uv build --package codeflash-benchmark
158+
159+ - name : Publish to PyPI
160+ if : steps.check_tag.outputs.exists == 'false'
161+ run : uv publish
162+
163+ - name : Create GitHub Release
164+ if : steps.check_tag.outputs.exists == 'false'
165+ uses : softprops/action-gh-release@v2
166+ with :
167+ tag_name : ${{ steps.extract_version.outputs.tag }}
168+ name : codeflash-benchmark ${{ steps.extract_version.outputs.tag }}
169+ body : |
170+ ## What's Changed
171+
172+ Release ${{ steps.extract_version.outputs.version }} of codeflash-benchmark.
173+
174+ **Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.extract_version.outputs.tag }}
175+ draft : false
176+ prerelease : false
177+ generate_release_notes : true
178+ files : |
179+ dist/*
0 commit comments