@@ -2,29 +2,87 @@ name: "Publish"
22
33on :
44 push :
5- tags :
6- # Publish on any tag starting with a `v`, e.g., v0.1.0
7- - v*
5+ branches :
6+ - main
7+ paths :
8+ - ' codeflash/version.py'
89
910jobs :
10- run :
11+ publish :
1112 runs-on : ubuntu-latest
1213 environment :
1314 name : pypi
1415 permissions :
1516 id-token : write
16- contents : read
17+ contents : write # Changed from ' read' to 'write' to allow tag creation
1718 steps :
1819 - name : Checkout
1920 uses : actions/checkout@v5
21+ with :
22+ fetch-depth : 0 # Fetch all history for proper versioning
23+
24+ - name : Extract version from version.py
25+ id : extract_version
26+ run : |
27+ VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash/version.py)
28+ echo "version=$VERSION" >> $GITHUB_OUTPUT
29+ echo "tag=v$VERSION" >> $GITHUB_OUTPUT
30+ echo "Extracted version: $VERSION"
31+
32+ - name : Check if tag already exists
33+ id : check_tag
34+ run : |
35+ if git rev-parse "v${{ steps.extract_version.outputs.version }}" >/dev/null 2>&1; then
36+ echo "exists=true" >> $GITHUB_OUTPUT
37+ echo "Tag v${{ steps.extract_version.outputs.version }} already exists, skipping release"
38+ else
39+ echo "exists=false" >> $GITHUB_OUTPUT
40+ echo "Tag v${{ steps.extract_version.outputs.version }} does not exist, proceeding with release"
41+ fi
42+
43+ - name : Create and push git tag
44+ if : steps.check_tag.outputs.exists == 'false'
45+ run : |
46+ git config user.name "github-actions[bot]"
47+ git config user.email "github-actions[bot]@users.noreply.github.com"
48+ git tag -a "${{ steps.extract_version.outputs.tag }}" -m "Release ${{ steps.extract_version.outputs.tag }}"
49+ git push origin "${{ steps.extract_version.outputs.tag }}"
50+
2051 - name : Install uv
52+ if : steps.check_tag.outputs.exists == 'false'
2153 uses : astral-sh/setup-uv@v6
54+
2255 - name : Build
56+ if : steps.check_tag.outputs.exists == 'false'
2357 run : uv build
58+
2459 # Check that basic features work and we didn't miss to include crucial files
2560 - name : Smoke test (wheel)
61+ if : steps.check_tag.outputs.exists == 'false'
2662 run : uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
63+
2764 - name : Smoke test (source distribution)
65+ if : steps.check_tag.outputs.exists == 'false'
2866 run : uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
29- - name : Publish
30- run : uv publish
67+
68+ - name : Publish to PyPI
69+ if : steps.check_tag.outputs.exists == 'false'
70+ run : uv publish
71+
72+ - name : Create GitHub Release
73+ if : steps.check_tag.outputs.exists == 'false'
74+ uses : softprops/action-gh-release@v2
75+ with :
76+ tag_name : ${{ steps.extract_version.outputs.tag }}
77+ name : Release ${{ steps.extract_version.outputs.tag }}
78+ body : |
79+ ## What's Changed
80+
81+ Release ${{ steps.extract_version.outputs.version }} of codeflash.
82+
83+ **Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.extract_version.outputs.tag }}
84+ draft : false
85+ prerelease : false
86+ generate_release_notes : true
87+ files : |
88+ dist/*
0 commit comments