Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/alpha-preview-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ jobs:
if ($LASTEXITCODE -ne 0 -or -not $remote -or ($remote -split '\s+')[0] -ne $env:GITHUB_SHA) {
throw "Release branch advanced during qualification; stale promotion rejected"
}
# A release that was current at dispatch can become stale while the
# Windows compiler runs. Never publish without the latest merged main.
$mainRemote = & git ls-remote origin 'refs/heads/main'
if ($LASTEXITCODE -ne 0 -or -not $mainRemote) {
throw "Cannot verify current main before public promotion"
}
$mainSha = ($mainRemote -split '\s+')[0]
& git fetch --no-tags origin $mainSha
if ($LASTEXITCODE -ne 0) {
throw "Cannot fetch current main for release ancestry gate"
}
& git merge-base --is-ancestor $mainSha $env:GITHUB_SHA
if ($LASTEXITCODE -ne 0) {
throw "RELEASE_MISSING_LATEST_MAIN_PROGRESS: reconcile and requalify a new SHA"
}
& gh release create $tag @assets --repo $env:GITHUB_REPOSITORY --target $env:GITHUB_SHA --title "ArSonMix $tag — Alpha Preview" --notes-file $env:ARMIX_RELEASE_NOTES --prerelease --latest=false
if ($LASTEXITCODE -ne 0) { throw "GitHub Release publication failed" }
& gh release view $tag --repo $env:GITHUB_REPOSITORY --json url,isPrerelease,assets
Expand Down
7 changes: 7 additions & 0 deletions scripts/release_ci_dispatch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export async function releaseDispatch({event,api}) {
const ref=await api('/git/ref/heads/'+cmd.branch);
if (ref?.ref!=='refs/heads/'+cmd.branch || ref?.object?.sha!==cmd.sha)
throw Error('RELEASE_STALE_SHA_OR_BRANCH');
// A correct release-branch SHA can still omit recent merged GUI/audio fixes.
// Fail BEFORE allocating Windows runners unless this immutable commit contains
// the complete current main history. Never treat an old release branch as RC.
const ancestry=await api('/compare/main...'+cmd.sha);
if (!ancestry || !['identical','ahead'].includes(ancestry.status) ||
ancestry.behind_by!==0 || !Number.isSafeInteger(ancestry.ahead_by))
throw Error('RELEASE_CANDIDATE_MISSING_MAIN_PROGRESS');
const older=[];
for(let page=1;page<=10;page++) {
const chunk=await api('/issues/'+CONTROL_ISSUE+'/comments?per_page=100&page='+page);
Expand Down
34 changes: 33 additions & 1 deletion tests/release_ci_dispatch_contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ const ev=(body='/arsonmix-release '+TAG+' '+SHA)=>({
repository:{full_name:'masarray/arsonmix'},issue:{number:450},
comment:{id:100,body,author_association:'OWNER',user:{login:'masarray'}}
});
function fakeApi({refSha=SHA,comments=[],runs=[],released=false,notesReady=true,notesSize=200,nativeVersion='0.5.0'}={}) {
function fakeApi({refSha=SHA,comments=[],runs=[],released=false,notesReady=true,notesSize=200,nativeVersion='0.5.0',compareStatus='ahead',compareBehind=0,compareAhead=1}={}) {
const calls=[];
const api=async(path,method='GET',data)=>{
calls.push({path,method,data});
if(path==='/git/ref/heads/'+BRANCH)
return {ref:'refs/heads/'+BRANCH,object:{sha:refSha}};
if(path==='/compare/main...'+SHA) return {status:compareStatus,behind_by:compareBehind,ahead_by:compareAhead};
if(path.startsWith('/issues/450/comments'))return comments;
if(path==='/releases/tags/'+TAG){
if(released)return {tag_name:TAG};
Expand Down Expand Up @@ -105,6 +106,25 @@ test('Stale SHA rejects without costly workflow dispatch',async()=>{
await assert.rejects(releaseDispatch({event:ev(),api:x.api}),/RELEASE_STALE_SHA/);
assert.equal(x.calls.filter(c=>c.method==='POST').length,0);
});
test('Release must include all of current main, not just match a valid release-branch SHA',async()=>{
// The old public alpha had a valid tag/SHA but omitted newly merged GUI/audio.
for(const stale of [
{compareStatus:'behind',compareBehind:63,compareAhead:0},
{compareStatus:'diverged',compareBehind:2,compareAhead:1},
{compareStatus:'ahead',compareBehind:1,compareAhead:1},
{compareStatus:'unknown',compareBehind:0,compareAhead:0}
]) {
const x=fakeApi(stale);
await assert.rejects(releaseDispatch({event:ev(),api:x.api}),
/RELEASE_CANDIDATE_MISSING_MAIN_PROGRESS/);
assert.equal(x.calls.some(t=>t.method==='POST'),false,
'stale candidate must not allocate the Windows builder');
}
const current=fakeApi({compareStatus:'identical',compareBehind:0,compareAhead:0});
assert.equal((await releaseDispatch({event:ev(),api:current.api})).kind,'dispatched');
assert.equal(current.calls.filter(t=>t.method==='POST').length,1);
});

test('Duplicate owner comment and already-published tag are no-op',async()=>{
const comments=[{id:88,body:ev().comment.body,user:{login:'masarray'},author_association:'OWNER'}];
for(const input of [{comments},{released:true}]){
Expand Down Expand Up @@ -276,6 +296,18 @@ test('Public port workflow includes no commercial signing or push-triggered buil
assert.match(workflow,/SHA256SUMS-Linux.txt/);
});

test('Windows release publisher checks latest main again at promotion, not just at start',()=>{
const workflow=readFileSync(new URL('../.github/workflows/alpha-preview-publish.yml',import.meta.url),'utf8');
const publish=workflow.split(' - name: Publish verified GitHub prerelease and its Windows binaries')[1]
?.split(' - name: Refresh official landing catalog')[0]||'';
assert.match(publish,/git ls-remote origin 'refs\/heads\/main'/);
assert.match(publish,/git fetch --no-tags origin \$mainSha/);
assert.match(publish,/git merge-base --is-ancestor \$mainSha \$env:GITHUB_SHA/);
assert.match(publish,/RELEASE_MISSING_LATEST_MAIN_PROGRESS/);
assert.ok(publish.indexOf('git merge-base --is-ancestor') < publish.indexOf('gh release create'),
'main ancestry must fail closed before the public release API call');
});

test('Windows public release ZIP is a verifiable wrapper of the same exact Inno EXE',()=>{
const publish=readFileSync(new URL('../.github/workflows/alpha-preview-publish.yml',import.meta.url),'utf8');
assert.match(publish,/Windows-x64-Setup\.zip/);
Expand Down
Loading