Linked Patches
When you patch multiple platforms from the same code, Shorebird gives those
patches the same patch number. Patch 3 on Android and Patch 3 on iOS are the
same fix, so your release notes, support tickets, and patch number your app
reads from package:shorebird_code_push all agree. Platforms maintain their own
patch lifecycle beneath the hood, so each platform can roll back or roll forward
and move between tracks independently.
Linking needs Shorebird TODO: version or newer and happens automatically;
there is nothing to turn on.
How patches are linked
Section titled “How patches are linked”Patches on the same release with the same link key share a patch number. The CLI chooses the link key for you:
Where you run shorebird patch | Link key |
|---|---|
| A git checkout with no uncommitted changes | The current commit’s SHA |
| CI, with uncommitted changes | The current commit’s SHA |
| Anywhere else, with uncommitted changes | None: the patch is not linked |
| Outside a git checkout, several platforms | A random key shared by the platforms in that run |
| Outside a git checkout, one platform | None: the patch is not linked |
Any of the above, with --patch-key | The value you pass |
Uncommitted changes include untracked files anywhere in the repository, not only in your app’s directory. On CI, uncommitted files are usually build output, so the CLI still links by commit and records that the tree was modified. On your own machine, uncommitted changes mean the build may not match the commit, so the CLI does not link and tells you how to link anyway. Linking only changes the number: each platform’s patch keeps its own artifacts, track, rollout percentage and rollback state. Devices only download their own platform’s patch.
Patch several platforms in one run
Section titled “Patch several platforms in one run”shorebird patch --platforms=android,ios publishes one patch per platform under
a single number, unless the tree has uncommitted changes outside CI (see
How patches are linked). When a platform joins a
number another platform already has, the CLI says so, for example
Linked iOS to patch 3 (Android, commit abc1234). The run ends with one line
listing each patch number and its platforms, for example
Published patch 3 (Android, iOS)!, or
Published patch 3 (Android) and patch 4 (iOS)! when a platform isn’t linked.
Platforms whose releases have different release versions are never linked.
Link patches built in separate jobs
Section titled “Link patches built in separate jobs”Most CI setups build Android and iOS in separate jobs, and those jobs link with no extra flags when they build the same commit. Whichever job finishes first takes the next number, and the other job’s platform joins it.
When the jobs build from different checkouts, or the tree differs between jobs,
pass the same --patch-key to each, such as --patch-key "$GITHUB_SHA" or your
build ID to link manually. Re-running a job from a clean checkout of the same
commit skips a platform that has already published an identical build from it,
as long as that patch is the platform’s newest, isn’t rolled back and is on the
same track. If the build differs, for example because a --dart-define changed,
the CLI says so and publishes it again. With --patch-key, or with uncommitted
changes on CI, the CLI can’t match the new build to the published patch, so a
re-run publishes another patch for that platform under a new number. An
unfinished patch from an earlier attempt is resumed instead of created again.
When a later platform fails in a run with a random key, the CLI prints the
command that finishes the other platforms under the same key. With --json, the
error output’s data carries link_key, the patches already published and
the unfinished_platforms.
When a patch isn’t linked
Section titled “When a patch isn’t linked”A patch that can’t join a number takes the next number instead, and the CLI
prints Not linked: followed by the reason.
The platform already has a newer patch
Section titled “The platform already has a newer patch”A platform only joins a number newer than its own newest patch on the release.
Joining an older number would make the new patch rank below a patch devices
already have, so they would never receive it. Example: Android has patch 4 and
iOS published patch 3 from commit abc1234; a later Android build of abc1234
takes patch 5.
The number is rolled back on a platform
Section titled “The number is rolled back on a platform”A platform doesn’t join a number that is rolled back on any platform. Roll the number forward first if you want the new platform to join it, or let it take a new number.
Turn linking off
Section titled “Turn linking off”Pass --no-link to give a patch its own number. --add-to-patch adds a build
to an existing patch, so it takes neither --patch-key nor --no-link.
Manage a linked patch
Section titled “Manage a linked patch”The shorebird patches commands that take --patch-number act on every
platform under that number unless you pass --platforms. With more than one
platform, in an interactive terminal, the CLI lists them and asks before it
changes anything. On CI or with --json it doesn’t ask, so a script that runs
patches rollback --patch-number 3 rolls back every platform under patch 3.
Pass --platforms in scripts.
Act on every platform
Section titled “Act on every platform”shorebird patches rollback --release-version 1.0.0+1 --patch-number 3 rolls
back the Android and iOS patches under patch 3. rollforward, set-track (or
promote) and rollout work the same way.
Act on some platforms
Section titled “Act on some platforms”Pass --platforms to choose platforms, for example to roll back iOS only while
Android stays live.
When the platforms differ
Section titled “When the platforms differ”When the platforms under a number are in different states, some commands refuse to act on all of them. They list each platform’s state and print the command that acts on the platforms they can change.
| Command | Refuses without --platforms when |
|---|---|
rollback | Never. It rolls back the platforms that aren’t rolled back yet. |
rollforward | Some platforms are rolled back and some aren’t, or the rolled-back platforms are on different tracks and one of them is protected. |
set-track or promote | The platforms are on different tracks, or some are rolled back and some aren’t. |
rollout | The platforms are on different tracks, some are rolled back and some aren’t, or one is on no track. |
Patches on the same track at different rollout percentages count as on the same
track. patches rollout also refuses, even with --platforms, when the
platforms you name are on different tracks, or when one is already rolling out
to a higher percentage than the one you asked for. set-track leaves a platform
that’s already on the target track where it is and moves the others.
See a linked patch
Section titled “See a linked patch”shorebird patches list prints one line per patch number with its platforms,
and each platform’s track and rollout when they differ:
shorebird patches info shows each platform’s patch under the number and takes
--platforms.
In the console
Section titled “In the console”The Console groups a linked number’s platforms together. This includes in analytics, where patch adoption and activity are measured by the linked patch number. Each action can apply to the whole number or to one platform.
Older versions of the CLI
Section titled “Older versions of the CLI”CLI versions before TODO: version act on every platform of a number when they
roll back, roll forward, promote or raise a rollout. When the platforms are in
different states, the server refuses rollforward, promote and rollout from those
versions, following the table above, and asks you to upgrade the CLI or use the
Console. Those versions’ patches list prints one line per platform’s patch,
with its ID.
What Shorebird records
Section titled “What Shorebird records”Every patch built in a git checkout records a digest of the commit SHA it was
built from and whether the tree had uncommitted changes, even when it isn’t
linked. A patch created with a link key stores the key as-is, whether or not it
joined a number; by default the key is the full commit SHA. Outside a git
checkout, no commit is recorded. The --json output of shorebird patch and
shorebird patches info includes the link key.
Reference
Section titled “Reference”| Flag | Command | Description |
|---|---|---|
--patch-key | shorebird patch | Links by this key instead of the commit. At most 255 characters. |
--no-link | shorebird patch | Gives the patch its own number. |
--platforms | shorebird patches rollback, rollforward, set-track, promote, rollout, info | Acts on these platforms only. Defaults to every platform under the number. |
JSON output
Section titled “JSON output”shorebird patch --json adds link_key, and each entry in patches adds
already_published and link_result. When a run fails partway, data carries
link_key, patches and unfinished_platforms. shorebird patches rollback,
rollforward, set-track, promote, rollout and info with --json add a
patches list with one entry per platform.
Errors
Section titled “Errors”The server returns these codes for a linked patch:
patch_platforms_differ: the platforms under the number are in different states and the request didn’t name platforms.patch_platform_not_found: a platform in--platformshas no patch under the number.patch_platforms_on_several_tracks: the platforms named are on different tracks, for a rollout, or for a rollforward where one of the tracks is protected.patch_not_on_channel: a rollout, or a rollforward with a rollout schedule, covers a patch that is on no track.
Frequently asked questions
Section titled “Frequently asked questions”Can I link patches after they’re published?
Section titled “Can I link patches after they’re published?”No, a patch’s number is set when it is created.
Does linking change what devices download?
Section titled “Does linking change what devices download?”No, each device downloads its own platform’s patch.
What happens if I patch only one platform?
Section titled “What happens if I patch only one platform?”The patch takes the next number.
Does rolling back on Android affect iOS?
Section titled “Does rolling back on Android affect iOS?”Only if you don’t pass --platforms: without it, a rollback applies to every
platform under the number.