forked from flutter/news_toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codemagic.yaml
189 lines (189 loc) · 7.3 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Codemagic Remarks:
# - As the encrypt button is no longer available in Codemagic web ui
# to encrypt the variable see this curl request https://docs.codemagic.io/rest-api/applications/#curl-example
definitions:
environment:
prod_emails: &prod_emails
tst_emails: &tst_emails
# common_environment: &common_environment
# FLUTTER_PROJECT_DIRECTORY: flutter_news_example
automatic_ios_signing: &automatic_ios_signing
# Encrypt the **content** of the API key for AppStore Connect
# - Log in to App Store Connect and navigate to Users and Access > Keys.
# - Click on the + sign to generate a new API key.
# - Enter the name for the key and select an access level: either Developer or App Manager.
# - Click Generate.
# - As soon as the key is generated, you can see it added in the list of active keys.
# Click Download API Key to save the private key for later. Note that the key can only be downloaded once.
# Save the key in the project 1Password or Lastpass.
# Encrypt the CONTENT of the p8 file and provide below in APP_STORE_CONNECT_PRIVATE_KEY.
APP_STORE_CONNECT_ISSUER_ID: TODO
APP_STORE_CONNECT_KEY_IDENTIFIER: TODO
APP_STORE_CONNECT_PRIVATE_KEY: TODO
# Generate the ssh key:
# ssh-keygen -t rsa -b 2048 -m PEM -f ./codemagic_private_key -q -N ""
# This will be used by app-store-connect to generate the signing certificates.
# Save the key in the project 1Password or Lastpass.
# Encrypt the CONTENT of the file and provide below in CERTIFICATE_PRIVATE_KEY.
CERTIFICATE_PRIVATE_KEY: TODO
android_signing: &android_signing
# Generate the project Android keystore either via Android Studio or command:
# keytool -genkey -v -keystore ./[project_name]-prod.keystore -alias [project_name] -keyalg RSA -keysize 2048 -validity 10000
# Save the key and password in the project 1Password or Lastpass
# See instruction: https://docs.codemagic.io/code-signing-yaml/signing-android/#set-up-code-signing-with-user-specified-keys
FCI_KEYSTORE_PATH: /tmp/keystore.keystore
FCI_KEYSTORE: TODO
FCI_KEYSTORE_PASSWORD: TODO
FCI_KEY_PASSWORD: TODO
FCI_KEY_ALIAS: flutter-news-example
# The Google Play service account key should be generated by the owner of Google Play account
# See instruction https://docs.codemagic.io/knowledge-base/google-play-api/
# Encrypt the **content** of the Service Account Key
GPLAY_KEY: TODO
workflows:
development:
name: development
working_directory: flutter_news_example
max_build_duration: 60
environment:
flutter: 3.3.10
xcode: latest
cocoapods: default
vars:
<<: *automatic_ios_signing
<<: *android_signing
FLAVOR: development
BUNDLE_ID: com.flutter.news.example.dev
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
- $HOME/.gradle/caches
triggering:
events:
- tag
# Include or exclude watched branches.
branch_patterns:
- pattern: "main"
include: true
source: true
# Include or exclude watched tag labels.
tag_patterns:
- pattern: "*"
include: true
# Set to `true` to automatically cancel outdated webhook builds.
cancel_previous_builds: true
scripts:
- &get_latest_tag
name: Get latest tag
script: set TAG=$(git describe --tags)
- &set_up_key_properties
name: Set up Android key.properties
script: |
echo $FCI_KEYSTORE | base64 --decode > $FCI_KEYSTORE_PATH
cat >> "$FCI_BUILD_DIR/flutter_news_example/android/key.properties" <<EOF
storePassword=$FCI_KEYSTORE_PASSWORD
keyPassword=$FCI_KEY_PASSWORD
keyAlias=$FCI_KEY_ALIAS
storeFile=$FCI_KEYSTORE_PATH
EOF
- &set_up_local_properties
name: Set up Android local properties
script: echo "flutter.sdk=$HOME/programs/flutter" > "$FCI_BUILD_DIR/flutter_news_example/android/local.properties"
- &setup_keychain
name: Setup keychain
script: keychain initialize
- &fetch_signing_files
name: Fetch signing files
script: |
app-store-connect fetch-signing-files "${BUNDLE_ID}" \
--type IOS_APP_STORE \
--create
- &get_packages
name: Get packages
script: flutter packages pub get
- &build_apk
name: Build Android APK
script: flutter build apk --release --flavor ${FLAVOR} -t lib/main/main_${FLAVOR}.dart --build-number=$PROJECT_BUILD_NUMBER
- &build_aab
name: Build Android AAB
script: flutter build appbundle --release --flavor ${FLAVOR} -t lib/main/main_${FLAVOR}.dart --build-number=$PROJECT_BUILD_NUMBER
- &setup_signing_certificates
name: Set up signing certificate
script: keychain add-certificates
- &use_profiles
name: Use Xcode profiles
script: xcode-project use-profiles
- &pod_install
name: Run pod install
script: find . -name "Podfile" -execdir pod install \;
- &build_ios
name: Build and sign iOS
script: flutter build ipa --release --flavor ${FLAVOR} -t lib/main/main_${FLAVOR}.dart --build-number=$PROJECT_BUILD_NUMBER --export-options-plist=/Users/builder/export_options.plist
artifacts:
- build/app/outputs/apk/${FLAVOR}/release/*.apk
- build/app/outputs/bundle/${FLAVOR}Release/*.aab
- build/app/outputs/mapping/**/mapping.txt
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log
publishing:
app_store_connect:
api_key: $APP_STORE_CONNECT_PRIVATE_KEY
key_id: $APP_STORE_CONNECT_KEY_IDENTIFIER
issuer_id: $APP_STORE_CONNECT_ISSUER_ID
email:
recipients: *tst_emails
google_play:
credentials: $GPLAY_KEY
track: internal
production:
name: production
working_directory: flutter_news_example
max_build_duration: 60
environment:
flutter: 3.3.10
xcode: latest
cocoapods: default
vars:
<<: *automatic_ios_signing
<<: *android_signing
FLAVOR: production
BUNDLE_ID: com.flutter.news.example
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
- $HOME/.gradle/caches
scripts:
- *get_latest_tag
- *set_up_key_properties
- *set_up_local_properties
- *setup_keychain
- *fetch_signing_files
- *get_packages
- *build_apk
- *build_aab
- *setup_signing_certificates
- *use_profiles
- *pod_install
- *build_ios
artifacts:
- build/app/outputs/apk/${FLAVOR}/release/*.apk
- build/app/outputs/bundle/${FLAVOR}Release/*.aab
- build/app/outputs/mapping/**/mapping.txt
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log
publishing:
app_store_connect:
api_key: $APP_STORE_CONNECT_PRIVATE_KEY
key_id: $APP_STORE_CONNECT_KEY_IDENTIFIER
issuer_id: $APP_STORE_CONNECT_ISSUER_ID
email:
recipients: *prod_emails
google_play:
credentials: $GPLAY_KEY
track: internal