Shorebird CLI is installed on your machine (guide).
Codemagic is connected to your repository (guide).
Authentication
Most Shorebird functionality, like creating releases and patches, requires being
authenticated. In order to authenticate with Shorebird in CI, you will need to
generate a CI token.
You will be prompted to go through a similar OAuth Flow as when using shorebird login, however, shorebird login:ci will not store any credentials on your
device. Instead, it will output a base-64 encoded auth token that you will use
in your CI environment.
The output of this command should look something like:
Next, copy the generated SHOREBIRD_TOKEN and navigate to your Codemagic
secrets:
Select the “teams” tab on the left sidebar.
Select the team you want to add the secret to.
Select the “Global Variables and Secrets” tab.
Enter SHOREBIRD_TOKEN as variable name.
Paste the token into the variable value field.
Add it to a group named shorebird.
Ensure “Secure” is checked.
Set up an Android workflow
This section shows you how to set up a Codemagic workflow to create Android
releases, distribute them to the Play Store, and patch them once they’ve been
distributed.
As a preview, our finished codemagic.yaml file will look like this:
Prerequisites
Give Codemagic permission to publish to the Play Store
You can follow the Codemagic guide
here
to set this up. We put the GCLOUD_SERVICE_ACCOUNT_CREDENTIALS variable in a
group named play_store.
Set up your Android keystore in Codemagic
You can follow the Codemagic guide
here to create a
keystore and upload it to Codemagic. We used android_keystore as the name of
the uploaded keystore.
You will also also need to update your android/app/build.gradle file to
use this keystore in the Codemagic CI environment:
Create Shared Configuration
At the top of our codemagic.yaml file, define shared environment variables and
scripts that will be used by multiple workflows. This has been annotated to
explain what each part does.
Add the Android release workflow
Add the following workflow to your codemagic.yaml file. This has been
annotated to explain what each part does.
With this, you should be able to create a release in Shorebird and publish it
to the Google Play Store via Codemagic.
Add the Android patch workflow
Add the following workflow to your codemagic.yaml file. This has been
annotated to explain what each part does.
With this, you should be able to patch a release in Shorebird via Codemagic.
Set up an iOS workflow
This section shows you how to set up a Codemagic workflow to create iOS
releases, distribute them to TestFlight, and patch them once they’ve been
distributed.
Prerequisites
Prepare your iOS code signing
Codemagic has a guide on how to set up code signing for iOS
here. This
guide will help you generate the necessary keys, certificates, and provisioning
profiles and load them into Codemagic.
Once you’ve done that, you will need to make these available to your
codemagic.yaml scripts. You will end up with four environment variables to
support this:
KEY_ID: This will be copied directly from App Store Connect.
ISSUER_ID: This will be copied directly from App Store Connect.
APP_STORE_CONNECT_PRIVATE_KEY: This will be the contents of the private key
file you downloaded from App Store Connect. An easy way to get this into
Codemagic is to run cat /path/to/AuthKey_12345678.p8 | pbcopy which will
copy the contents of the file to your clipboard. You can then paste this into
Codemagic.
CERTIFICATE_PRIVATE_KEY: Follow this
guide
to obtain ios_distribution_private_key file. You can then paste the contents
of this file into Codemagic. cat ios_distribution_private_key | pbcopy works
well for this.
We put all of these variables into a group named app_store.
Create a shared configuration
At the top of our codemagic.yaml file, define shared environment variables and
scripts that will be used by multiple workflows. This has been annotated to
explain what each part does.
Add the iOS release workflow
Add the following workflow to your codemagic.yaml file. This has been
annotated to explain what each part does.
With this, you should be able to create a release in Shorebird and publish it
to TestFlight via Codemagic.
Add the iOS patch workflow
Add the following workflow to your codemagic.yaml file:
With this, you should be able to patch a release in Shorebird via Codemagic.