Check CPython releases #1
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: Check CPython releases | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| max_dispatches: | |
| description: "Maximum number of build dispatches (0 = dry run)" | |
| required: false | |
| default: "20" | |
| type: string | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| discover: | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MAX_DISPATCHES: ${{ inputs.max_dispatches || '20' }} | |
| steps: | |
| - name: Enumerate and dispatch | |
| run: | | |
| set -euo pipefail | |
| max="${MAX_DISPATCHES}" | |
| dispatched=0 | |
| dispatched_list="" | |
| # Fetch all v* tags from python/cpython | |
| mapfile -t refs < <(gh api --paginate repos/python/cpython/git/matching-refs/tags/v -q '.[].ref') | |
| for ref in "${refs[@]}"; do | |
| tag="${ref#refs/tags/}" | |
| # Filter: 3.10+, with optional a/b/rc suffix, no dev/post | |
| if [[ ! "$tag" =~ ^v(3\.(1[0-9]|[2-9][0-9]))\.([0-9]+)(a[0-9]+|b[0-9]+|rc[0-9]+)?$ ]]; then | |
| continue | |
| fi | |
| minor_int="${BASH_REMATCH[2]}" | |
| # Normalise | |
| normalised="${tag#v}" | |
| normalised="$(echo "$normalised" | sed -E 's/a([0-9]+)$/-alpha.\1/; s/b([0-9]+)$/-beta.\1/; s/rc([0-9]+)$/-rc.\1/')" | |
| echo "Tag $tag -> release $normalised" | |
| if gh release view "$normalised" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| echo " already released, skipping" | |
| continue | |
| fi | |
| if [ "$dispatched" -ge "$max" ]; then | |
| echo " would dispatch (cap reached)" | |
| continue | |
| fi | |
| ft="false" | |
| if [ "$minor_int" -ge 13 ]; then | |
| ft="true" | |
| fi | |
| echo " dispatching build-python.yml (freethreaded=$ft)" | |
| gh workflow run build-python.yml --repo "$GITHUB_REPOSITORY" \ | |
| -f cpython_tag="$tag" \ | |
| -f freethreaded="$ft" | |
| dispatched=$((dispatched + 1)) | |
| dispatched_list="${dispatched_list}${tag} -> ${normalised} (ft=${ft})"$'\n' | |
| done | |
| echo "" | |
| echo "=== Dispatched $dispatched build(s) ===" | |
| printf '%s' "$dispatched_list" |