Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Watch for Chromium security updates; one command to build them

Victor65eb6edfc1c0
diff --git a/.github/workflows/cef-updates.yml b/.github/workflows/cef-updates.yml
new file mode 100644
index 0000000..cd51019
--- /dev/null
+++ b/.github/workflows/cef-updates.yml
@@ -0,0 +1,25 @@
+name: CEF updates
+
+# Daily check for a newer stable CEF (Chromium) than the one Cra ships. When there
+# is one, scripts/check-cef-update.sh opens an issue with the command that builds
+# it on the Mac (scripts/update-cef.sh); the build itself does not run here.
+on:
+ schedule:
+ - cron: "23 6 * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ issues: write
+
+jobs:
+ check:
+ name: Compare pinned CEF with the newest stable
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Check for a newer CEF
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: scripts/check-cef-update.sh
diff --git a/docs/release.md b/docs/release.md
index edb8ac5..160707d 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -149,6 +149,19 @@ from a different source. To change the build without a CEF version bump, bump th
`codecsN` suffix of `CEF_RELEASE` and publish again. Needs Xcode's Metal toolchain
(`xcodebuild -downloadComponent MetalToolchain`).
+**Staying current.** Chromium only ships security fixes for its newest version. The
+"CEF updates" workflow (`.github/workflows/cef-updates.yml`, daily, free Linux runner)
+runs `scripts/check-cef-update.sh`: when Spotify's index lists a newer stable CEF for
+macOS arm64, it opens one "Chromium engine update available" issue, assigned to the repo
+owner, with the exact command. The build itself runs on the Mac, because GitHub's free
+macOS runners are too small (3 cores, 14 GB disk, 6 hour jobs) and larger ones are billed:
+
+ scripts/update-cef.sh <cef_version> # build, publish, pin, rebuild Cra
+
+A same-major update reuses the checkout (1–2 hours); a new Chromium major compiles
+everything again. Then test `build/Cra.app`, commit `scripts/fetch-cef.sh`, close the
+issue and tag a release.
+
## Later
- **Homebrew.** A cask (`brew install --cask cra`) pointing at the DMG and
diff --git a/scripts/build-cef.sh b/scripts/build-cef.sh
index b1a0838..f8aaa4d 100755
--- a/scripts/build-cef.sh
+++ b/scripts/build-cef.sh
@@ -6,17 +6,21 @@
# compile-time switch in Chromium and FFmpeg is linked into the framework, so the
# only fix is building CEF ourselves with proprietary_codecs + ffmpeg_branding=Chrome.
#
-# Same CEF commit as the pinned prebuilt (scripts/fetch-cef.sh); besides the codecs
-# only the fixes in scripts/cef-patches/ change. Needs ~80 GB free and several hours on an M2 Max. Re-running
-# resumes: the checkout is kept and ninja only rebuilds what changed.
+# Builds the CEF_VERSION pinned in scripts/fetch-cef.sh (or the one in the environment;
+# scripts/update-cef.sh does that); besides the codecs only the fixes in
+# scripts/cef-patches/ change. Needs ~80 GB free and several hours on an M2 Max.
+# Re-running resumes: the checkout is kept and ninja only rebuilds what changed.
#
# Output: $CEF_BUILD_DIR/chromium/src/cef/binary_distrib/cef_binary_<ver>_macosarm64_minimal.tar.bz2
-# Publish it with scripts/publish-cef.sh, then bump CEF_FLAVOR in fetch-cef.sh.
+# Publish it with scripts/publish-cef.sh.
set -euo pipefail
cd "$(dirname "$0")/.."
-CEF_BRANCH="${CEF_BRANCH:-8037}"
-CEF_COMMIT="${CEF_COMMIT:-14c5a08}"
+eval "$(grep -E '^CEF_VERSION=' scripts/fetch-cef.sh)"
+# 154.0.34+g14c5a08+chromium-154.0.8037.98: CEF commit 14c5a08 on branch 8037.
+CEF_COMMIT="$(sed -E 's/.*\+g([0-9a-f]+)\+.*/\1/' <<<"$CEF_VERSION")"
+CEF_BRANCH="$(sed -E 's/.*chromium-[0-9]+\.[0-9]+\.([0-9]+)\..*/\1/' <<<"$CEF_VERSION")"
+echo "Building CEF $CEF_VERSION (branch $CEF_BRANCH, commit $CEF_COMMIT)"
# .noindex keeps Spotlight out of ~40 GB of sources.
CEF_BUILD_DIR="${CEF_BUILD_DIR:-$HOME/cef-build.noindex}"
@@ -31,10 +35,13 @@ if [ ! -d "$CEF_BUILD_DIR/depot_tools" ]; then
fi
# Bootstrap once (python, gn); DEPOT_TOOLS_UPDATE=0 below keeps it from updating.
[ -f "$CEF_BUILD_DIR/depot_tools/python3_bin_reldir.txt" ] || "$CEF_BUILD_DIR/depot_tools/ensure_bootstrap" || true
-if [ ! -f "$CEF_BUILD_DIR/automate/automate-git.py" ]; then
- mkdir -p "$CEF_BUILD_DIR/automate"
+# automate-git.py from the branch being built (it changes between branches).
+AUTOMATE="$CEF_BUILD_DIR/automate/$CEF_BRANCH/automate-git.py"
+if [ ! -f "$AUTOMATE" ]; then
+ mkdir -p "$(dirname "$AUTOMATE")"
+ rm -rf "$CEF_BUILD_DIR/cef-tools"
git -C "$CEF_BUILD_DIR" clone --depth 1 --branch "$CEF_BRANCH" https://github.com/chromiumembedded/cef.git cef-tools
- cp "$CEF_BUILD_DIR/cef-tools/tools/automate/automate-git.py" "$CEF_BUILD_DIR/automate/"
+ cp "$CEF_BUILD_DIR/cef-tools/tools/automate/automate-git.py" "$AUTOMATE"
rm -rf "$CEF_BUILD_DIR/cef-tools"
fi
@@ -45,7 +52,7 @@ export CEF_ARCHIVE_FORMAT=tar.bz2
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome symbol_level=0 blink_symbol_level=0 v8_symbol_level=0 enable_dsyms=false"
automate() {
- python3 "$CEF_BUILD_DIR/automate/automate-git.py" \
+ python3 "$AUTOMATE" \
--download-dir="$CEF_BUILD_DIR" \
--depot-tools-dir="$CEF_BUILD_DIR/depot_tools" \
--branch="$CEF_BRANCH" \
diff --git a/scripts/check-cef-update.sh b/scripts/check-cef-update.sh
new file mode 100755
index 0000000..d0207ed
--- /dev/null
+++ b/scripts/check-cef-update.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Compares the CEF pinned in scripts/fetch-cef.sh with the newest stable CEF for
+# macOS arm64 and, when Cra is behind, opens (or updates) one "Chromium engine
+# update" issue saying how to build it. Run daily by .github/workflows/cef-updates.yml.
+# scripts/check-cef-update.sh --dry-run print instead of touching issues
+set -euo pipefail
+cd "$(dirname "$0")/.."
+
+eval "$(grep -E '^CEF_VERSION=' scripts/fetch-cef.sh)"
+LATEST="$(curl -fsSL https://cef-builds.spotifycdn.com/index.json |
+ jq -r '[.macosarm64.versions[] | select(.channel == "stable")][0].cef_version')"
+[ -n "$LATEST" ] && [ "$LATEST" != null ] || { echo "Could not read the CEF index" >&2; exit 1; }
+
+major() { cut -d. -f1 <<<"$1"; }
+chromium() { sed 's/.*chromium-//' <<<"$1"; }
+echo "Pinned: $CEF_VERSION"
+echo "Latest: $LATEST"
+if [ "$LATEST" = "$CEF_VERSION" ] || [ "$(printf '%s\n%s\n' "$LATEST" "$CEF_VERSION" | sort -V | tail -1)" = "$CEF_VERSION" ]; then
+ echo "Cra is up to date."
+ exit 0
+fi
+
+if [ "$(major "$LATEST")" = "$(major "$CEF_VERSION")" ]; then
+ KIND="a security/bug-fix update on the same Chromium version, so the build reuses the existing checkout (typically 1-2 hours)"
+else
+ KIND="a new Chromium version ($(major "$CEF_VERSION") → $(major "$LATEST")), so the build fetches a new checkout and compiles everything (3-4 hours, ~80 GB free)"
+fi
+TITLE="Chromium engine update available"
+BODY="$(cat <<EOF
+Cra ships CEF \`$CEF_VERSION\` (Chromium $(chromium "$CEF_VERSION")). The newest stable CEF is **\`$LATEST\`** (Chromium $(chromium "$LATEST")).
+
+This is $KIND. Chromium only ships security fixes for its newest version, so Cra should move soon.
+
+On the Mac that builds the engine:
+
+\`\`\`sh
+scripts/update-cef.sh $LATEST
+\`\`\`
+
+It builds CEF with H.264/AAC and \`scripts/cef-patches\`, publishes it as the \`cef-${LATEST%%+*}-codecs1\` pre-release and pins it in \`scripts/fetch-cef.sh\`. Then test \`build/Cra.app\`, commit and tag a release. If a patch in \`scripts/cef-patches\` no longer applies, the build stops and says which one.
+
+_Checked daily by the CEF updates workflow; this issue is updated when an even newer CEF appears._
+EOF
+)"
+
+if [ "${1:-}" = --dry-run ]; then
+ echo "--- would open or update issue: $TITLE"
+ echo "$BODY"
+ exit 0
+fi
+EXISTING="$(gh issue list --state open --search "\"$TITLE\" in:title" --json number,body -q '.[0]')"
+if [ -z "$EXISTING" ]; then
+ gh issue create --title "$TITLE" --body "$BODY" --assignee "${GITHUB_REPOSITORY_OWNER:-@me}"
+elif ! grep -qF "$LATEST" <<<"$(jq -r .body <<<"$EXISTING")"; then
+ gh issue edit "$(jq -r .number <<<"$EXISTING")" --body "$BODY"
+ gh issue comment "$(jq -r .number <<<"$EXISTING")" --body "Newer CEF available: \`$LATEST\`. The steps above are updated."
+else
+ echo "Issue already up to date."
+fi
diff --git a/scripts/update-cef.sh b/scripts/update-cef.sh
new file mode 100755
index 0000000..800e78f
--- /dev/null
+++ b/scripts/update-cef.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Moves Cra to a newer CEF: builds it with codecs, publishes it, then pins it.
+# scripts/update-cef.sh 156.0.14+g4fa4ab5+chromium-156.0.8078.48
+# The version comes from the "Chromium engine update" issue that the CEF updates
+# workflow opens (scripts/check-cef-update.sh). Runs for hours on this Mac; ~80 GB.
+# fetch-cef.sh is only switched once the build is published, so other builds keep
+# working meanwhile. Afterwards: test build/Cra.app, commit, tag a release.
+set -euo pipefail
+cd "$(dirname "$0")/.."
+
+NEW="${1:?usage: scripts/update-cef.sh <cef_version>}"
+[[ "$NEW" =~ ^[0-9]+\.[0-9]+\.[0-9]+\+g[0-9a-f]+\+chromium-[0-9.]+$ ]] || { echo "Not a CEF version: $NEW" >&2; exit 1; }
+
+export CEF_VERSION="$NEW"
+export CEF_RELEASE="cef-${NEW%%+*}-codecs1"
+scripts/build-cef.sh
+scripts/publish-cef.sh
+unset CEF_VERSION CEF_RELEASE
+
+# Pin it; a new CEF version starts again at codecs1.
+sed -i '' -E "s/^CEF_VERSION=.*/CEF_VERSION=\"\${CEF_VERSION:-$NEW}\"/; s/-codecs[0-9]+\}/-codecs1}/" scripts/fetch-cef.sh
+scripts/fetch-cef.sh
+scripts/build.sh
+echo "Cra now builds with CEF $NEW. Test build/Cra.app, then commit scripts/fetch-cef.sh and tag a release."