From 5e394b1abbc2d481234084a34ed9f253166f192f Mon Sep 17 00:00:00 2001 From: Matthias Wittgen Date: Tue, 20 Aug 2024 16:35:57 -0700 Subject: [PATCH] Only upload weekly tag to PyPi when code changed --- .github/workflows/build.yaml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9456158..7465efe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -66,6 +66,32 @@ 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: | + 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 "Skip upload" + echo "skip=true" >> "$GITHUB_ENV" + else + echo "Enable upload" + echo "skip=false" >> "$GITHUB_ENV" + fi + pypi_wheel_build: strategy: matrix: @@ -111,7 +137,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