diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9456158..01bfedd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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_ENV}" + else + echo "Enable upload" + echo "skip=false" >> "${GITHUB_ENV}" + fi + pypi_wheel_build: strategy: matrix: @@ -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