|
7 | 7 | branches: [ main, master ] |
8 | 8 | workflow_dispatch: |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
10 | 13 | jobs: |
11 | 14 | build-android: |
12 | 15 | name: Build Android APK and AAB |
13 | 16 | runs-on: ubuntu-latest |
14 | 17 | steps: |
15 | 18 | - name: Checkout code |
16 | 19 | uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
17 | 22 |
|
18 | 23 | - name: Setup Flutter SDK |
19 | 24 | uses: subosito/flutter-action@v2 |
|
46 | 51 | name: android-aab |
47 | 52 | path: platform/build/app/outputs/bundle/release/app-release.aab |
48 | 53 | retention-days: 7 |
| 54 | + |
| 55 | + - name: Extract version from pubspec.yaml |
| 56 | + id: get_version |
| 57 | + if: github.event_name == 'push' |
| 58 | + run: | |
| 59 | + VERSION=$(grep '^version:' platform/pubspec.yaml | sed 's/version: //' | sed 's/+.*//') |
| 60 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 61 | + TAG_NAME="v${VERSION}-${SHORT_SHA}" |
| 62 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 63 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 64 | + echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT |
| 65 | + echo "Version: $VERSION" |
| 66 | + echo "Tag: $TAG_NAME" |
| 67 | + |
| 68 | + - name: Create tag |
| 69 | + if: github.event_name == 'push' |
| 70 | + run: | |
| 71 | + git config user.name "github-actions[bot]" |
| 72 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 73 | + git tag -a "${{ steps.get_version.outputs.tag_name }}" -m "Release Flutter Android ${{ steps.get_version.outputs.version }} (commit ${{ steps.get_version.outputs.short_sha }})" || true |
| 74 | + git push origin "${{ steps.get_version.outputs.tag_name }}" || true |
| 75 | + |
| 76 | + - name: Create GitHub Release |
| 77 | + if: github.event_name == 'push' |
| 78 | + uses: softprops/action-gh-release@v1 |
| 79 | + with: |
| 80 | + tag_name: ${{ steps.get_version.outputs.tag_name }} |
| 81 | + name: ESP32 Camera Manager Android ${{ steps.get_version.outputs.version }} |
| 82 | + body: | |
| 83 | + ## ESP32 Camera Manager Android ${{ steps.get_version.outputs.version }} |
| 84 | + |
| 85 | + **Commit:** ${{ steps.get_version.outputs.short_sha }} |
| 86 | + **Branch:** ${{ github.ref_name }} |
| 87 | + |
| 88 | + ### Installation |
| 89 | + |
| 90 | + **APK (Android Package):** |
| 91 | + - Download the `app-release.apk` file |
| 92 | + - Enable "Install from unknown sources" on your Android device |
| 93 | + - Transfer the APK to your device and install it |
| 94 | + |
| 95 | + **AAB (Android App Bundle):** |
| 96 | + - Download the `app-release.aab` file |
| 97 | + - Upload to Google Play Console for distribution |
| 98 | + |
| 99 | + ### Changes |
| 100 | + |
| 101 | + See the [commit history](https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.sha }}) for details. |
| 102 | + files: | |
| 103 | + platform/build/app/outputs/flutter-apk/app-release.apk |
| 104 | + platform/build/app/outputs/bundle/release/app-release.aab |
| 105 | + draft: false |
| 106 | + prerelease: false |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments