GitHub Integration
The Setup Shorebird GitHub Action allows you to integrate Shorebird into your existing GitHub Workflows.
β Shorebird CLI is installed on your machine
β You are logged into a Shorebird account.
Refer to the getting started instructions for more information.
To integrate Shorebird into your CI, use the setup-shorebird
action. The setup-shorebird
action downloads Shorebird and adds it to the system path.
In the above workflow, weβre using the setup-shorebird
action to configure Shorebird in our CI and in subsequent steps we can execute any Shorebird commands.
Currently setup-shorebird
only supports the latest stable version of shorebird.
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, a Shorebird token will be generated for you to use in CI.
The output should look something like:
Next, copy the generated SHOREBIRD_TOKEN
and navigate to your GitHub repository secrets via:
"Settings" -> "Secrets and variables" -> "Actions"
.
Then, click "New repository secret"
and paste your SHOREBIRD_TOKEN
:
Now we can use the SHOREBIRD_TOKEN
in our GitHub workflow to perform authenticated functions such as creating patches π
The simplest way to create a release is using the official Shorebird GitHub Actions:
A fully automated workflow between your project repository and the CI service can allow developers to trigger deploys of your application just by pushing to the project repository, streamlining the development workflow, which can reduce the chance of error due to repetitive, manual tasks.
There are several ways of setting this up, and in many instances, how it is set up will depending on how the git workflow of your project is structured, or which CI service is used, among other factors.
This guide is a simple proposal for setting up a Fully automated workflow using GitHub Actions. It is intentionally simple so that it can be easily adapted to different requirements and contexts.
We will be implementing an automation in a project that have the following goals:
- Any branches created off from
main
that starts with the prefixrelease/
will trigger a release at Shorebird. - Any additional commits on those branches will trigger patches.
Before anything, if you donβt have a Shorebird account, be sure to create one at shorebird.dev (Donβt worry, it is free to start have a generous quota that is way more than enough for this guide).
You will also need a GitHub account and a project repository created. If you donβt have an account
yet, create one at GitHub, and create a new repository, which for this guide
we will call shorebird_automated_workflow
.
First thing, lets create a new Flutter project simply by running:
Be sure to initialize your project as a git repository:
Next we need to initialize shorebird in it! Check out the Code Push Getting Started guide for more info.
We provide a collection of official GitHub Actions to help you with the integration. For this guide
we will be using shorebird-setup
, shorebird-release
and shorebird-patch
, you can learn more
about them at the beginning of this page.
Create a new file at .github/workflows/shorebird_android.yml
with the following content:
Letβs take a closer look at the above workflow.
The workflow will be triggered whenever a push is made to a branch that starts with releases/
.
It will then run the clone of the repository and setup the Shorebird CLI.
Next the workflow is divided into two conditional steps. If the push is the one that created the branch, it will trigger a release. Otherwise it will trigger a patch.
Thatβs it! You should be able to push the changes to your repository and see the workflow running in the actions tab of your repository.
Give it a try! Create a new branch called releases/1.0.0
and push it to your repository:
That will trigger the action! Once the workflow finishes, check the Shorebird console and you should see a new release for your app.
Next lets make the following change in our app:
And commit and push it!
That will trigger the action again, but now a patch will be created π.
As mentioned, the workflow presented here is just one way of setting up a fully automated workflow. Feel free to adapt it based on your teams needs and existing processes.
Some ways the workflow can be expanded are:
- Instead of directly committing to the branch after the release was made. Developers would land their
changes and fixes on their main branch, and then
cherry-pick
it to the release branch! - Both
shorebird-release
andshorebird-patch
returns the version/patch-number created. The workflow could be expanded in order for tags to be created in the repository, using the version number returned allowing snapshots of the code to be easily identified.
See this workflow in action by checking out our Time Shift App.
Thank you for reading this guide! If you have any questions or suggestions, feel free to reach out to us at our Discord.