Skip to content

Commit 7e18f15

Browse files
author
gopi2401
committed
fix: streamline Android build workflow by refining setup steps and improving caching
1 parent cc14461 commit 7e18f15

File tree

1 file changed

+24
-36
lines changed

1 file changed

+24
-36
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,67 +29,55 @@ jobs:
2929
- name: Checkout repository
3030
uses: actions/checkout@v3
3131

32-
# Setup Java environment for Android build
3332
- name: Set up JDK 17
3433
uses: actions/setup-java@v4
3534
with:
3635
distribution: "temurin"
3736
java-version: "17"
3837
cache: "gradle"
3938

40-
# Gradle cache for faster builds
41-
# - uses: actions/cache@v4
42-
# with:
43-
# path: |
44-
# ~/.gradle/caches
45-
# ~/.gradle/wrapper
46-
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
47-
# restore-keys: |
48-
# ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
49-
# ${{ runner.os }}-gradle-
50-
# ${{ runner.os }}-
51-
52-
- uses: subosito/flutter-action@v2
39+
- name: Setup Flutter
40+
uses: subosito/flutter-action@v2
5341
with:
5442
channel: "stable"
5543
cache: true
5644

57-
- name: Setup Android SDK
58-
uses: android-actions/setup-android@v3
45+
- name: Cache Android SDK components
46+
uses: actions/cache@v4
47+
with:
48+
path: |
49+
$ANDROID_HOME/platforms
50+
$ANDROID_HOME/build-tools
51+
$ANDROID_HOME/ndk
52+
$ANDROID_HOME/cmake
53+
key: ${{ runner.os }}-android-sdk-${{ hashFiles('**/build.gradle') }}
54+
restore-keys: |
55+
${{ runner.os }}-android-sdk-
5956
60-
- name: Install SDK 33, NDK, and CMake
61-
shell: bash
57+
- name: Install Android SDK, NDK, and CMake
6258
run: |
63-
export ANDROID_SDK_ROOT=$ANDROID_HOME
64-
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator
65-
yes | sdkmanager "platforms;android-33" \
66-
"build-tools;33.0.2" \
67-
"ndk;26.1.10909125" \
68-
"cmake;3.22.1"
69-
cache: true
70-
71-
# - name: Accept Android Licenses
72-
# run: yes | flutter doctor --android-licenses
59+
yes | sdkmanager --licenses
60+
sdkmanager --install \
61+
"platforms;android-33" \
62+
"build-tools;33.0.2" \
63+
"ndk;27.0.12077973" \
64+
"cmake;3.22.1"
7365
74-
- name: Install dependencies
66+
- name: Install Flutter dependencies
7567
run: flutter pub get
7668

77-
# - run: flutter doctor -v
78-
# - run: flutter analyze --suggestions
79-
# Create .env file for environment variables
8069
- name: Create .env file
8170
run: |
8271
cat <<EOF > .env
8372
GITHUBTOKEN=${{ secrets.GITHUBTOKEN }}
8473
EOF
8574
86-
# # Build APK with additional flags for optimization
87-
- run: flutter build apk --release
75+
- name: Build APK (Release)
76+
run: flutter build apk --release
8877

89-
# Upload to Telegram
9078
- name: Upload to Telegram
9179
run: |
9280
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
9381
-F chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
9482
-F document=@build/app/outputs/flutter-apk/app-release.apk \
95-
-F caption=app
83+
-F caption="New release from GitHub Actions"

0 commit comments

Comments
 (0)