ci(fastlane): update artifact path resolution to ensure correct direc… #36
This file contains hidden or 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
| # This action will be run on every push to main and can also be triggered manually | |
| # 1. Derives version and build number from pubspec.yaml | |
| # 2. Sets up Flutter environment | |
| # 3. Builds unsigned Android APK (.apk) | |
| # 4. Uploads unsigned APK as workflow artifact | |
| name: Android unsigned test build (.apk) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: ["main"] | |
| paths-ignore: | |
| - 'README.md' | |
| - '**/README.md' | |
| - '**/README.*' | |
| jobs: | |
| build-android-unsigned: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: example_app/fluttida | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate required secrets | |
| run: | | |
| if [ -z "${{ secrets.ADMOB_APP_ID_ANDROID }}" ]; then | |
| echo "Missing secret: ADMOB_APP_ID_ANDROID" >&2 | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.ADMOB_BANNER_UNIT_ANDROID }}" ]; then | |
| echo "Missing secret: ADMOB_BANNER_UNIT_ANDROID" >&2 | |
| exit 1 | |
| fi | |
| - name: Derive version (main branch) | |
| id: version | |
| run: | | |
| set -euo pipefail | |
| # Read version from pubspec (e.g., 1.2.3 or 1.2.3+45) | |
| VERSION_LINE=$(grep '^version:' pubspec.yaml | head -n 1 | awk '{print $2}') | |
| VERSION_NAME="${VERSION_LINE%%+*}" | |
| BUILD_NUMBER_PART="${VERSION_LINE#*+}" | |
| if [ "$BUILD_NUMBER_PART" = "$VERSION_LINE" ]; then | |
| # No +buildNumber in pubspec; fall back to commit count | |
| BUILD_NUMBER=$(git rev-list --count HEAD) | |
| else | |
| BUILD_NUMBER="$BUILD_NUMBER_PART" | |
| fi | |
| echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT" | |
| echo "build_number=$BUILD_NUMBER" >> "$GITHUB_OUTPUT" | |
| echo "Resolved version_name=$VERSION_NAME build_number=$BUILD_NUMBER" | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: "stable" | |
| flutter-version: '3.38.5' | |
| cache: true | |
| - name: Flutter doctor | |
| run: flutter doctor -v | |
| - name: Pub get | |
| run: flutter pub get | |
| - name: Build Android APK (release, unsigned) | |
| env: | |
| ORG_GRADLE_PROJECT_ADMOB_APP_ID_ANDROID: ${{ secrets.ADMOB_APP_ID_ANDROID }} | |
| ORG_GRADLE_PROJECT_ADMOB_BANNER_UNIT_ANDROID: ${{ secrets.ADMOB_BANNER_UNIT_ANDROID }} | |
| ORG_GRADLE_PROJECT_ADS_ENABLED: 'true' | |
| run: | | |
| flutter build apk --release \ | |
| --build-name="${{ steps.version.outputs.version_name }}" \ | |
| --build-number="${{ steps.version.outputs.build_number }}" | |
| - name: Gather APK artifacts | |
| run: | | |
| mkdir -p build/artifacts/android | |
| cp build/app/outputs/flutter-apk/*.apk build/artifacts/android/ || true | |
| ls -la build/artifacts/android || true | |
| - name: Upload unsigned APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Fluttida-unsigned-apk-${{ steps.version.outputs.version_name }}+${{ steps.version.outputs.build_number }} | |
| path: example_app/fluttida/build/artifacts/android/*.apk |