1- name : PyUIKit testing + Release
1+ name : PyUIKit Testing + Release
22
33on :
44 push :
@@ -29,10 +29,10 @@ jobs:
2929 - name : Run tests
3030 run : pytest tests
3131
32- # 2️⃣ Release job (runs only if test job passes)
32+ # 2️⃣ Release job
3333 release :
3434 runs-on : ubuntu-latest
35- needs : test # only run if tests passed
35+ needs : test
3636 steps :
3737 - name : Checkout repo
3838 uses : actions/checkout@v4
@@ -50,26 +50,53 @@ jobs:
5050 - name : Get current version from setup.py
5151 id : get_version
5252 run : |
53- VERSION=$(python -c "import re; import setuptools; f=open('setup.py'); print(re.search(r'version\s*=\s*[\"\\'](.+?)[\"\\']', f.read()).group(1))")
54- echo "Version=${ VERSION} " >> $GITHUB_ENV
53+ VERSION=$(python -c "import re; f=open('setup.py'); print(re.search(r'version\s*=\s*[\"\\'](.+?)[\"\\']', f.read()).group(1))")
54+ echo "VERSION=$ VERSION" >> $GITHUB_ENV
5555
56- # in YAML
57- - name : Check if version changed
58- id : version_check
56+ - name : Read release flags
57+ id : release_flags
5958 run : |
60- git fetch --tags # make sure all remote tags are available
61- LAST_TAG=$(git describe --tags --abbrev=0 || echo "0.0.0")
62- echo "Last tag: $LAST_TAG"
63- echo "Current version: $VERSION"
64- if [ "$LAST_TAG" = "v$VERSION" ]; then
65- echo "Version not changed, skipping release."
66- exit 78
67- fi
59+ FLAGS=$(python -c "from release_flag import UPLOAD_TO_PYPI, CREATE_TAG; print(f'{UPLOAD_TO_PYPI},{CREATE_TAG}')")
60+ IFS=',' read UPLOAD TAG <<< "$FLAGS"
61+ echo "UPLOAD_TO_PYPI=$UPLOAD" >> $GITHUB_ENV
62+ echo "CREATE_TAG=$TAG" >> $GITHUB_ENV
6863
6964 - name : Build distribution
65+ if : env.UPLOAD_TO_PYPI == 'True' || env.CREATE_TAG == 'True'
7066 run : python -m build
7167
7268 - name : Publish to PyPI
69+ if : env.UPLOAD_TO_PYPI == 'True'
7370 uses : pypa/gh-action-pypi-publish@release/v1
7471 with :
7572 password : ${{ secrets.PYPI_API_TOKEN }}
73+
74+ - name : Create Git tag
75+ if : env.CREATE_TAG == 'True'
76+ env :
77+ VERSION : ${{ env.VERSION }}
78+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79+ run : |
80+ TAG="v$VERSION"
81+ echo "Creating Git tag $TAG"
82+ git config user.name "github-actions"
83+ git config user.email "actions@github.com"
84+ git tag -a "$TAG" -m "Release $TAG"
85+ git push origin "$TAG"
86+
87+ - name : Create GitHub Release
88+ if : env.CREATE_TAG == 'True'
89+ uses : softprops/action-gh-release@v1
90+ with :
91+ tag_name : v${{ env.VERSION }}
92+ name : Release v${{ env.VERSION }}
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
95+
96+ - name : Upload distributions to GitHub Release
97+ if : env.CREATE_TAG == 'True'
98+ uses : softprops/action-gh-release@v1
99+ with :
100+ files : dist/* # upload all built binaries (.whl and .tar.gz)
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments