提交记录新增.github/workflows/release-platforms.yml+46 −0看文件
修改.github/workflows/release.yml+8 −2看文件
修改.github/workflows/windows-build.yml+0 −2看文件
修改scripts/build-qemu-windows.ps1+1 −1看文件
修改scripts/build-qemu-windows.sh+10 −0看文件
修改scripts/build-windows.ps1+11 −1看文件
新增scripts/bundle-qemu-sources.sh+51 −0看文件
新增scripts/bundle-qemu-sources.test.mjs+34 −0看文件
修改scripts/check-release-readiness.mjs+0 −7看文件
修改scripts/ci-windows-build.ps1+10 −15看文件
修改scripts/package-windows.ps1+3 −2看文件
修改scripts/release-control.mjs+27 −3看文件
修改scripts/release-control.test.mjs+37 −1看文件
| @@ -0,0 +1,46 @@ | ||
| 1 | 新增:name: Build signed release platforms for local macOS assembly | |
| 2 | 新增:on: | |
| 3 | 新增: workflow_dispatch: | |
| 4 | 新增: inputs: | |
| 5 | 新增: ref: | |
| 6 | 新增: description: Exact versioned source commit SHA (same as the locally notarized macOS build) | |
| 7 | 新增: required: true | |
| 8 | 新增: type: string | |
| 9 | 新增:permissions: | |
| 10 | 新增: contents: read | |
| 11 | 新增:concurrency: | |
| 12 | 新增: group: cage-local-assembly-platforms | |
| 13 | 新增: cancel-in-progress: false | |
| 14 | 新增:jobs: | |
| 15 | 新增: validate: | |
| 16 | 新增: if: github.repository == 'Lee-xeo/Claude-Cage' && github.ref == 'refs/heads/main' | |
| 17 | 新增: runs-on: ubuntu-24.04 | |
| 18 | 新增: steps: | |
| 19 | 新增: - name: Require an immutable build source | |
| 20 | 新增: env: | |
| 21 | 新增: BUILD_REF: ${{ inputs.ref }} | |
| 22 | 新增: run: '[[ "$BUILD_REF" =~ ^[0-9a-f]{40}$ ]]' | |
| 23 | 新增: - uses: actions/checkout@v4 | |
| 24 | 新增: with: | |
| 25 | 新增: ref: ${{ inputs.ref }} | |
| 26 | 新增: persist-credentials: false | |
| 27 | 新增: - uses: actions/setup-node@v4 | |
| 28 | 新增: with: | |
| 29 | 新增: node-version: 24 | |
| 30 | 新增: - run: node scripts/check-version.mjs | |
| 31 | 新增: windows: | |
| 32 | 新增: needs: validate | |
| 33 | 新增: if: github.repository == 'Lee-xeo/Claude-Cage' && github.ref == 'refs/heads/main' | |
| 34 | 新增: uses: ./.github/workflows/windows-build.yml | |
| 35 | 新增: with: | |
| 36 | 新增: ref: ${{ inputs.ref }} | |
| 37 | 新增: release: true | |
| 38 | 新增: artifact_name: release-windows | |
| 39 | 新增: linux: | |
| 40 | 新增: needs: validate | |
| 41 | 新增: if: github.repository == 'Lee-xeo/Claude-Cage' && github.ref == 'refs/heads/main' | |
| 42 | 新增: uses: ./.github/workflows/linux-build.yml | |
| 43 | 新增: with: | |
| 44 | 新增: ref: ${{ inputs.ref }} | |
| 45 | 新增: release: true | |
| 46 | 新增: artifact_name: release-linux | |
| @@ -8,6 +8,14 @@ on: | ||
| 8 | 8 | default: prerelease |
| 9 | 9 | type: choice |
| 10 | 10 | options: [prerelease, patch, minor, major] |
| 11 | 新增: version: | |
| 12 | 新增: description: Exact requested version (for example 0.1.7-rc.1); overrides bump | |
| 13 | 新增: required: false | |
| 14 | 新增: type: string | |
| 15 | 新增: notes_path: | |
| 16 | 新增: description: Committed Markdown release notes under docs/ (optional) | |
| 17 | 新增: required: false | |
| 18 | 新增: type: string | |
| 11 | 19 | permissions: |
| 12 | 20 | contents: read |
| 13 | 21 | concurrency: |
| @@ -47,8 +55,6 @@ jobs: | ||
| 47 | 55 | CAGE_ESIGNER_TOTP_SECRET: ${{ secrets.CAGE_ESIGNER_TOTP_SECRET }} |
| 48 | 56 | CAGE_WINDOWS_PFX_BASE64: ${{ secrets.CAGE_WINDOWS_PFX_BASE64 }} |
| 49 | 57 | CAGE_WINDOWS_PFX_PASSWORD: ${{ secrets.CAGE_WINDOWS_PFX_PASSWORD }} |
| 50 | 删除: CAGE_WINDOWS_QEMU_SOURCE_URL: ${{ vars.CAGE_WINDOWS_QEMU_SOURCE_URL }} | |
| 51 | 删除: CAGE_WINDOWS_QEMU_SOURCE_SHA256: ${{ vars.CAGE_WINDOWS_QEMU_SOURCE_SHA256 }} | |
| 52 | 58 | run: node scripts/check-release-readiness.mjs |
| 53 | 59 | - name: Validate versions and release behavior |
| 54 | 60 | run: | |
| @@ -145,8 +145,6 @@ jobs: | ||
| 145 | 145 | CAGE_ESIGNER_TOTP_SECRET: ${{ secrets.CAGE_ESIGNER_TOTP_SECRET }} |
| 146 | 146 | CAGE_WINDOWS_PFX_BASE64: ${{ secrets.CAGE_WINDOWS_PFX_BASE64 }} |
| 147 | 147 | CAGE_WINDOWS_PFX_PASSWORD: ${{ secrets.CAGE_WINDOWS_PFX_PASSWORD }} |
| 148 | 删除: CAGE_WINDOWS_QEMU_SOURCE_URL: ${{ vars.CAGE_WINDOWS_QEMU_SOURCE_URL }} | |
| 149 | 删除: CAGE_WINDOWS_QEMU_SOURCE_SHA256: ${{ vars.CAGE_WINDOWS_QEMU_SOURCE_SHA256 }} | |
| 150 | 148 | run: ./scripts/ci-windows-build.ps1 -Release |
| 151 | 149 | - uses: actions/upload-artifact@v4 |
| 152 | 150 | with: |
| @@ -14,7 +14,7 @@ $DependencyCache = [IO.Path]::GetFullPath($DependencyCache) | ||
| 14 | 14 | $OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory) |
| 15 | 15 | $dependencies = Get-Content (Join-Path $repository 'packaging/windows/dependencies.json') -Raw | ConvertFrom-Json |
| 16 | 16 | $patchDirectory = Join-Path $repository 'patches/qemu' |
| 17 | 删除:$inputs = @((Join-Path $PSScriptRoot 'build-qemu-windows.sh'), $PSCommandPath) + @(Get-ChildItem $patchDirectory -Filter '*.patch' | Sort-Object Name | ForEach-Object FullName) | |
| 17 | 新增:$inputs = @((Join-Path $PSScriptRoot 'build-qemu-windows.sh'), (Join-Path $PSScriptRoot 'bundle-qemu-sources.sh'), $PSCommandPath) + @(Get-ChildItem $patchDirectory -Filter '*.patch' | Sort-Object Name | ForEach-Object FullName) | |
| 18 | 18 | $fingerprintText = $dependencies.qemuSource.hash + $dependencies.qemuKeycodemap.hash + (($inputs | ForEach-Object { (Get-FileHash $_ -Algorithm SHA256).Hash }) -join '') |
| 19 | 19 | $fingerprint = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData([Text.Encoding]::UTF8.GetBytes($fingerprintText))) |
| 20 | 20 | $manifestPath = Join-Path $OutputDirectory 'cage-build.json' |
| @@ -24,14 +24,24 @@ strip "$output_dir"/*.exe | ||
| 24 | 24 | # Copy the DLL dependency closure from this toolchain, using the same versions |
| 25 | 25 | # that were linked into the executables. Windows system DLLs remain system-owned. |
| 26 | 26 | pending=("$output_dir"/*.exe) |
| 27 | 新增:packages=() | |
| 27 | 28 | while ((${#pending[@]})); do |
| 28 | 29 | binary=${pending[0]} |
| 29 | 30 | pending=("${pending[@]:1}") |
| 30 | 31 | while read -r dll; do |
| 31 | 32 | if [[ -f "$MINGW_PREFIX/bin/$dll" && ! -f "$output_dir/$dll" ]]; then |
| 32 | 33 | cp "$MINGW_PREFIX/bin/$dll" "$output_dir/$dll" |
| 34 | 新增: packages+=("$(pacman -Qqo "$MINGW_PREFIX/bin/$dll")") | |
| 33 | 35 | pending+=("$output_dir/$dll") |
| 34 | 36 | fi |
| 35 | 37 | done < <(objdump -p "$binary" | awk '/DLL Name:/ {print $3}') |
| 36 | 38 | done |
| 37 | 39 | pacman -Q > "$output_dir/build-packages.txt" |
| 40 | 新增:# Keep the exact source package identity with cached binaries. A later runner | |
| 41 | 新增:# must not collect the source of whichever library version happens to be installed. | |
| 42 | 新增:for package in "${packages[@]}"; do | |
| 43 | 新增: read -r name version < <(pacman -Q "$package") | |
| 44 | 新增: base=$(awk '/^%BASE%$/ {getline; print; exit}' "/var/lib/pacman/local/$name-$version/desc") | |
| 45 | 新增: [[ -n "$base" ]] || { echo "Source package identity missing for $package" >&2; exit 1; } | |
| 46 | 新增: printf '%s %s\n' "$base" "$version" | |
| 47 | 新增:done | sort -u > "$output_dir/build-source-packages.txt" | |
| @@ -105,7 +105,17 @@ try { | ||
| 105 | 105 | Expand-BuildArchive $qemuArchive $qemuTarget $sevenZip |
| 106 | 106 | $qemuBuilt = Join-Path $DependencyCache 'qemu-cage' |
| 107 | 107 | & (Join-Path $PSScriptRoot 'build-qemu-windows.ps1') -DependencyCache $DependencyCache -OutputDirectory $qemuBuilt |
| 108 | 删除: Copy-Item (Join-Path $qemuBuilt '*') $qemuTarget -Force | |
| 108 | 新增: $runtimeManifest = Get-Content (Join-Path $qemuBuilt 'cage-build.json') -Raw | ConvertFrom-Json | |
| 109 | 新增: $ownedRuntime = @($runtimeManifest.files | ForEach-Object { $_.name }) + @('cage-build.json') | |
| 110 | 新增: foreach ($name in $ownedRuntime) { | |
| 111 | 新增: if ([IO.Path]::GetFileName($name) -ne $name) { throw 'Invalid QEMU runtime manifest path.' } | |
| 112 | 新增: Copy-Item -LiteralPath (Join-Path $qemuBuilt $name) -Destination $qemuTarget -Force | |
| 113 | 新增: } | |
| 114 | 新增: # The two executables above are linked against the built dependency closure. | |
| 115 | 新增: # Vendor DLLs/executables outside that closure have no runtime consumer. | |
| 116 | 新增: Get-ChildItem -LiteralPath $qemuTarget -File | Where-Object { | |
| 117 | 新增: $_.Extension -in @('.exe', '.dll') -and $_.Name -notin $ownedRuntime | |
| 118 | 新增: } | Remove-Item -Force | |
| 109 | 119 | # Ship the x64 VM only, with its original firmware, DLLs and notices. |
| 110 | 120 | Get-ChildItem -LiteralPath $qemuTarget -Filter 'qemu-system-*.exe' | Where-Object { $_.Name -ne 'qemu-system-x86_64.exe' } | Remove-Item -Force |
| 111 | 121 | Get-ChildItem -LiteralPath (Join-Path $qemuTarget 'share') -File | |
| @@ -0,0 +1,51 @@ | ||
| 1 | 新增:#!/usr/bin/env bash | |
| 2 | 新增:# Bundle the exact QEMU/firmware revisions and the packages owning its DLLs. | |
| 3 | 新增:set -euo pipefail | |
| 4 | 新增:repository=$(cygpath -u "$1") | |
| 5 | 新增:runtime=$(cygpath -u "$2") | |
| 6 | 新增:archive=$(cygpath -u "$3") | |
| 7 | 新增:commit=$(node -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuSource.commit" "$repository/packaging/windows/dependencies.json") | |
| 8 | 新增:[[ $commit =~ ^[a-f0-9]{40}$ && -s "$runtime/build-source-packages.txt" ]] || { echo 'QEMU source/package identity is missing.' >&2; exit 1; } | |
| 9 | 新增:stage=$(mktemp -d) | |
| 10 | 新增:trap 'rm -rf "$stage"' EXIT | |
| 11 | 新增:mkdir -p "$stage/source/packages" "$stage/source/cage" | |
| 12 | 新增:git -c core.autocrlf=false init -q "$stage/source/qemu" | |
| 13 | 新增:git -C "$stage/source/qemu" fetch --depth=1 https://github.com/stweil/qemu.git "$commit" | |
| 14 | 新增:git -c core.autocrlf=false -C "$stage/source/qemu" checkout -q --detach FETCH_HEAD | |
| 15 | 新增:[[ $(git -C "$stage/source/qemu" rev-parse HEAD) == "$commit" ]] | |
| 16 | 新增:# All shipped firmware comes from QEMU's pinned ROM submodules. Include nested | |
| 17 | 新增:# submodules (EDK2 libraries etc.), not only the superproject's empty gitlinks. | |
| 18 | 新增:git -c core.autocrlf=false -C "$stage/source/qemu" submodule update --init --recursive --depth=1 -- roms | |
| 19 | 新增:git -C "$stage/source/qemu" submodule status --recursive -- roms > "$stage/source/firmware-revisions.txt" | |
| 20 | 新增:if grep -Eq '^[-+U]' "$stage/source/firmware-revisions.txt"; then echo 'Firmware source revisions are incomplete.' >&2; exit 1; fi | |
| 21 | 新增:cp "$runtime/build-source-packages.txt" "$runtime/build-packages.txt" "$runtime/cage-build.json" "$stage/source/cage/" | |
| 22 | 新增:cp "$repository/scripts/build-qemu-windows.sh" "$repository/scripts/build-qemu-windows.ps1" "$repository/scripts/bundle-qemu-sources.sh" "$stage/source/cage/" | |
| 23 | 新增:cp -R "$repository/patches/qemu" "$stage/source/cage/patches" | |
| 24 | 新增:keymap_url=$(node -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuKeycodemap.url" "$repository/packaging/windows/dependencies.json") | |
| 25 | 新增:keymap_hash=$(node -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuKeycodemap.hash" "$repository/packaging/windows/dependencies.json") | |
| 26 | 新增:curl --fail --location --retry 3 -o "$stage/source/keycodemapdb.tar.gz" "$keymap_url" | |
| 27 | 新增:printf '%s %s\n' "$keymap_hash" "$stage/source/keycodemapdb.tar.gz" | sha256sum -c - | |
| 28 | 新增:while read -r base version; do | |
| 29 | 新增: [[ $base =~ ^[a-zA-Z0-9+_.-]+$ && $version =~ ^[a-zA-Z0-9+_.:-]+$ ]] || exit 1 | |
| 30 | 新增: found=false | |
| 31 | 新增: for extension in zst xz gz; do | |
| 32 | 新增: name="$base-$version.src.tar.$extension" | |
| 33 | 新增: url="https://repo.msys2.org/mingw/sources/$name" | |
| 34 | 新增: if curl --fail --location --retry 2 -o "$stage/source/packages/$name" "$url"; then | |
| 35 | 新增: curl --fail --location --retry 3 -o "$stage/source/packages/$name.sig" "$url.sig" | |
| 36 | 新增: pacman-key --verify "$stage/source/packages/$name.sig" "$stage/source/packages/$name" | |
| 37 | 新增: found=true | |
| 38 | 新增: break | |
| 39 | 新增: fi | |
| 40 | 新增: done | |
| 41 | 新增: $found || { echo "No verified corresponding source for $base $version" >&2; exit 1; } | |
| 42 | 新增:done < "$runtime/build-source-packages.txt" | |
| 43 | 新增:# Firmware sources remain unmodified; the Cage patch and reproducible build | |
| 44 | 新增:# commands travel beside them. The manifest covers every distributed source. | |
| 45 | 新增:find "$stage/source" -name .git -type d -prune -exec rm -rf {} + | |
| 46 | 新增:find "$stage/source" -name .git -type f -delete | |
| 47 | 新增:(cd "$stage/source" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS) | |
| 48 | 新增:mkdir -p "$(dirname "$archive")" | |
| 49 | 新增:tar -czf "$archive.partial" -C "$stage" source | |
| 50 | 新增:mv "$archive.partial" "$archive" | |
| 51 | 新增:sha256sum "$archive" | |
| @@ -0,0 +1,34 @@ | ||
| 1 | 新增:import assert from 'node:assert/strict'; | |
| 2 | 新增:import {execFileSync} from 'node:child_process'; | |
| 3 | 新增:import {createHash} from 'node:crypto'; | |
| 4 | 新增:import {chmod,mkdir,mkdtemp,readFile,rm,writeFile} from 'node:fs/promises'; | |
| 5 | 新增:import {tmpdir} from 'node:os'; | |
| 6 | 新增:import {join} from 'node:path'; | |
| 7 | 新增:import {fileURLToPath} from 'node:url'; | |
| 8 | 新增:import test from 'node:test'; | |
| 9 | 新增:const collector=fileURLToPath(new URL('./bundle-qemu-sources.sh',import.meta.url)); | |
| 10 | 新增:test('source collector includes pinned firmware and authenticated package sources with a complete manifest',async t=>{ | |
| 11 | 新增: const root=await mkdtemp(join(tmpdir(),'cage-qemu-source-test-'));t.after(()=>rm(root,{recursive:true,force:true})); | |
| 12 | 新增: const repository=join(root,'repository'),runtime=join(root,'runtime'),bin=join(root,'bin'),artifact=join(root,'bundle.tar.gz'); | |
| 13 | 新增: for(const path of [bin,runtime,join(repository,'packaging/windows'),join(repository,'scripts'),join(repository,'patches/qemu')])await mkdir(path,{recursive:true}); | |
| 14 | 新增: const sha='a'.repeat(40),content='fixture source archive\n'; | |
| 15 | 新增: await writeFile(join(repository,'packaging/windows/dependencies.json'),JSON.stringify({qemuSource:{commit:sha},qemuKeycodemap:{url:'https://source.invalid/keymap.tar.gz',hash:createHash('sha256').update(content).digest('hex')}})); | |
| 16 | 新增: for(const name of ['build-source-packages.txt','build-packages.txt','cage-build.json'])await writeFile(join(runtime,name),name==='build-source-packages.txt'?'mingw-w64-fixture 1.2.3-1\n':'fixture'); | |
| 17 | 新增: for(const name of ['build-qemu-windows.sh','build-qemu-windows.ps1','bundle-qemu-sources.sh'])await writeFile(join(repository,'scripts',name),'fixture build input'); | |
| 18 | 新增: await writeFile(join(repository,'patches/qemu/fixture.patch'),'fixture patch'); | |
| 19 | 新增: const command=async(name,body)=>{const path=join(bin,name);await writeFile(path,'#!/bin/bash\nset -e\n'+body+'\n');await chmod(path,0o755)}; | |
| 20 | 新增: await command('cygpath','printf "%s\\n" "$2"'); | |
| 21 | 新增: await command('git',`if [[ "$*" == *' init '* ]];then mkdir -p "\${@: -1}/.git";fi | |
| 22 | 新增: if [[ "$*" == *rev-parse* ]];then printf '${sha}\\n';fi | |
| 23 | 新增: if [[ "$*" == *'submodule update'* ]];then for ((i=1;i<=$#;i++));do if [[ "\${!i}" == -C ]];then j=$((i+1));q="\${!j}";fi;done;mkdir -p "$q/roms/seabios";echo 'firmware code' > "$q/roms/seabios/code.c";echo 'gitdir: private' > "$q/roms/seabios/.git";fi | |
| 24 | 新增: if [[ "$*" == *'submodule status'* ]];then printf ' ${sha} roms/seabios\\n';fi`); | |
| 25 | 新增: await command('curl',`while [[ $# -gt 0 ]];do if [[ "$1" == -o ]];then shift;destination=$1;fi;shift;done;printf '${content.replaceAll('\n','\\n')}' > "$destination"`); | |
| 26 | 新增: await command('pacman-key','printf "%s\\n" "$*" >> "$SOURCE_TEST_VERIFICATIONS"'); | |
| 27 | 新增: execFileSync('bash',[collector,repository,runtime,artifact],{env:{...process.env,PATH:bin+':'+process.env.PATH,SOURCE_TEST_VERIFICATIONS:join(root,'verified')},stdio:'pipe'}); | |
| 28 | 新增: const listing=execFileSync('tar',['-tzf',artifact],{encoding:'utf8'}); | |
| 29 | 新增: for(const path of ['source/firmware-revisions.txt','source/qemu/roms/seabios/code.c','source/packages/mingw-w64-fixture-1.2.3-1.src.tar.zst','source/cage/patches/fixture.patch','source/SHA256SUMS'])assert.ok(listing.includes(path),path); | |
| 30 | 新增: assert.ok(!listing.includes('/.git')); | |
| 31 | 新增: assert.ok((await readFile(join(root,'verified'),'utf8')).includes('--verify')); | |
| 32 | 新增: const extract=join(root,'extracted');await mkdir(extract);execFileSync('tar',['-xzf',artifact,'-C',extract]); | |
| 33 | 新增: execFileSync('shasum',['-a','256','-c','SHA256SUMS'],{cwd:join(extract,'source'),stdio:'pipe'}); | |
| 34 | 新增:}); | |
| @@ -2,7 +2,6 @@ | ||
| 2 | 2 | const required = [ |
| 3 | 3 | 'CAGE_MACOS_P12_BASE64', 'CAGE_MACOS_P12_PASSWORD', 'CAGE_MACOS_SIGNING_IDENTITY', |
| 4 | 4 | 'CAGE_MACOS_NOTARY_KEY_BASE64', 'CAGE_MACOS_NOTARY_KEY_ID', 'CAGE_MACOS_NOTARY_ISSUER_ID', |
| 5 | 删除: 'CAGE_WINDOWS_QEMU_SOURCE_URL', 'CAGE_WINDOWS_QEMU_SOURCE_SHA256', | |
| 6 | 5 | ]; |
| 7 | 6 | const provider = process.env.CAGE_WINDOWS_SIGNING_PROVIDER || 'certificate-store'; |
| 8 | 7 | if (provider === 'esigner') { |
| @@ -21,12 +20,6 @@ if (missing.length) { | ||
| 21 | 20 | !/^[0-9a-f]{32,40}$/i.test(process.env.CAGE_ESIGNER_CERTIFICATE_SERIAL))) { |
| 22 | 21 | throw new Error('Invalid eSigner credential ID or expected certificate serial.'); |
| 23 | 22 | } |
| 24 | 删除: let source; | |
| 25 | 删除: try { source = new URL(process.env.CAGE_WINDOWS_QEMU_SOURCE_URL); } | |
| 26 | 删除: catch { throw new Error('Reviewed QEMU source requires a valid public HTTPS URL.'); } | |
| 27 | 删除: if (source.protocol !== 'https:' || source.username || source.password || source.search || source.hash || !/^[0-9a-f]{64}$/i.test(process.env.CAGE_WINDOWS_QEMU_SOURCE_SHA256)) { | |
| 28 | 删除: throw new Error('Reviewed QEMU source requires a credential-free HTTPS URL and SHA-256.'); | |
| 29 | 删除: } | |
| 30 | 23 | if (!process.env.CAGE_MACOS_SIGNING_IDENTITY.startsWith('Developer ID Application:')) throw new Error('macOS releases require a Developer ID Application identity.'); |
| 31 | 24 | console.log('Release configuration is present. Platform jobs will verify the credentials, signatures and corresponding sources.'); |
| 32 | 25 | } |
| @@ -29,21 +29,6 @@ try { | ||
| 29 | 29 | } elseif (-not $env:CAGE_WINDOWS_PFX_BASE64 -or -not $env:CAGE_WINDOWS_PFX_PASSWORD) { |
| 30 | 30 | throw 'Configure CAGE_WINDOWS_PFX_BASE64 and CAGE_WINDOWS_PFX_PASSWORD in the cage-release environment.' |
| 31 | 31 | } |
| 32 | 删除: $sourceUri = $null | |
| 33 | 删除: if (-not [Uri]::TryCreate($env:CAGE_WINDOWS_QEMU_SOURCE_URL, [UriKind]::Absolute, [ref]$sourceUri) -or | |
| 34 | 删除: $sourceUri.Scheme -ne 'https' -or $sourceUri.UserInfo -or $sourceUri.Query -or $sourceUri.Fragment -or | |
| 35 | 删除: $env:CAGE_WINDOWS_QEMU_SOURCE_SHA256 -notmatch '^[0-9A-Fa-f]{64}$') { | |
| 36 | 删除: throw 'Configure CAGE_WINDOWS_QEMU_SOURCE_URL (HTTPS) and CAGE_WINDOWS_QEMU_SOURCE_SHA256 for the reviewed complete source archive.' | |
| 37 | 删除: } | |
| 38 | 删除: $extension = [IO.Path]::GetExtension($sourceUri.AbsolutePath).ToLowerInvariant() | |
| 39 | 删除: if ($extension -notin @('.zip', '.7z', '.tar', '.gz', '.xz', '.bz2', '.zst')) { | |
| 40 | 删除: throw 'The reviewed source URL must name a ZIP, 7z, tar or compressed tar archive.' | |
| 41 | 删除: } | |
| 42 | 删除: $qemuSource = Join-Path $env:RUNNER_TEMP ('qemu-windows-source-' + [guid]::NewGuid().ToString('N') + $extension) | |
| 43 | 删除: Invoke-WebRequest -Uri $sourceUri -OutFile $qemuSource -TimeoutSec 600 -MaximumRedirection 5 | |
| 44 | 删除: if ((Get-FileHash -LiteralPath $qemuSource -Algorithm SHA256).Hash -ne $env:CAGE_WINDOWS_QEMU_SOURCE_SHA256) { | |
| 45 | 删除: throw 'Reviewed corresponding-source archive checksum mismatch.' | |
| 46 | 删除: } | |
| 47 | 32 | if ($env:CAGE_WINDOWS_SIGNING_PROVIDER -ne 'esigner') { |
| 48 | 33 | $pfx = Join-Path $env:RUNNER_TEMP ('cage-signing-' + [guid]::NewGuid().ToString('N') + '.pfx') |
| 49 | 34 | [IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($env:CAGE_WINDOWS_PFX_BASE64)) |
| @@ -67,6 +52,16 @@ try { | ||
| 67 | 52 | $windowsPowerShell = Join-Path ([Environment]::SystemDirectory) 'WindowsPowerShell/v1.0/powershell.exe' |
| 68 | 53 | & (Join-Path $PSScriptRoot 'test-windows-installation-files.ps1') -HelperShell $windowsPowerShell |
| 69 | 54 | & (Join-Path $PSScriptRoot 'build-windows.ps1') -Release:$Release |
| 55 | 新增: if ($Release) { | |
| 56 | 新增: $qemuSource = Join-Path $env:RUNNER_TEMP 'qemu-windows-full-source.tar.gz' | |
| 57 | 新增: $savedMsystem, $savedChere = $env:MSYSTEM, $env:CHERE_INVOKING | |
| 58 | 新增: try { | |
| 59 | 新增: $env:MSYSTEM = 'UCRT64'; $env:CHERE_INVOKING = '1' | |
| 60 | 新增: Invoke-BuildTool (Join-Path $env:CAGE_MSYS2_ROOT 'usr/bin/bash.exe') @('-l', | |
| 61 | 新增: (Join-Path $PSScriptRoot 'bundle-qemu-sources.sh'), $repository, | |
| 62 | 新增: (Join-Path $repository '_output/windows-deps/qemu-cage'), $qemuSource) | |
| 63 | 新增: } finally { $env:MSYSTEM = $savedMsystem; $env:CHERE_INVOKING = $savedChere } | |
| 64 | 新增: } | |
| 70 | 65 | if (-not $Release) { |
| 71 | 66 | $windowsPowerShell = Join-Path ([Environment]::SystemDirectory) 'WindowsPowerShell/v1.0/powershell.exe' |
| 72 | 67 | foreach ($test in @('install-guest-powershell.tests.ps1', 'windows-evaluation.tests.ps1')) { |
| @@ -37,7 +37,7 @@ if ($signed) { | ||
| 37 | 37 | if ($env:CAGE_WINDOWS_CERT_SHA1 -notmatch '^[0-9A-Fa-f]{40}$') { throw 'Build and verify the signed app before packaging.' } |
| 38 | 38 | if (Test-Path -LiteralPath (Join-Path $AppDirectory 'DEVELOPMENT-BUILD.txt')) { throw 'Rebuild with build-windows.ps1 -Sign or -Release before packaging a signed installer.' } |
| 39 | 39 | if ($Release -and (-not $QemuSourceArchive -or -not (Test-Path -LiteralPath $QemuSourceArchive -PathType Leaf))) { |
| 40 | 删除: throw 'Release packaging requires -QemuSourceArchive containing the corresponding patched QEMU and bundled library sources. A generic upstream QEMU tarball is not the source for the Weilnetz build.' | |
| 40 | 新增: throw 'Release packaging requires -QemuSourceArchive containing the exact QEMU, firmware and linked library sources. Generate it from the built runtime with bundle-qemu-sources.sh.' | |
| 41 | 41 | } |
| 42 | 42 | if ($Release) { Invoke-BuildTool $sevenZip @('t', '-bso0', '-bsp0', $QemuSourceArchive) } |
| 43 | 43 | $signTool = Get-SigningTool |
| @@ -100,7 +100,8 @@ if (Test-Path (Join-Path $qemuRuntime 'cage-build.json')) { | ||
| 100 | 100 | $releaseFiles += @($keymapSource, $changesSource) |
| 101 | 101 | } |
| 102 | 102 | if ($Release) { |
| 103 | 删除: $qemuSourceTarget = Join-Path $OutputDirectory ('qemu-' + $dependencies.qemu.version + '-windows-full-source' + [IO.Path]::GetExtension($QemuSourceArchive)) | |
| 103 | 新增: $sourceExtension = if ($QemuSourceArchive.EndsWith('.tar.gz', [StringComparison]::OrdinalIgnoreCase)) { '.tar.gz' } else { [IO.Path]::GetExtension($QemuSourceArchive) } | |
| 104 | 新增: $qemuSourceTarget = Join-Path $OutputDirectory ('qemu-' + $dependencies.qemu.version + '-windows-full-source' + $sourceExtension) | |
| 104 | 105 | Copy-Item -LiteralPath $QemuSourceArchive -Destination $qemuSourceTarget -Force |
| 105 | 106 | $releaseFiles += $qemuSourceTarget |
| 106 | 107 | } |
| @@ -43,6 +43,17 @@ async function findRelease(api, base, tag) { | ||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 新增:export async function releaseNotes(root, context) { | |
| 47 | 新增: if (!context.notesPath) return ''; | |
| 48 | 新增: if (!/^docs\/(?:[A-Za-z0-9_.-]+\/)*[A-Za-z0-9_.-]+\.md$/.test(context.notesPath) || context.notesPath.split('/').some(part => part === '.' || part === '..')) { | |
| 49 | 新增: throw new Error('Release notes must be a committed Markdown file under docs/.'); | |
| 50 | 新增: } | |
| 51 | 新增: if (!shaPattern.test(context.sourceSha)) throw new Error('Invalid release notes source.'); | |
| 52 | 新增: const body = execFileSync('git', ['show', `${context.sourceSha}:${context.notesPath}`], { cwd: root, encoding: 'utf8', maxBuffer: 1 << 20 }).trim(); | |
| 53 | 新增: if (!body || Buffer.byteLength(body) > 100000) throw new Error('Release notes must contain 1–100000 UTF-8 bytes.'); | |
| 54 | 新增: return body; | |
| 55 | 新增:} | |
| 56 | 新增: | |
| 46 | 57 | // Build expected version files from the immutable source commit, even when |
| 47 | 58 | // publish is checking out the candidate. This catches unrelated file edits. |
| 48 | 59 | export async function expectedFiles(root, sourceSha, version) { |
| @@ -82,6 +93,8 @@ export async function verifyCandidate(api, context, expected) { | ||
| 82 | 93 | |
| 83 | 94 | export async function prepareRelease({ api, root, ...context }) { |
| 84 | 95 | checkContext(context); |
| 96 | 新增: if (context.requestedVersion) parseVersion(context.requestedVersion); | |
| 97 | 新增: await releaseNotes(root, context); | |
| 85 | 98 | const base = apiRoot(context); |
| 86 | 99 | const main = await api('GET', `${base}/git/ref/heads/${context.defaultBranch}`); |
| 87 | 100 | const existing = await optional(api, `${base}/git/ref/heads/${branch(context.runId)}`); |
| @@ -89,6 +102,7 @@ export async function prepareRelease({ api, root, ...context }) { | ||
| 89 | 102 | const commit = await api('GET', `${base}/git/commits/${existing.object.sha}`); |
| 90 | 103 | const version = /^chore\(release\): v([^\n]+)\n\nCage-Release-Run: \d+$/.exec(commit.message)?.[1]; |
| 91 | 104 | parseVersion(version); |
| 105 | 新增: if (context.requestedVersion && context.requestedVersion !== version) throw new Error('Existing candidate uses another requested version.'); | |
| 92 | 106 | if (main.object.sha !== context.sourceSha && main.object.sha !== existing.object.sha) throw new Error('Main advanced; start a new explicitly requested release.'); |
| 93 | 107 | const result = { ...context, version, commitSha: existing.object.sha }; |
| 94 | 108 | await verifyCandidate(api, result, await expectedFiles(root, context.sourceSha, version)); |
| @@ -103,8 +117,16 @@ export async function prepareRelease({ api, root, ...context }) { | ||
| 103 | 117 | reserved.push(...releases.map(release => release.tag_name)); |
| 104 | 118 | if (releases.length < 100) break; |
| 105 | 119 | } |
| 106 | 删除: const version = nextVersion(current, context.bump, reserved); | |
| 120 | 新增: const version = context.requestedVersion || nextVersion(current, context.bump, reserved); | |
| 107 | 121 | if (compareVersions(version, current) <= 0) throw new Error('Release version must advance.'); |
| 122 | 新增: if (context.requestedVersion) { | |
| 123 | 新增: for (const tag of reserved) { | |
| 124 | 新增: if (!tag.startsWith('v')) continue; | |
| 125 | 新增: let previous; | |
| 126 | 新增: try { previous = parseVersion(tag.slice(1)); } catch { continue; } | |
| 127 | 新增: if (previous && compareVersions(version, tag.slice(1)) <= 0) throw new Error('Requested release version must exceed all reserved versions.'); | |
| 128 | 新增: } | |
| 129 | 新增: } | |
| 108 | 130 | // Tags and draft Releases reserve their version. Never reuse someone else's draft. |
| 109 | 131 | if (await findRelease(api, base, `v${version}`)) throw new Error(`Release v${version} is already reserved.`); |
| 110 | 132 | const files = await expectedFiles(root, context.sourceSha, version); |
| @@ -175,6 +197,7 @@ function assertAssets(assets, files) { | ||
| 175 | 197 | |
| 176 | 198 | export async function publishRelease({ api, upload, promote, root, files, ...context }) { |
| 177 | 199 | checkContext(context); |
| 200 | 新增: const customNotes = await releaseNotes(root, context); | |
| 178 | 201 | await verifyCandidate(api, context, await expectedFiles(root, context.sourceSha, context.version)); |
| 179 | 202 | const base = apiRoot(context); |
| 180 | 203 | const main = await api('GET', `${base}/git/ref/heads/${context.defaultBranch}`); |
| @@ -192,11 +215,11 @@ export async function publishRelease({ api, upload, promote, root, files, ...con | ||
| 192 | 215 | } |
| 193 | 216 | await promote(context); // Atomic, fast-forward-only main + tag; never force-push. |
| 194 | 217 | if (!release) { |
| 195 | 删除: const notes = await api('POST', `${base}/releases/generate-notes`, { tag_name: `v${context.version}`, target_commitish: context.commitSha }); | |
| 218 | 新增: const notes = customNotes ? { body: customNotes } : await api('POST', `${base}/releases/generate-notes`, { tag_name: `v${context.version}`, target_commitish: context.commitSha }); | |
| 196 | 219 | release = await api('POST', `${base}/releases`, { |
| 197 | 220 | tag_name: `v${context.version}`, target_commitish: context.commitSha, |
| 198 | 221 | name: `Cage ${context.version}`, draft: true, prerelease: context.version.includes('-'), |
| 199 | 删除: body: `${marker(context)}\n\n${notes.body || ''}\n\nThree platform builds, package verification and automated checks completed for ${context.commitSha}. Hardware virtualization and real Claude account acceptance are separate checks; see the platform guides.`, | |
| 222 | 新增: body: `${marker(context)}\n\n${notes.body || ''}${customNotes ? '' : `\n\nThree platform builds, package verification and automated checks completed for ${context.commitSha}. Hardware virtualization and real Claude account acceptance are separate checks; see the platform guides.`}`, | |
| 200 | 223 | }); |
| 201 | 224 | } |
| 202 | 225 | const assets = await api('GET', `${base}/releases/${release.id}/assets?per_page=100`); |
| @@ -220,6 +243,7 @@ export function workflowContext(env, event) { | ||
| 220 | 243 | repository: env.GITHUB_REPOSITORY, sourceSha: env.RELEASE_SOURCE_SHA || env.GITHUB_SHA, |
| 221 | 244 | runId: env.GITHUB_RUN_ID, defaultBranch: event.repository?.default_branch, bump: event.inputs?.bump, |
| 222 | 245 | version: env.RELEASE_VERSION, commitSha: env.RELEASE_COMMIT_SHA, |
| 246 | 新增: requestedVersion: event.inputs?.version?.replace(/^v/, '') || undefined, notesPath: event.inputs?.notes_path || undefined, | |
| 223 | 247 | }; |
| 224 | 248 | checkContext(context); |
| 225 | 249 | if (env.GITHUB_ACTIONS !== 'true' || env.GITHUB_EVENT_NAME !== 'workflow_dispatch' || env.GITHUB_REF !== 'refs/heads/main') { |
| @@ -7,7 +7,7 @@ import { dirname, join } from 'node:path'; | ||
| 7 | 7 | import test from 'node:test'; |
| 8 | 8 | import { |
| 9 | 9 | assembleRelease, expectedFiles, prepareRelease, publishRelease, releaseFiles, |
| 10 | 删除: verifyCandidate, versionPaths, workflowContext, | |
| 10 | 新增: verifyCandidate, versionPaths, workflowContext, releaseNotes, | |
| 11 | 11 | } from './release-control.mjs'; |
| 12 | 12 | |
| 13 | 13 | const repository = 'Lee-xeo/Claude-Cage'; |
| @@ -194,6 +194,42 @@ test('prepare leaves the working version unchanged and reuses the same run candi | ||
| 194 | 194 | assert.equal(f.state.calls.filter(call => call.method === 'POST' && call.path.endsWith('/git/commits')).length, 1); |
| 195 | 195 | }); |
| 196 | 196 | |
| 197 | 新增:test('exact requested version is retained on preparation and resume, with reserved versions rejected', async t => { | |
| 198 | 新增: const f = await repositoryFixture(t); | |
| 199 | 新增: f.context.requestedVersion = '99.1.0-rc.1'; | |
| 200 | 新增: const first = await f.candidate(); | |
| 201 | 新增: assert.equal(first.version, '99.1.0-rc.1'); | |
| 202 | 新增: assert.equal((await f.candidate()).commitSha, first.commitSha); | |
| 203 | 新增: f.context.requestedVersion = '99.1.0-rc.2'; | |
| 204 | 新增: await assert.rejects(f.candidate(), /another requested version/); | |
| 205 | 新增: const reserved = await repositoryFixture(t); | |
| 206 | 新增: reserved.context.requestedVersion = '99.1.0-rc.1'; | |
| 207 | 新增: reserved.state.otherReleases.push({ tag_name: 'v99.1.0-rc.1', draft: true }); | |
| 208 | 新增: await assert.rejects(reserved.candidate(), /reserved/); | |
| 209 | 新增: assert.equal(reserved.state.calls.some(call => call.method !== 'GET'), false); | |
| 210 | 新增:}); | |
| 211 | 新增: | |
| 212 | 新增:test('custom release notes come from the immutable source and are published with RC status', async t => { | |
| 213 | 新增: const f = await repositoryFixture(t); | |
| 214 | 新增: f.context.notesPath = 'docs/releases/v99.1.0-rc.1.md'; | |
| 215 | 新增: await mkdir(join(f.root, 'docs/releases'), { recursive: true }); | |
| 216 | 新增: await writeFile(join(f.root, f.context.notesPath), '# 本轮更新\n\n功能与已验证范围。\n'); | |
| 217 | 新增: f.git(['add', f.context.notesPath]); | |
| 218 | 新增: f.git(['commit', '--quiet', '-m', 'Public release notes']); | |
| 219 | 新增: f.context.sourceSha = f.state.main = f.git(['rev-parse', 'HEAD']); | |
| 220 | 新增: f.context.requestedVersion = '99.1.0-rc.1'; | |
| 221 | 新增: const candidate = await f.candidate(); | |
| 222 | 新增: await writeFile(join(f.root, f.context.notesPath), 'Concurrent local draft, must not be published.'); | |
| 223 | 新增: const files = await uploadFiles(f.root, candidate.version); | |
| 224 | 新增: const release = await publish(f, candidate, files); | |
| 225 | 新增: assert.equal(release.prerelease, true); | |
| 226 | 新增: assert.ok(release.body.endsWith('# 本轮更新\n\n功能与已验证范围。')); | |
| 227 | 新增: assert.equal(f.state.calls.some(call => call.path.endsWith('/generate-notes')), false); | |
| 228 | 新增: for (const notesPath of ['../private.md', 'docs/../private.md', '/docs/notes.md', 'docs/notes.txt']) { | |
| 229 | 新增: await assert.rejects(releaseNotes(f.root, { ...candidate, notesPath }), /committed Markdown/); | |
| 230 | 新增: } | |
| 231 | 新增:}); | |
| 232 | 新增: | |
| 197 | 233 | test('main movement prevents candidate creation and later publication', async t => { |
| 198 | 234 | const f = await repositoryFixture(t); |
| 199 | 235 | f.state.main = 'b'.repeat(40); |

