Skip to content

v3.0.2

v3.0.2 #27

Workflow file for this run

name: Release
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# Install all dependencies from pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatchling==1.27.0
pip install hatch==1.14.0
- name: Get Version
id: version
run: |
RAW_VERSION=$(hatch version)
echo "VERSION=$RAW_VERSION" >> $GITHUB_ENV
if [ "v$RAW_VERSION" != "${{ github.ref_name }}" ]; then
echo "Error: Git tag (${{ github.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/[email protected]
- name: Verify package is installable
id: verify_package
env:
VERSION: ${{ env.VERSION }}
run: |
for i in {1..30}; do
if pip install socketdev==${VERSION}; then
echo "Package ${VERSION} is now available and installable on PyPI"
pip uninstall -y socketdev
echo "success=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
sleep 20
done
echo "success=false" >> $GITHUB_OUTPUT
exit 1