From 7a389afdfffe16ab775aaeae3668a1308f1edbdb Mon Sep 17 00:00:00 2001 From: Eric Hibbs Date: Wed, 6 Nov 2024 17:48:24 -0800 Subject: [PATCH] trying a more deterministic approach to package version verification --- .github/workflows/pr-preview.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 2596963..9c9eb1f 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -103,25 +103,28 @@ jobs: env: VERSION: ${{ env.VERSION }} run: | - # Wait for package to be available (try up to 30 times with 20s delay - total 10 minutes) for i in {1..30}; do - if curl -s -f https://test.pypi.org/pypi/socketsecurity/$VERSION/json > /dev/null; then - echo "Package ${VERSION} is now available on Test PyPI" + if pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==${VERSION}; then + echo "Package ${VERSION} is now available and installable on Test PyPI" + pip uninstall -y socketsecurity + echo "success=true" >> $GITHUB_OUTPUT exit 0 fi - echo "Attempt $i: Package not yet available, waiting 20s... (${i}/30)" + echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)" sleep 20 done - echo "Package ${VERSION} not available after 10 minutes" + echo "success=false" >> $GITHUB_OUTPUT exit 1 - name: Login to Docker Hub + if: steps.verify_package.outputs.success == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build & Push Docker Preview + if: steps.verify_package.outputs.success == 'true' uses: docker/build-push-action@v5 env: VERSION: ${{ env.VERSION }}