Skip to content

Commit 732650d

Browse files
authored
Merge pull request #139 from ryanaidilp/refactor/example-app
refactor(example): complete SDK showcase implementation
2 parents 0c959a8 + a36398b commit 732650d

File tree

319 files changed

+45139
-9417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+45139
-9417
lines changed

.github/workflows/create-release-with-apk.yml

Lines changed: 125 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,156 @@ jobs:
3434
with:
3535
distribution: 'zulu'
3636
java-version: '17'
37+
cache: 'gradle'
3738

3839
- name: Setup Flutter
3940
uses: subosito/flutter-action@v2
4041
with:
4142
channel: 'stable'
43+
cache: true
44+
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
45+
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
46+
47+
- name: Cache Flutter dependencies
48+
uses: actions/cache@v4
49+
id: flutter-pub-cache
50+
with:
51+
path: |
52+
~/.pub-cache
53+
app/example/.dart_tool
54+
app/example/.flutter-plugins
55+
app/example/.flutter-plugins-dependencies
56+
app/example/.packages
57+
packages/stadata_flutter_sdk/.dart_tool
58+
packages/stadata_flutter_sdk/.packages
59+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}-${{ hashFiles('**/pubspec.lock') }}
60+
restore-keys: |
61+
${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}-
62+
${{ runner.os }}-pub-
63+
64+
- name: Cache build_runner outputs
65+
uses: actions/cache@v4
66+
id: build-runner-cache
67+
with:
68+
path: |
69+
app/example/lib/**/*.g.dart
70+
app/example/lib/**/*.gr.dart
71+
app/example/lib/**/*.config.dart
72+
app/example/.dart_tool/build
73+
key: ${{ runner.os }}-build-runner-${{ hashFiles('app/example/pubspec.yaml') }}-${{ hashFiles('app/example/lib/**/*.dart', '!app/example/lib/**/*.g.dart', '!app/example/lib/**/*.gr.dart', '!app/example/lib/**/*.config.dart') }}-${{ hashFiles('app/example/build.yaml') }}
74+
restore-keys: |
75+
${{ runner.os }}-build-runner-${{ hashFiles('app/example/pubspec.yaml') }}-
76+
${{ runner.os }}-build-runner-
77+
78+
- name: Cache Gradle dependencies
79+
uses: actions/cache@v4
80+
with:
81+
path: |
82+
~/.gradle/caches
83+
~/.gradle/wrapper
84+
app/example/android/.gradle
85+
key: ${{ runner.os }}-gradle-${{ hashFiles('app/example/android/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('app/example/android/**/*.gradle*') }}
86+
restore-keys: |
87+
${{ runner.os }}-gradle-${{ hashFiles('app/example/android/gradle/wrapper/gradle-wrapper.properties') }}-
88+
${{ runner.os }}-gradle-
89+
90+
- name: Log cache status
91+
run: |
92+
echo "### Cache Status" >> $GITHUB_STEP_SUMMARY
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "- Flutter Pub Cache: ${{ steps.flutter-pub-cache.outputs.cache-hit == 'true' && '✅ Hit' || '⚠️ Miss' }}" >> $GITHUB_STEP_SUMMARY
95+
echo "- Build Runner Cache: ${{ steps.build-runner-cache.outputs.cache-hit == 'true' && '✅ Hit' || '⚠️ Miss' }}" >> $GITHUB_STEP_SUMMARY
96+
echo "" >> $GITHUB_STEP_SUMMARY
4297
4398
- name: Get Flutter dependencies
4499
working-directory: app/example
45-
run: flutter pub get
100+
run: |
101+
if [ "${{ steps.flutter-pub-cache.outputs.cache-hit }}" == "true" ]; then
102+
echo "📦 Pub cache restored, verifying dependencies..."
103+
else
104+
echo "📦 Downloading Flutter dependencies..."
105+
fi
106+
flutter pub get
107+
echo "✅ Flutter dependencies ready"
46108
47-
- name: Build APK
109+
- name: Setup .env file
48110
working-directory: app/example
111+
env:
112+
ENV_BASE64: ${{ secrets.ENV_BASE64 }}
49113
run: |
50-
echo "Building APK for version ${{ steps.get_version.outputs.version }}"
51-
flutter build apk --release
52-
114+
if [ -n "$ENV_BASE64" ]; then
115+
echo "Decoding .env file from secret..."
116+
echo "$ENV_BASE64" | base64 -d > .env
117+
echo "✅ .env file created successfully"
118+
else
119+
echo "⚠️ Warning: ENV_BASE64 secret not found, creating empty .env"
120+
touch .env
121+
fi
122+
123+
- name: Run build_runner
124+
working-directory: app/example
125+
run: |
126+
if [ "${{ steps.build-runner-cache.outputs.cache-hit }}" == "true" ]; then
127+
echo "✅ Using cached build_runner outputs"
128+
echo "Skipping code generation (cache hit)"
129+
else
130+
echo "🔨 Running build_runner to generate code..."
131+
flutter pub run build_runner build --delete-conflicting-outputs
132+
echo "✅ Code generation completed"
133+
fi
134+
135+
- name: Build APK with Size Analysis
136+
working-directory: app/example
137+
run: |
138+
echo "Building APK for version ${{ steps.get_version.outputs.version }} with size analysis..."
139+
140+
# Build APK with size analysis
141+
flutter build apk --release --analyze-size --target-platform android-arm64
142+
53143
# Rename APK with version
54144
APK_PATH="build/app/outputs/flutter-apk/app-release.apk"
55145
NEW_APK_NAME="Stadata_Example_v${{ steps.get_version.outputs.version }}.apk"
56-
146+
57147
if [ -f "$APK_PATH" ]; then
58148
mv "$APK_PATH" "build/app/outputs/flutter-apk/$NEW_APK_NAME"
59149
echo "apk_path=app/example/build/app/outputs/flutter-apk/$NEW_APK_NAME" >> $GITHUB_OUTPUT
60150
echo "apk_name=$NEW_APK_NAME" >> $GITHUB_OUTPUT
61151
echo "✅ APK built successfully: $NEW_APK_NAME"
152+
153+
# Check for size analysis JSON in multiple locations
154+
SIZE_JSON=""
155+
if [ -f "$HOME/.flutter-devtools/apk-code-size-analysis_01.json" ]; then
156+
SIZE_JSON="$HOME/.flutter-devtools/apk-code-size-analysis_01.json"
157+
elif [ -f "build/apk-arm64-release-code-size-analysis_01.json" ]; then
158+
SIZE_JSON="build/apk-arm64-release-code-size-analysis_01.json"
159+
elif [ -f ".flutter-devtools/apk-code-size-analysis_01.json" ]; then
160+
SIZE_JSON=".flutter-devtools/apk-code-size-analysis_01.json"
161+
fi
162+
163+
if [ -n "$SIZE_JSON" ]; then
164+
# Copy to a known location for artifact upload
165+
mkdir -p build/size-analysis
166+
cp "$SIZE_JSON" build/size-analysis/release-size-analysis.json
167+
echo "size_json=app/example/build/size-analysis/release-size-analysis.json" >> $GITHUB_OUTPUT
168+
echo "✅ Size analysis JSON found and copied: $SIZE_JSON"
169+
else
170+
echo "⚠️ Size analysis JSON not found in expected locations"
171+
fi
62172
else
63173
echo "❌ APK build failed - file not found"
64174
exit 1
65175
fi
66176
id: build_apk
67177

178+
- name: Generate Size Analysis Report
179+
if: steps.build_apk.outputs.size_json != ''
180+
run: |
181+
echo "Generating size analysis report..."
182+
chmod +x scripts/analyze_apk_size.sh
183+
./scripts/analyze_apk_size.sh "${{ steps.build_apk.outputs.size_json }}" "${{ steps.build_apk.outputs.apk_path }}" apk_size_analysis.md
184+
echo "✅ APK analysis complete"
185+
id: analyze_apk
186+
68187
- name: Generate changelog for release
69188
id: generate_changelog
70189
run: |

0 commit comments

Comments
 (0)