File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Android CI-CD
2+
3+ on :
4+ push :
5+ branches :
6+ - development
7+
8+ jobs :
9+ build :
10+ name : Build Debug APK
11+ runs-on : ubuntu-latest
12+
13+ if : github.ref == 'refs/heads/development' && github.event_name == 'push'
14+
15+ steps :
16+ - name : Checkout Repository
17+ uses : actions/checkout@v4
18+
19+ - name : Set up JDK 17
20+ uses : actions/setup-java@v4
21+ with :
22+ java-version : ' 17'
23+ distribution : ' temurin'
24+ cache : gradle
25+
26+ - name : Grant Execute Permission to Gradle Wrapper
27+ run : chmod +x ./gradlew
28+
29+ - name : Build Debug APK
30+ run : ./gradlew bundleDebug
31+
32+ - name : Get Branch Type and Rename APK
33+ run : |
34+ RAW_BRANCH="${GITHUB_REF##*/}"
35+ if [[ "$RAW_BRANCH" == "main" ]]; then
36+ SHORT_NAME="main"
37+ elif [[ "$RAW_BRANCH" == "development" ]]; then
38+ SHORT_NAME="dev"
39+ else
40+ SHORT_NAME="feature"
41+ fi
42+
43+ FINAL_NAME="app_${SHORT_NAME}.apk"
44+ echo "FINAL_NAME=${FINAL_NAME}" >> $GITHUB_ENV
45+
46+ mv app/build/outputs/bundle/debug/app-debug.apk \
47+ app/build/outputs/bundle/debug/${FINAL_NAME}
48+
49+ echo "RENAMED_AAB_PATH=app/build/outputs/bundle/debug/${FINAL_NAME}" >> $GITHUB_ENV
50+
51+ - name : Upload APK
52+ uses : actions/upload-artifact@v4
53+ with :
54+ name : ${{ env.FINAL_NAME }}
55+ path : ${{ env.RENAMED_AAB_PATH }}
You can’t perform that action at this time.
0 commit comments