setup-python/.github/workflows
Ludovic Henry 337b0725b8
feat: Add mirror and mirror-token inputs for custom Python distribution sources (#1302)
* feat: Add `mirror` and `mirror-token` inputs for custom Python distribution sources

Users who need custom CPython builds (internal mirrors, GHES-hosted forks,
special build configurations, compliance builds, air-gapped runners) could not
previously point setup-python at anything other than actions/python-versions.

Adds two new inputs:
- `mirror`: base URL hosting versions-manifest.json and the Python
  distributions it references. Defaults to the existing
  https://raw.githubusercontent.com/actions/python-versions/main.
- `mirror-token`: optional token used to authenticate requests to the mirror.

If `mirror` is a raw.githubusercontent.com/{owner}/{repo}/{branch} URL, the
manifest is fetched via the GitHub REST API (authenticated rate limit applies);
otherwise the action falls back to a direct GET of {mirror}/versions-manifest.json.

Token interaction
-----------------

`token` is never forwarded to arbitrary hosts. Auth resolution is per-URL:

  1. if mirror-token is set, use mirror-token
  2. else if token is set AND the target host is github.com,
     *.github.com, or *.githubusercontent.com, use token
  3. else send no auth

Cases:

  Default (no inputs set)
    mirror = default raw.githubusercontent.com URL, mirror-token empty,
    token = github.token.
    → manifest API call and tarball downloads use `token`.
    Identical to prior behavior.

  Custom raw.githubusercontent.com mirror (e.g. personal fork)
    mirror-token empty, token = github.token.
    → manifest API call and tarball downloads use `token`
      (target hosts are GitHub-owned).

  Custom non-GitHub mirror, no mirror-token
    mirror-token empty, token = github.token.
    → manifest fetched via direct URL (no auth attached),
      tarball downloads use no auth.
    `token` is NOT forwarded to the custom host — this is the
    leak-prevention case.

  Custom non-GitHub mirror with mirror-token
    mirror-token set, token may be set.
    → manifest fetch and tarball downloads use `mirror-token`.

  Custom GitHub mirror with both tokens set
    mirror-token wins. Used for both the manifest API call and
    tarball downloads.

* fix: address mirror review feedback

- scope mirror-token to the mirror host and send it verbatim
- route non-repo mirrors straight to the URL fetch instead of throwing
- authenticate the manifest fetch
- warn on slash branches, and on mirror with PyPy/GraalPy
- memoize mirror validation
- exercise the direct-URL path in the E2E job

Addresses https://github.com/actions/setup-python/pull/1302#issuecomment-5202618946

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: correct mirror warnings, auth scoping, and integration coverage

- only warn about PyPy/GraalPy mirror when a custom mirror is set; the
  action.yml default made the warning fire on every run
- accept the refs/heads/{branch} raw URL form so it routes via the REST
  API instead of tripping the slash-branch warning
- scope mirror-token to the full mirror origin (scheme+host+port) so it
  can't leak to a same-host http download_url
- make an invalid mirror fatal on the auth path, matching getManifestUrl
- fix warning/docs that wrongly claimed the raw fallback is anonymous
- force a manifest fetch in the mirror integration job (check-latest) so
  it actually contacts the mirror instead of using the preinstalled cache

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 17:31:48 -05:00
..
basic-validation.yml Upgrade to node 24 (#1164) 2025-09-03 21:57:37 -05:00
check-dist.yml Upgrade to node 24 (#1164) 2025-09-03 21:57:37 -05:00
codeql-analysis.yml Add and configure ESLint and update configuration for Prettier (#617) 2023-03-09 12:44:56 +02:00
e2e-cache-freethreaded.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
e2e-cache.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
e2e-tests.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
licensed.yml Add and configure ESLint and update configuration for Prettier (#617) 2023-03-09 12:44:56 +02:00
publish-immutable-actions.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
release-new-action-version.yml Bump actions/publish-action from 0.3.0 to 0.4.0 & Documentation update for pip-install input (#1199) 2025-11-12 12:53:30 -06:00
test-graalpy.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
test-pypy.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
test-python-freethreaded.yml Bump actions/checkout from 7.0.0 to 7.0.1 (#1345) 2026-08-19 09:58:13 -05:00
test-python.yml feat: Add mirror and mirror-token inputs for custom Python distribution sources (#1302) 2026-09-08 17:31:48 -05:00
update-config-files.yml Add update-config-files.yml 2023-03-09 11:47:39 +01:00