-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (140 loc) · 5.64 KB
/
Copy pathandroid-play-closed.yml
File metadata and controls
165 lines (140 loc) · 5.64 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
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
name: Android Play Closed Testing Deploy
on:
workflow_dispatch:
inputs:
android_version_code:
description: Must be greater than every Android version code already uploaded to Google Play.
required: true
type: number
release_notes:
description: Optional Google Play release notes for en-US.
required: false
type: string
permissions:
contents: read
jobs:
deploy_closed_testing:
name: Build and upload closed testing release
runs-on: ubuntu-latest
environment: staging
env:
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
REST_API_URL: ${{ vars.REST_API_URL }}
steps:
- name: Validate workflow inputs
env:
ANDROID_VERSION_CODE: ${{ inputs.android_version_code }}
ANDROID_GOOGLE_SERVICES_JSON_B64: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_B64 }}
ANDROID_UPLOAD_KEYSTORE_B64: ${{ secrets.ANDROID_UPLOAD_KEYSTORE_B64 }}
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
run: |
case "$GITHUB_REF" in
refs/heads/release/*|refs/heads/hotfix/*)
;;
*)
echo "Android Play Closed Testing Deploy must be run from a release/** or hotfix/** branch." >&2
exit 1
;;
esac
if ! [[ "$ANDROID_VERSION_CODE" =~ ^[1-9][0-9]*$ ]]; then
echo "android_version_code must be a positive integer." >&2
exit 1
fi
missing=0
for name in \
ANDROID_GOOGLE_SERVICES_JSON_B64 \
ANDROID_UPLOAD_KEYSTORE_B64 \
ANDROID_KEYSTORE_PASSWORD \
ANDROID_KEY_ALIAS \
ANDROID_KEY_PASSWORD \
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON \
REST_API_URL
do
if [ -z "${!name}" ]; then
echo "$name is required for Android Play closed testing deploy." >&2
missing=1
fi
done
exit "$missing"
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.44.4"
channel: stable
cache: true
- name: Set Android keystore path
run: echo "ANDROID_KEYSTORE_PATH=$RUNNER_TEMP/ontime-upload.jks" >> "$GITHUB_ENV"
- name: Install native test dependencies
run: sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
- name: Decode Android Firebase config
env:
ANDROID_GOOGLE_SERVICES_JSON_B64: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_B64 }}
run: |
mkdir -p android/app/src/release
printf '%s' "$ANDROID_GOOGLE_SERVICES_JSON_B64" | base64 --decode > android/app/src/release/google-services.json
test -s android/app/src/release/google-services.json
- name: Decode Android upload keystore
env:
ANDROID_UPLOAD_KEYSTORE_B64: ${{ secrets.ANDROID_UPLOAD_KEYSTORE_B64 }}
run: |
printf '%s' "$ANDROID_UPLOAD_KEYSTORE_B64" | base64 --decode > "$ANDROID_KEYSTORE_PATH"
chmod 600 "$ANDROID_KEYSTORE_PATH"
test -s "$ANDROID_KEYSTORE_PATH"
- name: Install Flutter packages
run: flutter pub get
- name: Run code generation
run: dart run build_runner build --delete-conflicting-outputs
- name: Check generated Dart policy
run: dart run tool/check_generated_dart_policy.dart
- name: Verify generation left tracked files unchanged
run: git diff --exit-code
- name: Analyze
run: flutter analyze
- name: Test
run: flutter test
- name: Derive Android build name
run: |
app_version="$(sed -n 's/^version: *//p' pubspec.yaml | head -n 1)"
build_name="${app_version%%+*}"
if [ -z "$build_name" ]; then
echo "Unable to derive Android build name from pubspec.yaml version." >&2
exit 1
fi
echo "ANDROID_BUILD_NAME=$build_name" >> "$GITHUB_ENV"
- name: Build Android app bundle
run: |
flutter build appbundle --release \
--build-name="$ANDROID_BUILD_NAME" \
--build-number="${{ inputs.android_version_code }}" \
--dart-define=ENV=staging \
--dart-define=REST_API_URL="$REST_API_URL"
- name: Prepare Play release notes
if: ${{ inputs.release_notes != '' }}
env:
RELEASE_NOTES: ${{ inputs.release_notes }}
run: |
mkdir -p distribution/whatsnew
printf '%s\n' "$RELEASE_NOTES" > distribution/whatsnew/whatsnew-en-US
- name: Upload signed app bundle artifact
uses: actions/upload-artifact@v4
with:
name: ontime-android-closed-testing-aab
path: build/app/outputs/bundle/release/app-release.aab
if-no-files-found: error
retention-days: 14
- name: Install Google Play upload dependencies
run: npm install --no-save --no-package-lock googleapis
- name: Upload closed testing draft
env:
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
PACKAGE_NAME: club.devkor.ontime
PLAY_TRACK: alpha
RELEASE_FILE: build/app/outputs/bundle/release/app-release.aab
RELEASE_NOTES_FILE: distribution/whatsnew/whatsnew-en-US
run: node .github/scripts/upload_google_play_draft.js