From 0483a0696eea453f812495dbb5d30f63864748e9 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:36:42 +0200 Subject: [PATCH 01/14] Added new constant with new base URL input and replacing in download URL --- src/install-python.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/install-python.ts b/src/install-python.ts index bef0161c..adcde741 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -13,6 +13,7 @@ const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; +const PYTHON_DOWNLOAD_BASE_URL = core.getInput('python_download_base_url'); export async function findReleaseFromManifest( semanticVersionSpec: string, @@ -124,7 +125,7 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { if (!release.files || release.files.length === 0) { throw new Error('No files found in the release to download.'); } - const downloadUrl = release.files[0].download_url; + const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace("https://github.com/", PYTHON_DOWNLOAD_BASE_URL); core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; From d2dd15a2babd17a58892e0013547d3506e20566c Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:42:35 +0200 Subject: [PATCH 02/14] Added new input --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index e469b7b2..86cdaf02 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,8 @@ inputs: default: false pip-version: description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]." + python_download_base_url: + description: "Used to specify an alternative base URL to download the python releases instead of github.com. The Action will try to download the python releases from /actions/python-versions/releases// outputs: python-version: description: "The installed Python or PyPy version. Useful when given a version range as input." From 66a2194d64527a782c34f0e4b1581ef152137d08 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:46:49 +0200 Subject: [PATCH 03/14] Added missing quote --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 86cdaf02..78e2a231 100644 --- a/action.yml +++ b/action.yml @@ -32,7 +32,7 @@ inputs: pip-version: description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]." python_download_base_url: - description: "Used to specify an alternative base URL to download the python releases instead of github.com. The Action will try to download the python releases from /actions/python-versions/releases// + description: "Used to specify an alternative base URL to download the python releases instead of github.com. The Action will try to download the python releases from /actions/python-versions/releases//" outputs: python-version: description: "The installed Python or PyPy version. Useful when given a version range as input." From 88907341c2b9247bbb7a8531cb88a04e2adc40db Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:39:19 +0200 Subject: [PATCH 04/14] Update install-python.ts --- src/install-python.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/install-python.ts b/src/install-python.ts index adcde741..472b97dc 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -126,7 +126,8 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { throw new Error('No files found in the release to download.'); } const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace("https://github.com/", PYTHON_DOWNLOAD_BASE_URL); - + core.info(`base url "${PYTHON_DOWNLOAD_BASE_URL}") + core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; try { From c712311b50cb53bd96c70837569e758981cf56b2 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Thu, 24 Jul 2025 18:02:41 +0200 Subject: [PATCH 05/14] Update install-python.ts --- src/install-python.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install-python.ts b/src/install-python.ts index 472b97dc..dfa0498f 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -126,7 +126,7 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { throw new Error('No files found in the release to download.'); } const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace("https://github.com/", PYTHON_DOWNLOAD_BASE_URL); - core.info(`base url "${PYTHON_DOWNLOAD_BASE_URL}") + core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; From 19fd8ef7d86c7f609df984707de79b84148b6453 Mon Sep 17 00:00:00 2001 From: Pablo Gomez Date: Wed, 13 Aug 2025 16:53:18 +0200 Subject: [PATCH 06/14] chore(format): run prettier on install-python.ts --- src/install-python.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/install-python.ts b/src/install-python.ts index dfa0498f..14362ca1 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -125,9 +125,13 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { if (!release.files || release.files.length === 0) { throw new Error('No files found in the release to download.'); } - const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace("https://github.com/", PYTHON_DOWNLOAD_BASE_URL); - - + const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL + ? release.files[0].download_url + : release.files[0].download_url.replace( + 'https://github.com/', + PYTHON_DOWNLOAD_BASE_URL + ); + core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; try { From a5dada8afdb5ceaedf7ce6bd6d2b7cb002192f7c Mon Sep 17 00:00:00 2001 From: Pablo Gomez Date: Fri, 15 Aug 2025 16:33:53 +0200 Subject: [PATCH 07/14] Added index.js in dist --- dist/setup/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 2f06fb35..b62b73dc 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -97762,6 +97762,7 @@ const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; +const PYTHON_DOWNLOAD_BASE_URL = core.getInput('python_download_base_url'); function findReleaseFromManifest(semanticVersionSpec, architecture, manifest) { return __awaiter(this, void 0, void 0, function* () { if (!manifest) { @@ -97852,7 +97853,9 @@ function installCpythonFromRelease(release) { if (!release.files || release.files.length === 0) { throw new Error('No files found in the release to download.'); } - const downloadUrl = release.files[0].download_url; + const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL + ? release.files[0].download_url + : release.files[0].download_url.replace('https://github.com/', PYTHON_DOWNLOAD_BASE_URL); core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; try { From 47a081effe0d9a7339bea8b212bee6c38e024a7a Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:33:16 +0200 Subject: [PATCH 08/14] Update advanced-usage.md --- docs/advanced-usage.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 188fa9d6..734d0280 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -623,7 +623,12 @@ One quick way to grant access is to change the user and group of `/Users/runner/ ### No access to github.com -If the runner is not able to access github.com, any Python versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. +If the runner is not able to access github.com, any Python versions requested during a workflow run must come from the runner's tool cache or defining and alternative mirror to download the distributions. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. + +### Using an alternative location to download Python distributions + +If it is not an option for you to add the Python distributions in the runner's tool cache, another option is to have some mirror or files repository in your company network. You can define the mirror URL using the input `python_download_base_url`. The mirror must be setup in such a way that the Python distributions are available with the format `/actions/python-versions/releases//`. For example `/actions/python-versions/releases/download/3.10.18-15433209320/python-3.10.18-linux-22.04-x64.tar.gz` + ## Allow pre-releases @@ -671,4 +676,4 @@ The version of Pip should be specified in the format `major`, `major.minor`, or ``` > The `pip-version` input is supported only with standard Python versions. It is not available when using PyPy or GraalPy. -> Using a specific or outdated version of pip may result in compatibility or security issues and can cause job failures. For best practices and guidance, refer to the official [pip documentation](https://pip.pypa.io/en/stable/). \ No newline at end of file +> Using a specific or outdated version of pip may result in compatibility or security issues and can cause job failures. For best practices and guidance, refer to the official [pip documentation](https://pip.pypa.io/en/stable/). From 825358b22b06b7addeb0fbe49f5b1bad90386acd Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:46:38 +0200 Subject: [PATCH 09/14] Replace longer part of download URL --- src/install-python.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install-python.ts b/src/install-python.ts index 14362ca1..42b51130 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -128,7 +128,7 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace( - 'https://github.com/', + 'https://github.com/actions/python-versions/releases', PYTHON_DOWNLOAD_BASE_URL ); From 736c77b72f1e3ac00931e585e7254e3f3053f685 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:48:27 +0200 Subject: [PATCH 10/14] Fixed input description --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 78e2a231..c268dc34 100644 --- a/action.yml +++ b/action.yml @@ -32,7 +32,7 @@ inputs: pip-version: description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]." python_download_base_url: - description: "Used to specify an alternative base URL to download the python releases instead of github.com. The Action will try to download the python releases from /actions/python-versions/releases//" + description: "Used to specify an alternative base URL to download the python releases instead of github.com. The Action will try to download the python releases from //" outputs: python-version: description: "The installed Python or PyPy version. Useful when given a version range as input." From 3f9a0c2480bdf6b19e47fb326d9efeb89a896dbe Mon Sep 17 00:00:00 2001 From: Pablo Gomez Date: Fri, 15 Aug 2025 17:55:38 +0200 Subject: [PATCH 11/14] Committing changes to dist/setup/index.js after build --- dist/setup/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index b62b73dc..a7ced0b2 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -97855,7 +97855,7 @@ function installCpythonFromRelease(release) { } const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url - : release.files[0].download_url.replace('https://github.com/', PYTHON_DOWNLOAD_BASE_URL); + : release.files[0].download_url.replace('https://github.com/actions/python-versions/releases', PYTHON_DOWNLOAD_BASE_URL); core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; try { From 916f37ea976ec58b2bf1b75a103accff96343636 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:02:04 +0200 Subject: [PATCH 12/14] Update alternative location documentation --- docs/advanced-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 734d0280..ad7bb785 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -627,7 +627,7 @@ If the runner is not able to access github.com, any Python versions requested du ### Using an alternative location to download Python distributions -If it is not an option for you to add the Python distributions in the runner's tool cache, another option is to have some mirror or files repository in your company network. You can define the mirror URL using the input `python_download_base_url`. The mirror must be setup in such a way that the Python distributions are available with the format `/actions/python-versions/releases//`. For example `/actions/python-versions/releases/download/3.10.18-15433209320/python-3.10.18-linux-22.04-x64.tar.gz` +If it is not an option for you to add the Python distributions in the runner's tool cache, another option is to have some mirror or files repository in your company network. You can define the mirror URL using the input `python_download_base_url`. The mirror must be setup in such a way that the Python distributions are available with the format `//`. For example `/3.10.18-15433209320/python-3.10.18-linux-22.04-x64.tar.gz` From 55cba3512afe0fa76f7335cd841df747fd032dc6 Mon Sep 17 00:00:00 2001 From: GolanTrevize10 <25170481+GolanTrevize10@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:03:14 +0200 Subject: [PATCH 13/14] Adjusted the URL replaced part again --- src/install-python.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install-python.ts b/src/install-python.ts index 42b51130..7e1e5354 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -128,7 +128,7 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) { const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url : release.files[0].download_url.replace( - 'https://github.com/actions/python-versions/releases', + 'https://github.com/actions/python-versions/releases/download', PYTHON_DOWNLOAD_BASE_URL ); From 656324a07e5b7bb9d7433611c71602f52299436e Mon Sep 17 00:00:00 2001 From: Pablo Gomez Date: Fri, 15 Aug 2025 18:04:07 +0200 Subject: [PATCH 14/14] Updated index.js after build --- dist/setup/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index a7ced0b2..abd8261d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -97855,7 +97855,7 @@ function installCpythonFromRelease(release) { } const downloadUrl = !PYTHON_DOWNLOAD_BASE_URL ? release.files[0].download_url - : release.files[0].download_url.replace('https://github.com/actions/python-versions/releases', PYTHON_DOWNLOAD_BASE_URL); + : release.files[0].download_url.replace('https://github.com/actions/python-versions/releases/download', PYTHON_DOWNLOAD_BASE_URL); core.info(`Download from "${downloadUrl}"`); let pythonPath = ''; try {