-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shorebirdtech/feat/action
feat: shorebird patch action
- Loading branch information
Showing
5 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
gha-deps: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: ci | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }} | ||
E2E_TEST_SHOREBIRD_YAML: ${{ secrets.E2E_TEST_SHOREBIRD_YAML }} | ||
|
||
jobs: | ||
semantic-pull-request: | ||
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1 | ||
|
||
e2e: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: 📚 Git Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: 🎯 Set up Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: stable | ||
cache: true | ||
|
||
- name: ☕ Set up Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: "17" | ||
|
||
- name: 🐦 Setup Shorebird | ||
uses: shorebirdtech/setup-shorebird@v1 | ||
|
||
- name: ✨ Create New Flutter Project | ||
run: flutter create e2e_test --empty | ||
|
||
- name: 🐦 Shorebird Init (MacOS/Linux) | ||
if: runner.os != 'Windows' | ||
run: echo "$E2E_TEST_SHOREBIRD_YAML" > shorebird.yaml | ||
working-directory: e2e_test | ||
|
||
- name: 🐦 Shorebird Init (Windows) | ||
if: runner.os == 'Windows' | ||
run: echo $env:E2E_TEST_SHOREBIRD_YAML > shorebird.yaml | ||
working-directory: e2e_test | ||
|
||
- name: 🐦 Shorebird Patch pubspec.yaml | ||
run: | | ||
echo " assets:" >> pubspec.yaml | ||
echo " - shorebird.yaml" >> pubspec.yaml | ||
working-directory: e2e_test | ||
|
||
- name: 🐦 Shorebird Doctor | ||
run: shorebird doctor --fix | ||
working-directory: e2e_test | ||
|
||
- name: 🐦 Shorebird Patch (MacOS/Linux) | ||
if: runner.os != 'Windows' | ||
uses: ./ | ||
id: shorebird-patch-unix | ||
with: | ||
args: --verbose | ||
platform: android | ||
working-directory: e2e_test | ||
|
||
- name: 🐦 Shorebird Patch (Windows) | ||
if: runner.os == 'Windows' | ||
uses: ./ | ||
id: shorebird-patch-windows | ||
with: | ||
# We only need allow-asset-diffs on Windows because the release was generated on a | ||
# macOS machine, so ignoring asset diffs for now. | ||
args: --verbose --allow-asset-diffs | ||
platform: android | ||
working-directory: e2e_test | ||
|
||
- name: 🚦 Assert Patch Number (MacOS/Linux) | ||
if: runner.os != 'Windows' | ||
run: | | ||
if [[ ${{ steps.shorebird-patch-unix.outputs.patch-number }} =~ ^-?[0-9]+$ ]]; then | ||
echo '✅ Shorebird Patch Succeeded!' | ||
else | ||
echo '❌ Shorebird Patch Failed.' | ||
exit 1 | ||
fi | ||
- name: 🚦 Assert Patch Version (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
if ("${{ steps.shorebird-patch-windows.outputs.patch-number }}" -match "^[0-9]+$") { | ||
Write-Output "✅ Shorebird Patch Succeeded!" | ||
} else { | ||
Write-Output "❌ Shorebird Patch Failed." | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Shorebird Patch | ||
|
||
[![ci](https://github.com/shorebirdtech/shorebird-patch/actions/workflows/main.yaml/badge.svg)](https://github.com/shorebirdtech/shorebird-patch/actions/workflows/main.yaml) | ||
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) | ||
|
||
Create a new patch using the [Shorebird CLI](https://github.com/shorebirdtech/shorebird) for use in GitHub Actions. | ||
|
||
## Features | ||
|
||
✅ Create new Android patches | ||
|
||
✅ Create new iOS patches | ||
|
||
✅ Outputs the patch number | ||
|
||
## Usage | ||
|
||
```yaml | ||
steps: | ||
- uses: shorebirdtech/setup-shorebird@v0 | ||
- uses: shorebirdtech/shorebird-patch@v0 | ||
id: shorebird-patch | ||
with: | ||
platform: android | ||
working-directory: ./path/to/app | ||
|
||
- run: echo patch-number ${{ steps.shorebird-patch.outputs.patch-number }} | ||
shell: bash | ||
``` | ||
## Inputs | ||
The action takes the following inputs: | ||
- `args`: Any arguments to pass to `shorebird patch`. | ||
- Use an extra `--` to pass arguments to Flutter (e.g. `-- --dart-define=KEY=VALUE`) | ||
- `platform`: Which platform to create a patch for (e.g. `android` or `ios`) | ||
- `working-directory`: Which directory to run `shorebird patch` in. | ||
|
||
## Outputs | ||
|
||
The actions outputs the following: | ||
|
||
- `patch-number`: The number of the patch that was successfully created. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Releasing Patch Shorebird | ||
|
||
These are the steps needed to create a new release: | ||
|
||
1. Create a new release in GitHub | ||
- Click on `Releases -> Draft a new release` | ||
1. Make sure to name the release `v<VERSION>` (e.g. v1.2.3) | ||
1. Click on `Generate release notes` | ||
1. Click on `Publish release` | ||
1. Update the current major version tag to point to the latest release. For example, if we just released v0.1.2, we'll need to make sure the `v0` tag points to the same commit as `v0.1.2` | ||
```sh | ||
# force update the latest release tag | ||
git tag -f v0 v0.1.2 | ||
# push the tag | ||
git push origin :refs/tags/v0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Shorebird Patch | ||
description: Create a new patch using the Shorebird CLI | ||
|
||
branding: | ||
icon: package | ||
color: green | ||
|
||
inputs: | ||
args: | ||
description: The arguments to pass to the Shorebird patch command | ||
required: false | ||
default: "" | ||
platform: | ||
description: The platform for which to create a patch (e.g. android, ios) | ||
required: true | ||
working-directory: | ||
description: The working directory in which to run Shorebird | ||
required: false | ||
default: . | ||
|
||
outputs: | ||
patch-number: | ||
description: The number of the patch that was created. | ||
value: ${{ steps.shorebird-patch.outputs.patch-number }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: 🐦 Shorebird Patch | ||
shell: bash | ||
id: shorebird-patch | ||
working-directory: ${{ inputs.working-directory }} | ||
run: | | ||
shorebird patch ${{ inputs.platform }} ${{ inputs.args }} | tee output.log | ||
GREP_MATCH=$(grep -Ei "Published Patch (.*)" output.log) | ||
if [[ $GREP_MATCH ]]; then | ||
# Strip the non-version-number characters from the line | ||
PATCH_NUMBER=$(echo $GREP_MATCH | sed -E 's/^.+ Published Patch (.*)\!$/\1/') | ||
echo "patch-number=$(echo $PATCH_NUMBER)" >> $GITHUB_OUTPUT | ||
else | ||
echo "Failed to create patch" | ||
exit 1 | ||
fi |