Skip to content

Commit eeef7f4

Browse files
committed
feat: compact README status table and add OS version
1 parent 740ce90 commit eeef7f4

File tree

2 files changed

+266
-150
lines changed

2 files changed

+266
-150
lines changed

index.js

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ async function detectToolVersion(tool) {
8888
const { stdout, stderr, exitCode } = await execCapture(cmd, args);
8989
const combined = `${stdout}\n${stderr}`.trim();
9090
const line = firstLine(stdout) || firstLine(stderr);
91+
9192
if (exitCode !== 0 && isNotFoundMessage(combined || line)) return 'Not found';
9293
if (exitCode !== 0 && !line) return 'Unknown';
94+
9395
const ver = pickFirstVersionLike(combined) || pickFirstVersionLike(line);
9496
return ver || line || 'Unknown';
9597
};
@@ -101,6 +103,49 @@ async function detectToolVersion(tool) {
101103
return null;
102104
}
103105

106+
async function detectOSInfo() {
107+
const runnerOs = process.env.RUNNER_OS || '';
108+
109+
if (runnerOs === 'Linux') {
110+
const { stdout } = await execCapture('bash', [
111+
'-c',
112+
'source /etc/os-release 2>/dev/null && echo "${ID:-linux}|${VERSION_ID:-}" || echo "linux|"',
113+
]);
114+
const line = firstLine(stdout);
115+
const [idRaw, verRaw] = String(line || 'linux|').split('|');
116+
const id = (idRaw || 'linux').trim();
117+
const version = (verRaw || '').trim();
118+
const family = id === 'ubuntu' ? 'ubuntu' : id;
119+
const label = version ? `${family} ${version}` : family;
120+
return { family, version, label };
121+
}
122+
123+
if (runnerOs === 'macOS') {
124+
const v = await execCapture('sw_vers', ['-productVersion']);
125+
const version = firstLine(v.stdout) || '';
126+
const family = 'macos';
127+
const label = version ? `macos ${version}` : 'macos';
128+
return { family, version, label };
129+
}
130+
131+
if (runnerOs === 'Windows') {
132+
const { stdout } = await execCapture('powershell', [
133+
'-NoProfile',
134+
'-Command',
135+
'$os=(Get-CimInstance Win32_OperatingSystem); "$($os.Caption)|$($os.Version)"',
136+
]);
137+
const line = firstLine(stdout);
138+
const [caption, ver] = String(line || 'Windows|').split('|');
139+
const family = 'windows';
140+
const version = (ver || '').trim();
141+
const shortCaption = (caption || 'Windows').replace(/^Microsoft\s+/i, '').trim();
142+
const label = version ? `${shortCaption} ${version}` : shortCaption;
143+
return { family, version, label };
144+
}
145+
146+
return { family: (runnerOs || 'unknown').toLowerCase(), version: '', label: runnerOs || 'unknown' };
147+
}
148+
104149
function ghRequestJson(url, token) {
105150
return new Promise((resolve, reject) => {
106151
const u = new URL(url);
@@ -186,6 +231,8 @@ async function run() {
186231
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || '';
187232
let jobInfo = null;
188233

234+
const osInfo = await detectOSInfo();
235+
189236
const metaBase = {
190237
schema_version: 1,
191238
repo: process.env.GITHUB_REPOSITORY || '',
@@ -196,6 +243,9 @@ async function run() {
196243
os: process.env.RUNNER_OS || '',
197244
arch: process.env.RUNNER_ARCH || '',
198245
name: process.env.RUNNER_NAME || '',
246+
os_family: osInfo.family,
247+
os_version: osInfo.version,
248+
os_label: osInfo.label,
199249
},
200250
compiler: {
201251
requested: compiler,
@@ -257,8 +307,15 @@ async function run() {
257307

258308
await summary
259309
.addTable([
260-
['OS', 'Compiler', 'Version'],
261-
[platformInput, compiler, metaBase.compiler.actual_version],
310+
['OS', 'OS Version', 'Compiler', 'Version', 'Tool', 'Tool Version'],
311+
[
312+
metaBase.runner.os_family || metaBase.runner.os,
313+
metaBase.runner.os_version || metaBase.runner.os_label,
314+
compiler,
315+
metaBase.compiler.actual_version,
316+
metaBase.tool || '-',
317+
metaBase.tool ? (metaBase.tools?.[metaBase.tool]?.version || 'Unknown') : '-',
318+
],
262319
])
263320
.write();
264321
} catch (err) {

0 commit comments

Comments
 (0)