-
Notifications
You must be signed in to change notification settings - Fork 22
/
codemagic.yaml
118 lines (116 loc) · 4.24 KB
/
codemagic.yaml
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
117
118
definitions:
configure_environment: &configure_environment
# This running machine can be changed depends on the billing plan: https://docs.codemagic.io/knowledge-codemagic/machine-type/
instance_type: mac_mini_m1
max_build_duration: 30
environment:
groups:
- firebase_credentials
java: 17
cache:
cache_paths:
- $HOME/.gradle/caches
scripts:
- &detekt_on_template_compose
name: Run detekt on template-compose
working_directory: ./template-compose
script: ./gradlew detekt
- &unit_test_on_template_compose
name: Run unit tests on template-compose
working_directory: ./template-compose
script: ./gradlew koverHtmlReport
artifacts:
- &artifacts_template_compose template-compose/app/build/reports/kover/
- &artifacts_staging_apk template-compose/app/build/outputs/apk/staging/debug/app-staging-debug.apk
- &artifacts_production_apk template-compose/app/build/outputs/apk/production/debug/app-production-debug.apk
workflows:
unit-test-on-pr-for-template-compose:
name: Unit test on PR for template-compose
<<: *configure_environment
triggering:
events:
# Run when a pull request is opened or updated
- pull_request
branch_patterns:
# Review changes BEFORE they’re merged into any branches
- pattern: '*'
source: false
# Will not run on develop branch as it is already covered by build-and-deploy-template-compose-staging
- pattern: 'develop'
include: false
# Will not run on main branch as it is already covered by build-and-deploy-template-compose-production
- pattern: 'main'
include: false
cancel_previous_builds: true
scripts:
- *detekt_on_template_compose
- *unit_test_on_template_compose
artifacts:
- *artifacts_template_compose
build-and-deploy-template-compose-staging:
name: Build and deploy template-compose staging to Firebase App Distribution
<<: *configure_environment
triggering:
events:
- push
branch_patterns:
- pattern: 'develop'
scripts:
- *detekt_on_template_compose
- *unit_test_on_template_compose
- name: Build APK for staging
working_directory: ./template-compose
script: |
./gradlew assembleStagingDebug -PversionCode=$BUILD_NUMBER
- name: Generate release notes with the latest git commit
script: |
RELEASE_NOTE_CONTENT="$((git log -1 --merges | grep "\[") | grep . && echo "" || echo $(git log -1 --merges --format=%B))"
echo "$RELEASE_NOTE_CONTENT" | tee release_notes.txt
artifacts:
- *artifacts_template_compose
- *artifacts_staging_apk
publishing:
firebase:
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT_CREDENTIALS
android:
app_id: $FIREBASE_APP_ID_STAGING
groups:
- android-chapter
artifact_type: 'apk'
build-and-deploy-template-compose-production:
name: Build and deploy template-compose production to Firebase App Distribution
<<: *configure_environment
triggering:
events:
- push
branch_patterns:
- pattern: 'main'
environment:
vars:
# Increase the clone depth to 50 to cover all commits from the latest tag
CM_CLONE_DEPTH: 50
groups:
- firebase_credentials
java: 17
scripts:
- *detekt_on_template_compose
- *unit_test_on_template_compose
- name: Build APK for production
working_directory: ./template-compose
script: |
./gradlew assembleProductionDebug -PversionCode=$BUILD_NUMBER
- name: Generate release notes with git commits from the latest tag
script: |
RELEASE_NOTE_CONTENT="$(git log --merges --pretty=%B $(git describe --abbrev=0 --tags)..HEAD | grep "\[")"
echo "$RELEASE_NOTE_CONTENT" | tee release_notes.txt
artifacts:
- *artifacts_template_compose
- *artifacts_production_apk
publishing:
firebase:
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT_CREDENTIALS
android:
app_id: $FIREBASE_APP_ID_PRODUCTION
groups:
- android-chapter
artifact_type: 'apk'