|
1 | | -# flutter-workflow |
| 1 | +# Flutter Workflow |
2 | 2 |
|
3 | | -TODO: README |
| 3 | +[](https://github.com/RubberDuckCrew/flutter-workflow/releases) |
| 4 | +[](https://github.com/RubberDuckCrew/flutter-workflow/actions/workflows/check-release.yml) |
| 5 | +[](https://github.com/RubberDuckCrew/flutter-workflow/commits/main) |
| 6 | +[](LICENSE) |
| 7 | + |
| 8 | +A reusable GitHub Actions workflow to **test, build, analyze, and release Flutter applications** with minimal setup. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Runs **formatting, analysis, and tests** automatically. |
| 13 | +- Builds **APK and App Bundle (AAB)** artifacts. |
| 14 | +- Supports **size analysis builds**. |
| 15 | +- Automatically **signs builds** when keystore secrets are provided. |
| 16 | +- Uploads build artifacts (APK, AAB, symbols). |
| 17 | +- Can **comment artifact links on pull requests** (via artifact2pr). |
| 18 | +- Supports **on-demand builds via PR label** (`⚗️ Request Build`). |
| 19 | +- Creates **draft GitHub releases** with attached artifacts. |
| 20 | + |
| 21 | +## Inputs |
| 22 | + |
| 23 | +| Name | Description | Required | Default | |
| 24 | +| ------------------- | -------------------------------------------------------------- | -------- | ------- | |
| 25 | +| `release-version` | Version to release (e.g., `1.2.3`, `v` is added automatically) | No | — | |
| 26 | +| `app-name` | Name of the app (used for artifact naming) | No | — | |
| 27 | +| `build-type` | Type of build (`test`, `build`, `size-analysis`, `release`) | No | `test` | |
| 28 | +| `java-version` | Java version used for Android build | No | `21` | |
| 29 | +| `working-directory` | Directory of the Flutter project | No | `.` | |
| 30 | +| `bot-app-id` | GitHub App ID used for release creation | No | — | |
| 31 | + |
| 32 | +## Secrets |
| 33 | + |
| 34 | +| Name | Description | Required | |
| 35 | +| --------------------- | ----------------------- | -------- | |
| 36 | +| `KEY_PASSWORD` | Keystore key password | No | |
| 37 | +| `KEYSTORE_PASSWORD` | Keystore password | No | |
| 38 | +| `KEY_ALIAS` | Keystore alias | No | |
| 39 | +| `KEYSTORE_BASE64` | Base64 encoded keystore | No | |
| 40 | +| `BOT_APP_PRIVATE_KEY` | GitHub App private key | No | |
| 41 | + |
| 42 | +## Usage |
| 43 | + |
| 44 | +Call this workflow from another repository: |
| 45 | + |
| 46 | +```yaml |
| 47 | +name: Use Flutter Workflow |
| 48 | + |
| 49 | +on: |
| 50 | + pull_request: |
| 51 | + push: |
| 52 | + tags: |
| 53 | + - "*" |
| 54 | + |
| 55 | +jobs: |
| 56 | + flutter: |
| 57 | + uses: RubberDuckCrew/flutter-workflow/.github/workflows/workflow-build.yml@v1 |
| 58 | + with: |
| 59 | + app-name: my-app |
| 60 | + build-type: build |
| 61 | +``` |
| 62 | +
|
| 63 | +### Release Example |
| 64 | +
|
| 65 | +```yaml |
| 66 | +jobs: |
| 67 | + release: |
| 68 | + uses: RubberDuckCrew/flutter-workflow/.github/workflows/workflow-build.yml@v1 |
| 69 | + with: |
| 70 | + app-name: my-app |
| 71 | + build-type: release |
| 72 | + release-version: 1.2.3 |
| 73 | + secrets: |
| 74 | + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} |
| 75 | + KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} |
| 76 | + KEY_ALIAS: ${{ secrets.KEY_ALIAS }} |
| 77 | + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} |
| 78 | + BOT_APP_PRIVATE_KEY: ${{ secrets.BOT_APP_PRIVATE_KEY }} |
| 79 | +``` |
| 80 | +
|
| 81 | +## Build Triggers |
| 82 | +
|
| 83 | +The build job runs when: |
| 84 | +
|
| 85 | +- A **tag is pushed** |
| 86 | +- The PR has the label **`⚗️ Request Build`** |
| 87 | +- `build-type` is set to `build`, `size-analysis`, or `release` |
| 88 | + |
| 89 | +## Artifacts |
| 90 | + |
| 91 | +The workflow uploads: |
| 92 | + |
| 93 | +- 📦 APK file |
| 94 | +- 📦 App Bundle (AAB) |
| 95 | +- 🧩 Debug symbols |
| 96 | +- 📊 Size analysis report (optional) |
| 97 | + |
| 98 | +## Pull Request Integration |
| 99 | + |
| 100 | +When using the label: |
| 101 | + |
| 102 | +``` |
| 103 | +⚗️ Request Build |
| 104 | +``` |
| 105 | + |
| 106 | +- A build is triggered |
| 107 | +- The label is automatically removed |
| 108 | +- A comment with artifact links is posted (via artifact2pr) |
| 109 | + |
| 110 | +## Release Flow |
| 111 | + |
| 112 | +When `build-type: release` and `release-version` is set: |
| 113 | + |
| 114 | +- Updates `pubspec.yaml` version |
| 115 | +- Builds signed artifacts (if secrets available) |
| 116 | +- Commits updated version |
| 117 | +- Creates a **draft GitHub release** |
| 118 | +- Uploads: |
| 119 | + - APK |
| 120 | + - AAB |
| 121 | + - Zipped symbols |
| 122 | + |
| 123 | +## Notes |
| 124 | + |
| 125 | +- Signing is skipped automatically if no keystore is provided. |
| 126 | +- Forked PRs do not have access to secrets → no signing. |
| 127 | +- Artifacts are retained according to GitHub’s default retention policy. |
| 128 | +- The workflow uses concurrency control to cancel outdated runs. |
| 129 | + |
| 130 | +## License |
| 131 | + |
| 132 | +[MIT](LICENSE) |
0 commit comments