-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (99 loc) · 3.74 KB
/
Copy pathcd.yml
File metadata and controls
116 lines (99 loc) · 3.74 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/CD with Firebase
on:
pull_request:
types: [closed]
branches: [develop]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
setup:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/setup.yml
secrets: inherit
build:
needs: setup
runs-on: ubuntu-latest
env:
VERSION_OFFSET: 448
outputs:
pr_title: ${{ steps.set-pr-metadata.outputs.title }}
pr_number: ${{ steps.set-pr-metadata.outputs.number }}
ref_name: ${{ steps.set-pr-metadata.outputs.ref }}
sha: ${{ steps.set-pr-metadata.outputs.sha }}
version_name: ${{ steps.set-version.outputs.version_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-cache-${{ hashFiles('**/gradle-wrapper.properties', '**/*.gradle*', '**/settings.gradle*', '**/libs.versions.toml') }}
restore-keys: |
gradle-cache-${{ runner.os }}-
gradle-cache-
- name: ♻️ Restore Project Setup
uses: actions/cache@v4
with:
path: |
local.properties
app/google-services.json
app/novix-release.jks
key: project-setup-${{ github.sha }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set PR metadata as outputs
id: set-pr-metadata
run: |
echo "title=${{ github.event.pull_request.title || 'Manual Dispatch' }}" >> "$GITHUB_OUTPUT"
echo "number=${{ github.event.pull_request.number || 'manual' }}" >> "$GITHUB_OUTPUT"
echo "ref=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
- name: Calculate versionName
id: set-version
run: |
VERSION_NAME="1.2.$(( ${{ github.run_number }} - ${{ env.VERSION_OFFSET }} ))"
echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
- name: Build ABI-split Release APKs
run: ./gradlew -PversionCode=${{ github.run_number }} -PversionName="${{ steps.set-version.outputs.version_name }}" assembleRelease
- name: Upload APKs as artifact
uses: actions/upload-artifact@v4
with:
name: apk-artifacts
path: app/build/outputs/apk/release/*-release.apk
upload-to-firebase:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
abi: [x86_64, x86, arm64-v8a, armeabi-v7a]
steps:
- name: Download built APKs
uses: actions/download-artifact@v4
with:
name: apk-artifacts
path: apks
- name: Upload ${{ matrix.abi }} APK to Firebase
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.ACCOUNT_SERVICE_JSON }}
groups: testers
file: apks/Novix-${{ needs.build.outputs.version_name }}-${{ matrix.abi }}-release.apk
releaseNotes: |
📦 Split APK Build
🔧 ABI: ${{ matrix.abi }}
🆕 PR #${{ needs.build.outputs.pr_number }}: ${{ needs.build.outputs.pr_title }}
🔀 Branch: ${{ needs.build.outputs.ref_name }}
🔖 Commit: ${{ needs.build.outputs.sha }}