From c0729302e6374b9d3663db229e428c13e6005f4e Mon Sep 17 00:00:00 2001 From: wed150 Date: Fri, 19 Jun 2026 23:33:10 +0800 Subject: [PATCH] Update .github/workflows/release.yml --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a048f52..88a9d3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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]