Skip to content

Commit

Permalink
Merge pull request #69 from lsst/tickets/DM-42695
Browse files Browse the repository at this point in the history
DM-42695: Only upload weekly tag to PyPi when code changed
  • Loading branch information
mwittgen committed Sep 3, 2024
2 parents 9a700aa + f8af8f1 commit df4d240
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,40 @@ jobs:
name: sphgeom-sdist
path: dist/*

check-changes:
outputs:
skip: ${{ steps.check.outputs.skip }}
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if weekly changed
id: check
run: |
# Get SHA hashes for all weekly tags
weekly_sha=$(git tag -l 'w.*' | while read tag; do
git rev-list -n 1 "${tag}"
done)
# Extract the current tag and its SHA
current_tag=${GITHUB_REF#refs/tags/}
current_sha=$(git rev-list -1 "${current_tag}")
# Count occurrences of the current SHA in the weekly SHA list
n=$(echo "${weekly_sha}" | grep -c "${current_sha}")
echo "Current tag ${current_tag} (${current_sha}) SHA found ${n} time(s)"
# Determine whether to skip the upload based on the count
if [ "${n}" -gt 1 ]; then
echo "Skip upload"
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "Enable upload"
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
pypi_wheel_build:
strategy:
matrix:
Expand Down Expand Up @@ -111,7 +145,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 df4d240

Please sign in to comment.