ci: merge release table instead of overwriting on single-distro builds

The release step now fetches the existing release body and merges the
new distro rows into it, instead of rebuilding the table from scratch.
This means a single-distro build (e.g. --distro fedora) only updates
that distro's row and checksum — all other distros stay in the table.

Previously, every single-distro CI run wiped the other distros from
the release page, requiring a manual API patch each time.

[skip ci]
This commit is contained in:
Bug Bounty Zip
2026-06-14 00:30:19 +08:00
parent 177cc5cfbf
commit 76d3ba281e

View File

@@ -139,41 +139,94 @@ jobs:
- name: Prepare release body - name: Prepare release body
id: body id: body
run: | uses: actions/github-script@v8
KVER=$(cat meta/kver) with:
PSHA=$(cat meta/psha) script: |
TS=$(cat meta/ts) const fs = require('fs');
SUMS=$(cat meta/*.sha256) const path = require('path');
{ const kver = fs.readFileSync('meta/kver', 'utf8').trim();
echo 'text<<EOF' const psha = fs.readFileSync('meta/psha', 'utf8').trim();
echo "PS5 Linux images — built from latest \`main\`." const ts = fs.readFileSync('meta/ts', 'utf8').trim();
echo ""
echo "Kernel: \`$KVER\`" // Collect new checksums from this run
echo "Patches: [\`$PSHA\`](https://github.com/ps5-linux/ps5-linux-patches/commit/$PSHA)" const newSums = {};
echo "Built: \`$TS\`" for (const f of fs.readdirSync('meta').filter(f => f.endsWith('.sha256'))) {
echo "" const distro = f.replace('.sha256', '');
echo "| Image | Download |" newSums[distro] = fs.readFileSync(path.join('meta', f), 'utf8').trim();
echo "|-------|----------|" }
echo "| Ubuntu 26.04 | [\`ps5-ubuntu2604.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-ubuntu2604.img.xz) |"
echo "| Arch | [\`ps5-arch.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-arch.img.xz) |" // All known distros and their display names (order = table order)
echo "| CachyOS | [\`ps5-cachyos.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-cachyos.img.xz) |" const R2 = 'https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev';
if [ -f meta/kali.sha256 ]; then const ALL_DISTROS = [
echo "| Kali | [\`ps5-kali.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-kali.img.xz) |" { key: 'ubuntu2604', label: 'Ubuntu 26.04', file: 'ps5-ubuntu2604.img.xz' },
fi { key: 'arch', label: 'Arch', file: 'ps5-arch.img.xz' },
if [ -f meta/fedora.sha256 ]; then { key: 'cachyos', label: 'CachyOS', file: 'ps5-cachyos.img.xz' },
echo "| Fedora 44 | [\`ps5-fedora.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-fedora.img.xz) |" { key: 'kali', label: 'Kali', file: 'ps5-kali.img.xz' },
fi { key: 'fedora', label: 'Fedora 44', file: 'ps5-fedora.img.xz' },
if [ -f meta/proxmox.sha256 ]; then { key: 'proxmox', label: 'Proxmox VE 8', file: 'ps5-proxmox.img.xz' },
echo "| Proxmox VE 8 | [\`ps5-proxmox.img.xz\`](https://pub-561df4012f1a46fbbdf618d5cc5941f6.r2.dev/ps5-proxmox.img.xz) |" { key: 'debian', label: 'Debian 12', file: 'ps5-debian.img.xz' },
fi ];
echo ""
echo "**SHA256 checksums:**" // Fetch existing release body to preserve distros not built this run
echo "\`\`\`" const existingSums = {};
echo "$SUMS" try {
echo "\`\`\`" const { data: rel } = await github.rest.repos.getReleaseByTag({
echo 'EOF' ...context.repo, tag: 'latest',
} >> "$GITHUB_OUTPUT" });
// Extract existing checksum lines (format: "hash filename")
const sumBlock = (rel.body || '').match(/```\n([\s\S]*?)```/);
if (sumBlock) {
for (const line of sumBlock[1].trim().split('\n')) {
const m = line.match(/^(\w+)\s+ps5-(\S+)\.img\.xz$/);
if (m) existingSums[m[2]] = line.trim();
}
}
// Also preserve distros that appear in the table even without checksums
for (const d of ALL_DISTROS) {
if (rel.body && rel.body.includes(d.file) && !existingSums[d.key]) {
existingSums[d.key] = '';
}
}
} catch (e) {
core.info('No existing release found, starting fresh');
}
// Merge: new checksums override existing ones
const mergedSums = { ...existingSums };
for (const [k, v] of Object.entries(newSums)) {
mergedSums[k] = v;
}
// Build the table — only include distros that have been built at least once
const rows = ALL_DISTROS
.filter(d => d.key in mergedSums || d.key in newSums)
.map(d => `| ${d.label} | [\`${d.file}\`](${R2}/${d.file}) |`);
// Combine all checksum lines
const allSumLines = ALL_DISTROS
.filter(d => mergedSums[d.key])
.map(d => mergedSums[d.key])
.join('\n');
const body = [
'PS5 Linux images — built from latest `main`.',
'',
`Kernel: \`${kver}\``,
`Patches: [\`${psha}\`](https://github.com/ps5-linux/ps5-linux-patches/commit/${psha})`,
`Built: \`${ts}\``,
'',
'| Image | Download |',
'|-------|----------|',
...rows,
'',
'**SHA256 checksums:**',
'```',
allSumLines,
'```',
].join('\n');
core.setOutput('text', body);
- name: Move latest tag to current commit - name: Move latest tag to current commit
uses: actions/github-script@v8 uses: actions/github-script@v8