Skip to content

Commit 6a6e49b

Browse files
committed
ci: harden post-release distribution sync
1 parent 616bd9d commit 6a6e49b

1 file changed

Lines changed: 69 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,17 +483,17 @@ jobs:
483483
needs: [publish]
484484
runs-on: ubuntu-latest
485485
if: github.event_name == 'push' && !contains(github.ref_name, '-')
486-
continue-on-error: true
487486
permissions:
488487
contents: write
488+
pull-requests: write
489489
steps:
490490
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
491491
with:
492492
# Check out the default branch (not the tag) so the commit lands
493493
# on main. We pass the version explicitly to the script.
494494
ref: main
495495
fetch-depth: 0
496-
token: ${{ secrets.GITHUB_TOKEN }}
496+
token: ${{ secrets.RELEASE_BOT_TOKEN || secrets.GITHUB_TOKEN }}
497497

498498
- name: Derive version from tag
499499
id: ver
@@ -519,7 +519,26 @@ jobs:
519519
git commit -m "$msg"
520520
# Rebase in case main advanced while the release job ran.
521521
git pull --rebase origin main
522-
git push origin HEAD:main
522+
if git push origin HEAD:main; then
523+
echo "::notice::pushed packaging manifest sync directly to main"
524+
exit 0
525+
fi
526+
527+
branch="release/${GITHUB_REF_NAME}-manifests"
528+
git push --force origin HEAD:"$branch"
529+
existing_pr="$(gh pr list --head "$branch" --json number --jq '.[0].number // empty')"
530+
if [ -z "$existing_pr" ]; then
531+
gh pr create \
532+
--base main \
533+
--head "$branch" \
534+
--title "chore(release): sync manifests to ${GITHUB_REF_NAME}" \
535+
--body "Auto-generated by .github/workflows/release.yml after publishing ${GITHUB_REF_NAME}. Pulls SHA256SUMS.txt from the release and rewrites cask / scoop / winget / flatpak manifests to match."
536+
fi
537+
pr_number="$(gh pr list --head "$branch" --json number --jq '.[0].number')"
538+
gh pr merge "$pr_number" --auto --squash
539+
echo "::notice::opened packaging manifest PR #${pr_number} and enabled auto-merge"
540+
env:
541+
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN || secrets.GITHUB_TOKEN }}
523542

524543
# ------------------------------------------------------------------
525544
# Scoop bucket bump — publishes the generated manifest to the actual
@@ -595,7 +614,6 @@ jobs:
595614
needs: [publish]
596615
runs-on: macos-latest
597616
if: github.event_name == 'push' && !contains(github.ref_name, '-')
598-
continue-on-error: true
599617
steps:
600618
- name: Guard on secret
601619
id: guard
@@ -607,15 +625,41 @@ jobs:
607625
echo "skip=false" >> "$GITHUB_OUTPUT"
608626
fi
609627
610-
- name: Bump cask
628+
- name: Checkout source
611629
if: steps.guard.outputs.skip == 'false'
612-
uses: macauley/action-homebrew-bump-cask@445c42390d790569d938f9068d01af39ca030feb # v1
630+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
631+
with:
632+
path: source
633+
ref: ${{ github.ref }}
634+
635+
- name: Generate cask from release checksums
636+
if: steps.guard.outputs.skip == 'false'
637+
working-directory: source
638+
run: ./packaging/update-shas.sh "${GITHUB_REF_NAME#v}"
639+
640+
- name: Checkout Homebrew tap
641+
if: steps.guard.outputs.skip == 'false'
642+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
613643
with:
644+
repository: OpenCoworkAI/homebrew-tap
645+
path: homebrew-tap
614646
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
615-
tap: OpenCoworkAI/homebrew-tap
616-
cask: open-codesign
617-
tag: ${{ github.ref_name }}
618-
force: false
647+
648+
- name: Commit + push cask
649+
if: steps.guard.outputs.skip == 'false'
650+
run: |
651+
mkdir -p homebrew-tap/Casks
652+
cp source/packaging/homebrew/Casks/open-codesign.rb homebrew-tap/Casks/open-codesign.rb
653+
cd homebrew-tap
654+
if git diff --quiet Casks/open-codesign.rb; then
655+
echo "::notice::Homebrew tap already up to date — no commit"
656+
exit 0
657+
fi
658+
git config user.name "github-actions[bot]"
659+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
660+
git add Casks/open-codesign.rb
661+
git commit -m "open-codesign ${GITHUB_REF_NAME#v}"
662+
git push
619663
620664
# ------------------------------------------------------------------
621665
# Winget manifest PR — submits to microsoft/winget-pkgs.
@@ -630,7 +674,6 @@ jobs:
630674
needs: [publish]
631675
runs-on: windows-latest
632676
if: github.event_name == 'push' && !contains(github.ref_name, '-')
633-
continue-on-error: true
634677
steps:
635678
- name: Guard on secret
636679
id: guard
@@ -643,8 +686,22 @@ jobs:
643686
echo "skip=false" >> "$GITHUB_OUTPUT"
644687
fi
645688
646-
- name: Release winget package
689+
- name: Check existing winget package
647690
if: steps.guard.outputs.skip == 'false'
691+
id: winget-package
692+
shell: pwsh
693+
run: |
694+
$ErrorActionPreference = 'SilentlyContinue'
695+
Invoke-RestMethod -Uri 'https://api.github.com/repos/microsoft/winget-pkgs/contents/manifests/o/OpenCoworkAI/OpenCoDesign' -Method Get | Out-Null
696+
if ($?) {
697+
"exists=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
698+
} else {
699+
"exists=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
700+
Write-Output "::notice::OpenCoworkAI.OpenCoDesign is not in microsoft/winget-pkgs yet; skipping automated winget update until the initial manifest is accepted."
701+
}
702+
703+
- name: Release winget package
704+
if: steps.guard.outputs.skip == 'false' && steps.winget-package.outputs.exists == 'true'
648705
uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
649706
with:
650707
identifier: OpenCoworkAI.OpenCoDesign

0 commit comments

Comments
 (0)