Update .github/workflows/release.yml
/ build (push) Successful in 39s

This commit is contained in:
2026-06-19 23:33:10 +08:00
Partially verified
parent d94d400182
commit c0729302e6
+48
View File
@@ -18,6 +18,54 @@ jobs:
steps:
- uses: https://github.bibk.top/actions/checkout@v4
- name: Regenerate UUIDs
shell: powershell # 兼容 PowerShell 5.1
env:
RP_SOURCE: ${{ env.RP_SOURCE }}
BP_SOURCE: ${{ env.BP_SOURCE }}
run: |
$jsCode = @"
const fs = require('fs');
const crypto = require('crypto');
const path = require('path');
const genUUID = () => crypto.randomUUID();
const rpHeader = genUUID();
const bpHeader = genUUID();
console.log('Generated RP Header UUID: ' + rpHeader);
console.log('Generated BP Header UUID: ' + bpHeader);
function processManifest(filePath, isRP) {
if (!fs.existsSync(filePath)) {
console.log('Warning: File not found: ' + filePath);
return;
}
let manifest = JSON.parse(fs.readFileSync(filePath, 'utf8'));
manifest.header.uuid = isRP ? rpHeader : bpHeader;
if (manifest.modules) {
manifest.modules.forEach(mod => {
if (mod.uuid) mod.uuid = genUUID();
});
}
if (manifest.dependencies) {
manifest.dependencies.forEach(dep => {
if (dep.uuid) {
dep.uuid = isRP ? bpHeader : rpHeader;
}
});
}
fs.writeFileSync(filePath, JSON.stringify(manifest, null, 4), 'utf8');
console.log('✅ Successfully updated: ' + filePath);
}
const rpDir = process.env.RP_SOURCE || 'packs/RP';
const bpDir = process.env.BP_SOURCE || 'packs/BP';
processManifest(path.join(rpDir, 'manifest.json'), true);
processManifest(path.join(bpDir, 'manifest.json'), false);
"@
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText("$PWD\update_uuids.js", $jsCode, $utf8NoBom)
node update_uuids.js
Remove-Item update_uuids.js -Force
- name: Package mcaddon
run: |
$VERSION = $env:GITHUB_REF.Split('/')[-1]