-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (100 loc) · 4.46 KB
/
Copy pathandroid-build.yml
File metadata and controls
116 lines (100 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Android CI Build
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Decode Keystore
run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 -d > app/keystore.jks
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Debug APK
run: ./gradlew assembleDebug
- name: Build Release APK
run: ./gradlew assembleRelease
env:
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Verify APK exists
run: |
if [ -f app/build/outputs/apk/release/app-release.apk ]; then
echo "✅ Release APK built successfully"
ls -lh app/build/outputs/apk/release/app-release.apk
else
echo "❌ Release APK not found"
exit 1
fi
- name: Get commit info
id: commit_info
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "commit_msg=$(git log -1 --pretty=%B | head -n 1)" >> $GITHUB_OUTPUT
echo "build_date=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
- name: Rename APK files
run: |
mkdir -p output
cp app/build/outputs/apk/debug/app-debug.apk output/floating-clock-timing-debug-${{ steps.commit_info.outputs.sha_short }}.apk
cp app/build/outputs/apk/release/app-release.apk output/floating-clock-timing-release-${{ steps.commit_info.outputs.sha_short }}.apk || echo "Release APK not found"
- name: Upload Debug APK
uses: actions/upload-artifact@v4
with:
name: floating-clock-timing-debug-${{ steps.commit_info.outputs.sha_short }}
path: output/floating-clock-timing-debug-${{ steps.commit_info.outputs.sha_short }}.apk
retention-days: 30
- name: Upload Release APK
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: floating-clock-timing-release-${{ steps.commit_info.outputs.sha_short }}
path: output/floating-clock-timing-release-${{ steps.commit_info.outputs.sha_short }}.apk
retention-days: 30
- name: Create Build Info
run: |
cat > output/build-info.txt << EOF
Floating Clock Timing - Build Information
=========================================
Commit: ${{ github.sha }}
Short SHA: ${{ steps.commit_info.outputs.sha_short }}
Branch: ${{ github.ref_name }}
Commit Message: ${{ steps.commit_info.outputs.commit_msg }}
Build Date: ${{ steps.commit_info.outputs.build_date }}
Workflow: ${{ github.workflow }}
Run Number: ${{ github.run_number }}
Actor: ${{ github.actor }}
EOF
- name: Upload Build Info
uses: actions/upload-artifact@v4
with:
name: build-info-${{ steps.commit_info.outputs.sha_short }}
path: output/build-info.txt
retention-days: 30
- name: Generate build summary
run: |
echo "## 🎉 Build Successful!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📱 APK Files Built" >> $GITHUB_STEP_SUMMARY
echo "- **Debug APK**: floating-clock-timing-debug-${{ steps.commit_info.outputs.sha_short }}.apk" >> $GITHUB_STEP_SUMMARY
echo "- **Release APK**: floating-clock-timing-release-${{ steps.commit_info.outputs.sha_short }}.apk" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ℹ️ Build Details" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: \`${{ steps.commit_info.outputs.sha_short }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Message**: ${{ steps.commit_info.outputs.commit_msg }}" >> $GITHUB_STEP_SUMMARY
echo "- **Date**: ${{ steps.commit_info.outputs.build_date }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📥 Download" >> $GITHUB_STEP_SUMMARY
echo "Download the artifacts from the **Artifacts** section below." >> $GITHUB_STEP_SUMMARY