v3.5.0 #56
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.13' | |
| - name: Install build tooling | |
| uses: ./.github/actions/setup-hatch | |
| - name: Get Version | |
| id: version | |
| env: | |
| REF_NAME: ${{ github.ref_name }} | |
| run: | | |
| RAW_VERSION=$(hatch version) | |
| echo "VERSION=$RAW_VERSION" >> "$GITHUB_ENV" | |
| if [ "v$RAW_VERSION" != "$REF_NAME" ]; then | |
| echo "Error: Git tag ($REF_NAME) does not match hatch version (v$RAW_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Check if version exists on PyPI | |
| id: version_check | |
| env: | |
| VERSION: ${{ env.VERSION }} | |
| run: | | |
| if curl -s -f "https://pypi.org/pypi/socketdev/$VERSION/json" > /dev/null; then | |
| echo "Version ${VERSION} already exists on PyPI" | |
| echo "pypi_exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Version ${VERSION} not found on PyPI - proceeding with PyPI deployment" | |
| echo "pypi_exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build package | |
| if: steps.version_check.outputs.pypi_exists != 'true' | |
| run: | | |
| hatch build | |
| - name: Publish to PyPI | |
| if: steps.version_check.outputs.pypi_exists != 'true' | |
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | |
| - name: Verify package is installable | |
| id: verify_package | |
| env: | |
| VERSION: ${{ env.VERSION }} | |
| run: | | |
| # The first lookup can race PyPI's Simple-index propagation, and a delayed | |
| # CDN purge can leave the index stale well after a successful upload. | |
| # pip caches HTTP responses by default, so without --no-cache-dir every | |
| # retry can reuse that initial stale response instead of checking whether | |
| # the release has appeared. Budget: 30 minutes. | |
| MAX_ATTEMPTS=60 | |
| for i in $(seq 1 "$MAX_ATTEMPTS"); do | |
| if python -m pip install \ | |
| --no-cache-dir \ | |
| --index-url https://pypi.org/simple/ \ | |
| "socketdev==${VERSION}"; then | |
| echo "Package ${VERSION} is now available and installable on PyPI" | |
| python -m pip uninstall -y socketdev | |
| echo "success=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if curl -s -f "https://pypi.org/pypi/socketdev/${VERSION}/json" > /dev/null; then | |
| echo "Release ${VERSION} exists on PyPI (JSON API) but is not in the Simple index yet - CDN propagation delay" | |
| fi | |
| if [ "$i" -lt "$MAX_ATTEMPTS" ]; then | |
| echo "Attempt $i: Package not yet installable, waiting 30s... (${i}/${MAX_ATTEMPTS})" | |
| sleep 30 | |
| fi | |
| done | |
| echo "success=false" >> "$GITHUB_OUTPUT" | |
| exit 1 |