Skip to content

Commit

Permalink
Only upload weekly tag to PyPi when code changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Wittgen authored and Matthias Wittgen committed Aug 20, 2024
1 parent 4daecf7 commit ae5bcbd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ jobs:
name: sphgeom-sdist
path: dist/*

check-changes:
outputs:
skip: ${{ steps.check.outputs.skip }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if weekly changed
id: check
run: |
prev_tag=$(git tag -l 'w.*' | sort | tail -2 | head -1)
prev_sha=$(git rev-list -1 "$prev_tag")
echo "Previous tag ${prev_tag} (${prev_sha})"
current_tag=${GITHUB_REF#refs/tags/}
current_sha=$(git rev-list -1 "$current_tag")
echo "Current tag ${current_tag} (${current_sha})"
if [ "$current_sha" = "$prev_sha" ]; then
echo "Hashes are identical - Skipping upload"
echo "skip=true" >> "$GITHUB_ENV"
else
echo "Hashes differ - Enable upload"
echo "skip=false" >> "$GITHUB_ENV"
fi
pypi_wheel_build:
strategy:
matrix:
Expand Down Expand Up @@ -110,7 +135,8 @@ jobs:
path: dist/*

pipy_upload:
needs: [pypi_sdist_build, pypi_wheel_build]
needs: [pypi_sdist_build, pypi_wheel_build, check-changes]
if: "!startsWith(github.ref, 'refs/tags/w.') || needs.check-changes.outputs.skip == 'false'"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
Expand Down

0 comments on commit ae5bcbd

Please sign in to comment.