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.
To integrate Shorebird into your CI, use the setup-shorebird
action. The
setup-shorebird
action downloads Shorebird and adds it to the system path.
name: Shorebird Workflow Example
on: workflow_dispatch:
jobs: example: defaults: run: shell: bash
runs-on: ubuntu-latest
steps: # Use the setup-shorebird action to configure Shorebird - name: π¦ Setup Shorebird uses: shorebirdtech/setup-shorebird@v1 with: cache: true # Optionally cache your Shorebird installation
# Now we're able to use Shorebird CLI in our workflow - name: π Use Shorebird run: shorebird --version
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.
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.
shorebird login:ci
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:
$ shorebird login:ciThe Shorebird CLI needs your authorization to manage apps, releases, and patches on your behalf.
In a browser, visit this URL to log in:
https://accounts.google.com/o/oauth2/v2/auth...
Waiting for your authorization...
π Success! Use the following token to login on a CI server:
qwerasdf1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqwer1234asdfqw==
Example:
export SHOREBIRD_TOKEN="$SHOREBIRD_TOKEN" && shorebird patch android
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
:
name: SHOREBIRD_TOKENsecret: <THE GENERATED 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:
name: Shorebird Release
on: workflow_dispatch:
env: SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
jobs: release: defaults: run: shell: bash
runs-on: ubuntu-latest
steps: - name: π Git Checkout uses: actions/checkout@v3
- name: π¦ Setup Shorebird uses: shorebirdtech/setup-shorebird@v1 with: cache: true
- name: Set up Java uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17'
- name: π Shorebird Release uses: shorebirdtech/shorebird-release@v0 with: platform: android # or 'ios'
name: Shorebird Patch
on: workflow_dispatch:
env: SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
jobs: patch: defaults: run: shell: bash
runs-on: ubuntu-latest
steps: - name: π Git Checkout uses: actions/checkout@v3
- name: π¦ Setup Shorebird uses: shorebirdtech/setup-shorebird@v1 with: cache: true
- name: Set up Java uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17'
# Note: all signing information (key.properties, etc.) must be set up on # this runner for `shorebird patch android` to work. - name: π Shorebird Patch uses: shorebirdtech/shorebird-patch@v0 with: platform: android # or 'ios'
:::
tip The shorebird-patch
action also outputs the patch number:
- name: π Shorebird Patch id: shorebird-patch uses: shorebirdtech/shorebird-patch@v0 with: platform: android # or 'ios'
- name: π Output Patch Version run: echo ${{ steps.shorebird-patch.outputs.patch-number }}
:::
For an example of a fully automated development workflow, see our Development Workflow Guide.