Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-42695: Only upload weekly tag to PyPi when code changed #69

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading