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
80 changes: 65 additions & 15 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
# 2. The plan job says what each platform would promote and links the
# builds; read it before approving.
# 3. The promote jobs wait on the `production` environment's required
# reviewers. Approve, and they run tool/publish_appcast.sh (macOS) and
# tool/windows/promote_release.ps1 (Windows), with their signing keys
# from that environment's secrets.
# reviewers. Approve, and they run tool/publish_appcast.sh (macOS),
# tool/windows/promote_release.ps1 (Windows) and
# tool/linux/promote_release.sh (Linux), with their signing keys from
# that environment's secrets.
# 4. Once they have succeeded, the release is tagged v<version> on GitHub
# (tool/tag_release.sh), on the commit that set the version.
#
# What is promoted is what the chosen commit names (pubspec.yaml's version and
# build, windows/release.json's build), and it must already be uploaded by the
# Release workflow. A platform whose build is already in its appcast is
# skipped, so promoting both after only one changed is safe.
# build, which Linux shares, and windows/release.json's build), and it must
# already be uploaded by the Release workflow. A platform whose build is
# already in its appcast is skipped, so promoting all after only one changed
# is safe.
#
# One-time setup — secrets, environments, Google Cloud: see the release
# specs/release_ci.md.
Expand All @@ -34,8 +36,8 @@ on:
description: Platforms to promote
required: true
type: choice
default: both
options: [both, macos, windows]
default: all
options: [all, macos, windows, linux]

concurrency:
group: release
Expand All @@ -58,6 +60,7 @@ jobs:
outputs:
macos: ${{ steps.pick.outputs.macos }}
windows: ${{ steps.pick.outputs.windows }}
linux: ${{ steps.pick.outputs.linux }}
steps:
- name: From main only
run: |
Expand Down Expand Up @@ -93,17 +96,22 @@ jobs:
MR: ${{ steps.plan.outputs.macos_reason }}
W: ${{ steps.plan.outputs.windows }}
WR: ${{ steps.plan.outputs.windows_reason }}
L: ${{ steps.plan.outputs.linux }}
LR: ${{ steps.plan.outputs.linux_reason }}
run: |
[[ "$WANT" == both || "$WANT" == macos ]] || M=skip
[[ "$WANT" == both || "$WANT" == windows ]] || W=skip
[[ "$WANT" == all || "$WANT" == macos ]] || M=skip
[[ "$WANT" == all || "$WANT" == windows ]] || W=skip
[[ "$WANT" == all || "$WANT" == linux ]] || L=skip
failed=0
[[ "$M" == error ]] && { echo "::error title=macOS cannot be promoted::$MR"; failed=1; }
[[ "$W" == error ]] && { echo "::error title=Windows cannot be promoted::$WR"; failed=1; }
if [[ "$M" == skip && "$W" == skip && "$failed" == 0 ]]; then
echo "::notice title=Nothing to promote::macOS: $MR. Windows: $WR."
[[ "$L" == error ]] && { echo "::error title=Linux cannot be promoted::$LR"; failed=1; }
if [[ "$M" == skip && "$W" == skip && "$L" == skip && "$failed" == 0 ]]; then
echo "::notice title=Nothing to promote::macOS: $MR. Windows: $WR. Linux: $LR."
fi
echo "macos=$M" >>"$GITHUB_OUTPUT"
echo "windows=$W" >>"$GITHUB_OUTPUT"
echo "linux=$L" >>"$GITHUB_OUTPUT"
exit "$failed"

- name: Summary
Expand All @@ -119,6 +127,10 @@ jobs:
WB: ${{ steps.plan.outputs.windows_build }}
WU: ${{ steps.plan.outputs.windows_url }}
WR: ${{ steps.plan.outputs.windows_reason }}
L: ${{ steps.plan.outputs.linux }}
LB: ${{ steps.plan.outputs.linux_build }}
LU: ${{ steps.plan.outputs.linux_url }}
LR: ${{ steps.plan.outputs.linux_reason }}
run: |
{
echo "### Promote $MV ($WANT) from \`${GITHUB_SHA:0:7}\`"
Expand All @@ -129,6 +141,7 @@ jobs:
echo "|---|---|---|---|---|"
echo "| macOS | $MB | $M | $MR | ${MU:+<$MU>} |"
echo "| Windows | $WB | $W | $WR | ${WU:+<$WU>} |"
echo "| Linux | $LB | $L | $LR | ${LU:+<$LU>} |"
} >>"$GITHUB_STEP_SUMMARY"

macos:
Expand Down Expand Up @@ -225,17 +238,54 @@ jobs:
Remove-Item $key -Force -ErrorAction SilentlyContinue
}

linux:
name: linux (appcast)
needs: plan
if: needs.plan.outputs.linux == 'promote'
runs-on: ubuntu-24.04
timeout-minutes: 20
environment: production
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_RELEASE_PROMOTE_SERVICE_ACCOUNT }}

- uses: google-github-actions/setup-gcloud@v2

# Same handling as the other keys: outside the checkout (the script
# refuses one inside it), readable only by this user, gone at the end
# of the step. The script checks it against eddsaPublicKey in
# linux/release.json before signing, and appcast.sh verifies the
# signature it made against that key.
- name: Promote into the appcast
env:
LINUX_KEY: ${{ secrets.LINUX_ED25519_PRIVATE_KEY }}
run: |
[[ -n "$LINUX_KEY" ]] || { echo "::error::secret LINUX_ED25519_PRIVATE_KEY is not set"; exit 1; }
key="$RUNNER_TEMP/linux_ed25519.pem"
(umask 077; printf '%s\n' "$LINUX_KEY" >"$key")
trap 'rm -f "$key"' EXIT
./tool/linux/promote_release.sh --key="$key" --bucket="$BUCKET"

# The release is live: tag it. On the commit that set the version, which is
# the one Release built, not on the head of main (tool/tag_release.sh). Runs
# when neither appcast job failed, including when the plan found both
# when no appcast job failed, including when the plan found them all
# already promoted, so a re-run can still add a tag that is missing.
tag:
name: tag
needs: [plan, macos, windows]
needs: [plan, macos, windows, linux]
if: >-
!cancelled() && needs.plan.result == 'success' &&
!contains(fromJSON('["failure", "cancelled"]'), needs.macos.result) &&
!contains(fromJSON('["failure", "cancelled"]'), needs.windows.result)
!contains(fromJSON('["failure", "cancelled"]'), needs.windows.result) &&
!contains(fromJSON('["failure", "cancelled"]'), needs.linux.result)
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
Expand Down
116 changes: 113 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Runs after CI passes on a push to main. When the commit names a build that
# is not in the bucket yet (`make set_version` was run and committed, or
# windows/release.json's build was bumped), it uploads that build exactly as
# `make publish` and tool/windows/publish_release.ps1 do: an immutable object
# under releases/, and the "preview" entry of downloads/<os>.json. The appcast
# `make publish`, tool/windows/publish_release.ps1 and
# tool/linux/publish_release.sh do: an immutable object under releases/, and
# the "preview" entry of downloads/<os>.json. The appcast
# is never touched, so no installed copy is offered the build. Test it from
# the URL in the run summary on a clean machine, then run the Promote
# workflow (promote.yml), which is the half that reaches users.
Expand All @@ -15,7 +16,8 @@
#
# macOS is built, signed and notarized here, as `make build` does locally. The
# Windows installer is the one the CI run for the same commit already built
# (ci.yml, `windows installer`), unsigned for now.
# (ci.yml, `windows installer`), unsigned for now. The Linux AppImage is
# built here with `make appimage`, on the oldest Ubuntu it supports.
#
# One-time setup — secrets, environments, Google Cloud: see the release
# specs/release_ci.md.
Expand Down Expand Up @@ -83,6 +85,11 @@ jobs:
windows_build: ${{ steps.plan.outputs.windows_build }}
windows_url: ${{ steps.plan.outputs.windows_url }}
windows_reason: ${{ steps.plan.outputs.windows_reason }}
linux: ${{ steps.plan.outputs.linux }}
linux_version: ${{ steps.plan.outputs.linux_version }}
linux_build: ${{ steps.plan.outputs.linux_build }}
linux_url: ${{ steps.plan.outputs.linux_url }}
linux_reason: ${{ steps.plan.outputs.linux_reason }}
steps:
- name: The commit and its CI run
id: ci
Expand All @@ -96,6 +103,9 @@ jobs:
# "cancelled" by running out its time — what the removed socket
# canary did on every run.
REQUIRED: macos-latest|windows-latest|windows installer
# Linux also needs its own test job; macOS and Windows do not wait
# on it.
REQUIRED_LINUX: ubuntu-24.04
run: |
if [[ "$EVENT" == workflow_run ]]; then
sha="$RUN_SHA" run="$RUN_ID"
Expand Down Expand Up @@ -123,6 +133,12 @@ jobs:
for job in "${required[@]}"; do
grep -qxF "$job"$'\t'success <<<"$jobs" || missing+="${missing:+, }$job"
done
linux_missing=""
IFS='|' read -ra required_linux <<<"$REQUIRED_LINUX"
for job in "${required_linux[@]}"; do
grep -qxF "$job"$'\t'success <<<"$jobs" || linux_missing+="${linux_missing:+, }$job"
done
echo "linux_missing=$linux_missing" >>"$GITHUB_OUTPUT"
if [[ -z "$missing" ]]; then
echo "ok=true" >>"$GITHUB_OUTPUT"
elif [[ "$EVENT" == workflow_run ]]; then
Expand All @@ -142,6 +158,7 @@ jobs:
id: plan
env:
CI_OK: ${{ steps.ci.outputs.ok }}
LINUX_MISSING: ${{ steps.ci.outputs.linux_missing }}
TEST_MACOS: ${{ inputs.test_macos_build || false }}
run: |
if [[ "$CI_OK" != true ]]; then
Expand All @@ -150,16 +167,27 @@ jobs:
echo "macos_reason=CI did not pass on this commit"
echo "windows=skip"
echo "windows_reason=CI did not pass on this commit"
echo "linux=skip"
echo "linux_reason=CI did not pass on this commit"
} | tee -a "$GITHUB_OUTPUT"
exit 0
fi
./tool/release_plan.sh upload | tee -a "$GITHUB_OUTPUT"
# A later key=value line wins in $GITHUB_OUTPUT.
if [[ -n "$LINUX_MISSING" ]]; then
{
echo "linux=skip"
echo "linux_reason=CI did not pass on this commit: $LINUX_MISSING"
} | tee -a "$GITHUB_OUTPUT"
fi
if [[ "$TEST_MACOS" == true ]]; then
{
echo "macos=test"
echo "macos_reason=test build: signed and notarized, not uploaded"
echo "windows=skip"
echo "windows_reason=test build of macOS only"
echo "linux=skip"
echo "linux_reason=test build of macOS only"
} | tee -a "$GITHUB_OUTPUT"
fi

Expand All @@ -169,6 +197,8 @@ jobs:
MR: ${{ steps.plan.outputs.macos_reason }}
W: ${{ steps.plan.outputs.windows }}
WR: ${{ steps.plan.outputs.windows_reason }}
L: ${{ steps.plan.outputs.linux }}
LR: ${{ steps.plan.outputs.linux_reason }}
SHA: ${{ steps.ci.outputs.sha }}
run: |
{
Expand All @@ -178,6 +208,7 @@ jobs:
echo "|---|---|---|"
echo "| macOS | $M | $MR |"
echo "| Windows | $W | $WR |"
echo "| Linux | $L | $LR |"
} >>"$GITHUB_STEP_SUMMARY"

macos:
Expand Down Expand Up @@ -383,3 +414,82 @@ jobs:
echo
echo "Then run the **Promote** workflow to make it the live update."
} >>"$GITHUB_STEP_SUMMARY"

linux:
name: linux (build the AppImage, upload)
needs: plan
if: needs.plan.outputs.linux != 'skip'
# The oldest Ubuntu the AppImage supports (glibc 2.38, specs/linux_appimage.md
# C1). A newer image can raise the glibc the bundle needs, and then
# build_appimage.sh stops at its glibc check rather than ship a build
# that no longer starts where the download page says it does.
runs-on: ubuntu-24.04
timeout-minutes: 60
environment: release-upload
permissions:
contents: read
id-token: write # Workload Identity Federation into Google Cloud
steps:
- name: Stop on a build number that is taken
if: needs.plan.outputs.linux == 'error'
env:
REASON: ${{ needs.plan.outputs.linux_reason }}
run: |
echo "::error title=Linux not uploaded::$REASON. Run 'make set_version V=…' and commit pubspec.yaml and windows/release.json."
exit 1

- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.sha }}

# Flutter's Linux desktop toolchain, and what build_appimage.sh needs
# besides (curl, python3, readelf and strip).
- name: Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev \
libstdc++-12-dev curl python3 binutils

- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.47.7
cache: true

# CEF is downloaded by the first CMake configure, and appimagetool and
# its runtime are fetched pinned and sha256-checked by the script. None
# of it is cached: these are the bytes we ship, as on macOS.
- name: Build the AppImage
run: |
flutter pub get
make appimage

- name: Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_RELEASE_UPLOAD_SERVICE_ACCOUNT }}

- uses: google-github-actions/setup-gcloud@v2

# Every gate runs again here: the build number against the live Linux
# appcast, the AppImage's own version against pubspec, a feed and a key
# in linux/release.json.
- name: Upload (preview only, the appcast is untouched)
run: ./tool/linux/publish_release.sh --bucket="$BUCKET"

- name: Summary
env:
V: ${{ needs.plan.outputs.linux_version }}
B: ${{ needs.plan.outputs.linux_build }}
URL: ${{ needs.plan.outputs.linux_url }}
run: |
{
echo "### Linux $V (build $B) uploaded"
echo
echo "Not in the appcast: no installed copy is offered it yet."
echo "Test it on a clean Ubuntu 24.04 or newer: <$URL>"
echo
echo "Then run the **Promote** workflow to make it the live update."
} >>"$GITHUB_STEP_SUMMARY"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ app.*.map.json
# Release / distribution artifacts
/dist/

# Update signing keys and local test feeds never belong in git: a private key
# here is one `git add -A` from public, and a test feed or test public key
# committed would ship in a release (specs/release_ci.md).
*.pem
/appcast*.xml

# --- macOS / Xcode / CocoaPods ---
/macos/Flutter/ephemeral/
/macos/Pods/
Expand Down
21 changes: 17 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,15 +1069,25 @@ full rationale are in `specs/release_ci.md`.
Mac). **Windows is the installer artifact from the CI run of the same
commit**, unsigned.
- **Windows is skipped while `windows/release.json` lacks `appcastUrl` or
`eddsaPublicKey`.** A build without them never checks for updates.
`eddsaPublicKey`, and Linux while `linux/release.json` does.** A build
without them never checks for updates.
- **Linux is built in Release itself**, `make appimage` on `ubuntu-24.04`
(the oldest Ubuntu it supports, so the glibc check in
`build_appimage.sh` holds), and uploaded by `tool/linux/publish_release.sh`
with the macOS gates. Its build number is pubspec's, so `set_version.sh`
also clears the Linux appcast and `downloads/linux.json`.
`tool/publish_downloads.sh --platform=linux` writes that pointer.
- **`promote.yml` is `workflow_dispatch` only.** You type the version as
confirmation, it runs from `main`, and the promote jobs wait for the
`production` environment's required reviewers. The keys come from that
environment's secrets as files in the runner's temp directory:
`SPARKLE_ED_KEY_FILE` for `publish_appcast.sh`, which checks the derived
public key (`tool/lib/eddsa_public_key.py`) against the shipped one, and
public key (`tool/lib/eddsa_public_key.py`) against the shipped one,
`-PrivateKeyFile` for `promote_release.ps1`, which checks against
`release.json` and verifies its own signature.
`release.json` and verifies its own signature, and `--key` for
`tool/linux/promote_release.sh`, which signs the bucket's object with
`appcast.sh` (verified against `linux/release.json`) and refuses to write
the production feed anywhere but that file's `appcastUrl`.
- **Google Cloud is Workload Identity Federation**, with no JSON keys. There
are two service accounts, each bound to one environment. The uploader can
only *create* under `releases/`, so IAM now enforces the immutability too.
Expand Down Expand Up @@ -2395,7 +2405,10 @@ change is behaviour-neutral on all three (a null check, say).
start page, unless another tool's entry already names App Studio.
- **Updates** (`lib/update/linux/`) are App Studio's own, from a Sparkle
appcast with an Ed25519 signature over the file, written by
`tool/linux/appcast.sh`. The feed URL and public key are in
`tool/linux/appcast.sh`. Release and Promote run it in CI like the other
two platforms (`specs/release_ci.md`): `appcast/linux/appcast.xml`,
`downloads/linux.json`, `releases/linux/<v>/b<n>/`, and the key in the
`LINUX_ED25519_PRIVATE_KEY` secret. The feed URL and public key are in
`linux/release.json`; both empty means no updates, and the build refuses
only one. The feed itself is not signed: nothing from it but the file may
be trusted, which is why the version is validated before it reaches the
Expand Down
Loading
Loading