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:
Priya Gupta
2026-06-19 05:17:28 +05:30
committed by GitHub
parent c8813ba1bc
commit 0cb1a84326
9 changed files with 5612 additions and 52 deletions
@@ -1,5 +1,6 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {getOSInfo, IS_LINUX} from '../utils';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
export enum State {
@@ -22,6 +23,33 @@ abstract class CacheDistributor {
}>;
protected async handleLoadedCache() {}
/**
* Builds the Linux distro portion of a cache key (e.g. `-26.04-Ubuntu`, `-9-rhel`).
* RHEL is keyed by major version since it ships one ABI-stable artifact per major.
*/
protected async getLinuxInfoKeySegment(): Promise<string> {
if (!IS_LINUX) {
return '';
}
const osInfo = await getOSInfo();
if (!osInfo) {
return '';
}
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
const normalizedName = osInfo.osName.toLowerCase();
const isRhel =
normalizedName === 'rhel' || normalizedName.includes('redhat');
const osName = isRhel ? 'rhel' : osInfo.osName;
const osVersion = isRhel
? osInfo.osVersion.split('.')[0]
: osInfo.osVersion;
return `-${osVersion}-${osName}`;
}
public async restoreCache() {
const {primaryKey, restoreKey} = await this.computeKeys();
if (primaryKey.endsWith('-')) {