Skip to content

Commit 5df8e4e

Browse files
Enhance GitHub Actions workflow to conditionally build and publish the package based on changes in Python files. Added checks to determine if a build is necessary before executing build and publish steps.
1 parent 84c9094 commit 5df8e4e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,43 @@ jobs:
3131
3232
- name: Increment version
3333
run: |
34-
uv venv
34+
uv venv --python 3.12
3535
source .venv/bin/activate
3636
uv pip install --upgrade semver
3737
echo "VERSION=${VERSION}" >> $GITHUB_ENV
3838
NEW_VERSION=$(python -c "import semver; print(semver.bump_patch('${VERSION}'))")
3939
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
40+
41+
- name: Need to build package
42+
# only if cahnges are in .py files
43+
run: |
44+
if git diff --name-only --diff-filter=d | grep -qE '\.py$'; then
45+
echo "BUILD=true" >> $GITHUB_ENV
46+
else
47+
echo "No Python files changed, skipping build"
48+
echo "BUILD=false" >> $GITHUB_ENV
49+
fi
50+
51+
- name: Push changes
52+
run: git push
4053

4154
- name: Update version in __init__.py
4255
run: |
4356
sed -i "s/__version__ = \"${VERSION}\"/__version__ = \"${NEW_VERSION}\"/" syne_sql_extension/__init__.py
4457
4558
- name: Commit changes
4659
run: git config user.name "SyneHQ" && git config user.email "engineering@synehq.com" && git add . && git commit -m "Bump version to ${NEW_VERSION}"
47-
60+
4861
- name: Build package
49-
run: uv build
50-
62+
run: |
63+
if [ "$BUILD" = "true" ]; then
64+
uv build
65+
fi
66+
5167
- name: Publish to PyPI
5268
env:
5369
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
5470
run: |
55-
uv publish
71+
if [ "$BUILD" = "true" ]; then
72+
uv publish
73+
fi

0 commit comments

Comments
 (0)