mirror of
https://github.com/actions/setup-python.git
synced 2026-07-20 08:49:58 +08:00
Add RHEL support and include Linux distro in cache keys (#1323)
* Add RHEL support for manifest matching and OS detection * update dist * make cache keys distro-aware and key RHEL by major version * Normalize RHEL OS detection and improve cache key consistency * Refactor OS info retrieval to use getOSInfo and handle null cases for improved reliability
This commit is contained in:
parent
c8813ba1bc
commit
0cb1a84326
9 changed files with 5612 additions and 52 deletions
35
src/utils.ts
35
src/utils.ts
|
|
@ -173,15 +173,38 @@ async function getMacOSInfo() {
|
|||
}
|
||||
|
||||
export async function getLinuxInfo() {
|
||||
const {stdout} = await exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
|
||||
silent: true
|
||||
});
|
||||
try {
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'lsb_release',
|
||||
['-i', '-r', '-s'],
|
||||
{
|
||||
silent: true
|
||||
}
|
||||
);
|
||||
|
||||
const [osName, osVersion] = stdout.trim().split('\n');
|
||||
const [osName, osVersion] = stdout.trim().split('\n');
|
||||
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
|
||||
return {osName, osVersion};
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`lsb_release failed (${(err as Error).message}). Falling back to /etc/os-release.`
|
||||
);
|
||||
|
||||
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
|
||||
const osReleaseContent = fs.readFileSync('/etc/os-release', 'utf8');
|
||||
const osInfo: {[key: string]: string} = {};
|
||||
|
||||
return {osName: osName, osVersion: osVersion};
|
||||
osReleaseContent.split('\n').forEach(line => {
|
||||
const [key, value] = line.split('=');
|
||||
if (key && value) {
|
||||
osInfo[key.trim()] = value.trim().replace(/"/g, '');
|
||||
}
|
||||
});
|
||||
|
||||
const osName = osInfo['ID'] || 'Linux';
|
||||
const osVersion = osInfo['VERSION_ID'] || '';
|
||||
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
|
||||
return {osName, osVersion};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOSInfo() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue