-
Notifications
You must be signed in to change notification settings - Fork 3
111 lines (93 loc) · 2.7 KB
/
android-ci.yml
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
name: Android CI
on:
push:
branches:
- "main"
paths-ignore:
- '**/*.md'
pull_request:
branches:
- "main"
release:
types:
- created
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- uses: actions/checkout@v3
# Step 2: Set up JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
# Step 3: Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Step 4: Clean the project
- name: Clean project
run: ./gradlew clean
# Step 5: Build Debug APK
- name: Build Debug APK
run: ./gradlew assembleDebug
# Step 6: Check if Debug APK exists
- name: Check Debug APK
run: ls -la app/build/outputs/apk/debug/
# Step 7: Archive the Debug APK
- name: Archive Debug APK
uses: actions/upload-artifact@v2
with:
name: app-debug
path: app/build/outputs/apk/debug/app-debug.apk
# Step 8: Build Release APK
- name: Build Release APK
run: ./gradlew assembleRelease
# Step 9: Check if Release APK exists
- name: Check Release APK
run: ls -la app/build/outputs/apk/release/
# Step 10: Archive the Release APK
- name: Archive Release APK
uses: actions/upload-artifact@v2
with:
name: app-release
path: app/build/outputs/apk/release/app-release.apk
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
steps:
# Step 1: Check out the repository
- uses: actions/checkout@v3
# Step 2: Download the Release APK
- name: Download Release APK
uses: actions/download-artifact@v2
with:
name: app-release
path: .
# Step 3: Verify APK File
- name: Verify APK File
run: ls -la app-release.apk
# Step 4: Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
# Step 5: Upload APK to Release
- name: Upload APK to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./app-release.apk
asset_name: app-release.apk
asset_content_type: application/vnd.android.package-archive