-
Notifications
You must be signed in to change notification settings - Fork 2
306 lines (262 loc) · 11.1 KB
/
Copy pathRelease.yml
File metadata and controls
306 lines (262 loc) · 11.1 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
track:
description: 'Play Store 배포 트랙'
type: choice
options: [internal, alpha, beta, production]
default: production
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
# ──────────────────────────────────────────────
# JOB 1 : 서명된 AAB 빌드
# ──────────────────────────────────────────────
build-signed-bundle:
name: Build Signed Bundle
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Generate local.properties
run: |
write_local_property() {
local name="$1"
local value="$2"
if [ -z "$value" ]; then
echo "Missing required local.properties secret: $name"
exit 1
fi
if [[ "$value" == ${name}* ]]; then
value="${value#*=}"
value="${value# }"
fi
if [[ "$value" == \"*\" ]]; then
value="${value#\"}"
value="${value%\"}"
fi
printf '%s = "%s"\n' "$name" "$value" >> ./local.properties
}
: > ./local.properties
write_local_property "PROD_BASE_URL" "$PROD_BASE_URL"
write_local_property "DEV_BASE_URL" "$DEV_BASE_URL"
write_local_property "TERMS_URL" "$TERMS_URL"
write_local_property "REPORT_FORM_URL" "$REPORT_FORM_URL"
env:
PROD_BASE_URL: ${{ secrets.PROD_BASE_URL }}
DEV_BASE_URL: ${{ secrets.DEV_BASE_URL }}
TERMS_URL: ${{ secrets.TERMS_URL }}
REPORT_FORM_URL: ${{ secrets.REPORT_FORM_URL }}
- name: Create google-services.json
run: |
mkdir -p ${{ github.workspace }}/app
SECRET='${{ secrets.GOOGLE_SERVICES_JSON }}'
TARGET='${{ github.workspace }}/app/google-services.json'
if ! printf '%s' "$SECRET" | jq -e . > /dev/null 2>&1; then
echo "Invalid GOOGLE_SERVICES_JSON secret: must be raw JSON content from app/google-services.json"
exit 1
fi
printf '%s' "$SECRET" > "$TARGET"
jq -e . "$TARGET" > /dev/null
- name: Validate signing secrets
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
for name in KEYSTORE_BASE64 KEYSTORE_PASSWORD KEY_ALIAS KEY_PASSWORD; do
if [ -z "${!name}" ]; then
echo "Missing required signing secret: $name"
exit 1
fi
done
- name: Decode and restore keystore
run: |
KEYSTORE_PATH="${RUNNER_TEMP}/dmsStore.jks"
echo "${{ secrets.KEYSTORE_BASE64 }}" | tr -d ' \n\r' | base64 --decode > "$KEYSTORE_PATH"
echo "KEYSTORE_PATH=$KEYSTORE_PATH" >> $GITHUB_ENV
- name: Build Release AAB
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew bundleRelease
- name: Verify signed AAB
run: |
AAB_PATH="app/build/outputs/bundle/release/app-release.aab"
if [ ! -f "$AAB_PATH" ]; then
echo "Missing AAB: $AAB_PATH"
exit 1
fi
jarsigner -verify -verbose -certs "$AAB_PATH"
- name: Upload AAB artifact
uses: actions/upload-artifact@v7
with:
name: release-aab
path: app/build/outputs/bundle/release/*.aab
retention-days: 30
# ──────────────────────────────────────────────
# JOB 2 : Play Store 업로드
# ──────────────────────────────────────────────
deploy-play-store:
name: Deploy to Play Store
runs-on: ubuntu-latest
needs: build-signed-bundle
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download AAB artifact
uses: actions/download-artifact@v4
with:
name: release-aab
path: app/build/outputs/bundle/release/
- name: Prepare versioned changelog
run: |
VERSION_CODE=$(grep -oP '(?<=VERSION_CODE = )\d+' buildSrc/src/main/kotlin/ProjectProperties.kt)
cp app/src/main/play/release-notes/ko-KR/default.txt \
app/src/main/play/release-notes/ko-KR/${VERSION_CODE}.txt
echo "Changelog ready: ${VERSION_CODE}.txt"
- name: Prepare Google Play release notes directory
run: |
VERSION_CODE=$(grep -oP '(?<=VERSION_CODE = )\d+' buildSrc/src/main/kotlin/ProjectProperties.kt)
NOTES_SRC="app/src/main/play/release-notes/ko-KR/default.txt"
VERSIONED_SRC="app/src/main/play/release-notes/ko-KR/${VERSION_CODE}.txt"
NOTES_DIR="build/play-whatsnew"
if [ -f "$VERSIONED_SRC" ]; then
NOTES_SRC="$VERSIONED_SRC"
fi
mkdir -p "$NOTES_DIR"
cp "$NOTES_SRC" "$NOTES_DIR/whatsnew-ko-KR"
ls -la "$NOTES_DIR"
- name: Validate upload inputs
run: |
shopt -s nullglob
files=(app/build/outputs/bundle/release/*.aab)
if [ ${#files[@]} -eq 0 ]; then
echo "No AAB found at app/build/outputs/bundle/release/*.aab"
exit 1
fi
if [ ! -f "build/play-whatsnew/whatsnew-ko-KR" ]; then
echo "Missing release notes file: build/play-whatsnew/whatsnew-ko-KR"
exit 1
fi
- name: Verify downloaded AAB signature
run: |
shopt -s nullglob
files=(app/build/outputs/bundle/release/*.aab)
jarsigner -verify -verbose -certs "${files[0]}"
- name: Prepare Google Play service account file
env:
GOOGLE_CLOUD_PLATFORM_SECRET: ${{ secrets.GOOGLE_CLOUD_PLATFORM }}
GOOGLE_CLOUD_PLATFORM_VAR: ${{ vars.GOOGLE_CLOUD_PLATFORM }}
run: |
SERVICE_ACCOUNT="${GOOGLE_CLOUD_PLATFORM_SECRET:-$GOOGLE_CLOUD_PLATFORM_VAR}"
TARGET='${{ runner.temp }}/google-play-service-account.json'
if [ -z "$SERVICE_ACCOUNT" ]; then
echo "Missing GOOGLE_CLOUD_PLATFORM (set it as an Actions secret or variable containing raw service-account JSON)"
exit 1
fi
if ! printf '%s' "$SERVICE_ACCOUNT" | jq -e '.client_email and .private_key' > /dev/null 2>&1; then
echo "Invalid GOOGLE_CLOUD_PLATFORM secret"
exit 1
fi
printf '%s' "$SERVICE_ACCOUNT" > "$TARGET"
chmod 600 "$TARGET"
- name: Determine deploy track
id: track
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "track=production" >> $GITHUB_OUTPUT
else
echo "track=${{ github.event.inputs.track }}" >> $GITHUB_OUTPUT
fi
- name: Upload to Google Play
uses: r0adkll/upload-google-play@v1.1.3
with:
serviceAccountJson: ${{ runner.temp }}/google-play-service-account.json
packageName: team.aliens.dms
releaseFiles: app/build/outputs/bundle/release/*.aab
track: ${{ steps.track.outputs.track }}
whatsNewDirectory: build/play-whatsnew
# ──────────────────────────────────────────────
# JOB 3 : 결과 알림
# ──────────────────────────────────────────────
notify:
name: Notify Result
runs-on: ubuntu-latest
needs: deploy-play-store
if: always()
steps:
- name: Determine result
id: result
run: |
DEPLOY="${{ needs.deploy-play-store.result }}"
if [[ "$DEPLOY" == "success" ]]; then
echo "emoji=🚀" >> $GITHUB_OUTPUT
echo "label=Play Store 배포 성공" >> $GITHUB_OUTPUT
echo "color=good" >> $GITHUB_OUTPUT
echo "color_int=3066993" >> $GITHUB_OUTPUT
else
echo "emoji=❌" >> $GITHUB_OUTPUT
echo "label=Play Store 배포 실패" >> $GITHUB_OUTPUT
echo "color=danger" >> $GITHUB_OUTPUT
echo "color_int=15158332" >> $GITHUB_OUTPUT
fi
- name: Notify Slack
continue-on-error: true
uses: slackapi/slack-github-action@v2.0.0
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "${{ steps.result.outputs.emoji }} *${{ steps.result.outputs.label }}*",
"attachments": [{
"color": "${{ steps.result.outputs.color }}",
"fields": [
{ "title": "Repository", "value": "${{ github.repository }}", "short": true },
{ "title": "Tag", "value": "${{ github.ref_name }}", "short": true },
{ "title": "Triggered by", "value": "${{ github.actor }}", "short": true },
{ "title": "Run",
"value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"short": false }
]
}]
}
- name: Notify Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
LABEL: ${{ steps.result.outputs.label }}
COLOR: ${{ steps.result.outputs.color_int }}
DEPLOY_RESULT: ${{ needs.deploy-play-store.result }}
run: |
curl -s -X POST "$DISCORD_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{
\"embeds\": [{
\"title\": \"$LABEL\",
\"color\": $COLOR,
\"fields\": [
{ \"name\": \"Repository\", \"value\": \"${{ github.repository }}\", \"inline\": true },
{ \"name\": \"Tag\", \"value\": \"${{ github.ref_name }}\", \"inline\": true },
{ \"name\": \"Run\",
\"value\": \"[View Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\" }
]
}]
}"