diff --git a/.github/actions/latest-supported-python/action.yml b/.github/actions/latest-supported-python/action.yml index 5cf3ceac..2d30bc74 100644 --- a/.github/actions/latest-supported-python/action.yml +++ b/.github/actions/latest-supported-python/action.yml @@ -29,18 +29,58 @@ runs: id: python-version shell: bash run: |- + set -euo pipefail + + release_event='${{ github.event_name == 'release' && github.event.action == 'published' }}' + if [[ "$release_event" == 'true' ]]; then + echo "Release workflow detected; selecting the latest stable version already available on PyPI." + version=$( + curl -fsS "https://pypi.org/pypi/msgspec/json" \ + | jq -r ' + .releases + | to_entries + | map( + select( + [ .value[] + | select(.packagetype == "bdist_wheel") + ] | length > 0 + ) + ) + | map(select(.key | test("(a|b|rc)"; "i") | not)) + | map(.key) + | .[] + ' \ + | sort -V \ + | tail -n 1 + ) + + if [[ -z "$version" ]]; then + echo "Failed to find a stable PyPI release with wheels" >&2 + exit 1 + fi + + echo "Selected PyPI release: $version" + else + version='${{ steps.latest-release.outputs.tag }}' + echo "Selected GitHub release: $version" + fi + + pypi_url="https://pypi.org/pypi/msgspec/$version/json" + python_version=$( - curl -s "https://pypi.org/pypi/msgspec/${{ steps.latest-release.outputs.tag }}/json" \ + curl -fsS "$pypi_url" \ | jq -r ' - [ .urls[] - | select(.packagetype == "bdist_wheel") - | .filename - | capture("cp(?[0-9]+)").cp - | tonumber - ] + .urls + | [ .[] + | select(.packagetype == "bdist_wheel") + | .filename + | capture("cp(?[0-9]+)").cp + | tonumber + ] | max | "3.\(tostring | .[1:])" ' ) + echo "Python version: $python_version" echo "version=$python_version" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c224448..742b476d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,12 @@ on: - MANIFEST.in # Changes to CI execution - .github/workflows/ci.yml + - .github/workflows/prepare-build.yml + - .github/workflows/build-wheels.yml - .github/workflows/profile.yml + - .github/actions/latest-supported-python/action.yml + - .github/actions/fetch-release-history/action.yml + - .github/actions/load-env/action.yml - .cibuildwheel.toml - .justfile # Changes to testing