Support all valid PHP version file values (#1121)

* Support all valid PHP version file values

Allow version files to use partial versions and aliases accepted by the
php-version input while preserving support for both plain .php-version
files and asdf-style php entries.

* Regenerate bundled action

---------

Co-authored-by: Shivam Mathur <shivam_jpr@hotmail.com>
This commit is contained in:
Sviatoslav Abakumov
2026-09-17 20:17:54 +05:30
committed by GitHub
co-authored by Shivam Mathur
parent e3f88f3ca7
commit 0bbee91078
3 changed files with 8 additions and 2 deletions
+6
View File
@@ -334,6 +334,12 @@ describe('Utils tests', () => {
readFileSync.mockReturnValue('ruby 1.2.3\nphp 8.4.2\nnode 20.1.2');
expect(await utils.readPHPVersion()).toBe('8.4.2');
readFileSync.mockReturnValue('ruby 1.2.3\nphp 8.4\nnode 20.1.2');
expect(await utils.readPHPVersion()).toBe('8.4');
readFileSync.mockReturnValue('ruby 1.2.3\nphp latest\nnode 20.1.2');
expect(await utils.readPHPVersion()).toBe('latest');
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('setup-php');
await expect(utils.readPHPVersion()).rejects.toThrow('Invalid PHP version');
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -535,7 +535,7 @@ export async function readPHPVersion(): Promise<string> {
(await getInput('php-version-file', false)) || '.php-version';
if (fs.existsSync(versionFile)) {
const contents: string = fs.readFileSync(versionFile, 'utf8');
const match = contents.match(/^(?:php\s)?(\d+\.\d+\.\d+)$/m);
const match = contents.match(/^(?:php\s)?(\S+)$/m);
return validatePHPVersionInput(
match ? match[1] : contents.trim(),
versionFile