Repository navigation
319 lines (281 loc) · 10.5 KB
/
Copy pathandroid-release.yml
File metadata and controls
319 lines (281 loc) · 10.5 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
307
308
309
310
311
312
313
314
315
316
317
318
319
name: Build Mobile Release
on:
workflow_dispatch:
inputs:
mode:
description: Validate only, create a draft, or publish the release
required: true
type: choice
options:
- dry-run
- draft
- publish
default: dry-run
exclude_commits:
description: Optional comma-separated commit hashes to omit from the notes
required: false
type: string
permissions:
contents: read
concurrency:
group: mobile-release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
name: Prepare ${{ inputs.mode }} release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
version: ${{ steps.release.outputs.version }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_PROPERTIES_BASE64: ${{ secrets.NUVIO_LOCAL_PROPERTIES_BASE64 }}
RELEASE_KEYSTORE_BASE64: ${{ secrets.NUVIO_RELEASE_KEYSTORE_BASE64 }}
steps:
- name: Check out full history
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Read release metadata
id: release
run: ./scripts/release-metadata.sh "${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
- name: Validate release state
env:
RELEASE_TAG: ${{ steps.release.outputs.tag }}
CURRENT_BUMP: ${{ steps.release.outputs.current_bump }}
RELEASE_COMMIT: ${{ steps.release.outputs.release_commit }}
RELEASE_BRANCH: ${{ github.ref_name }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
RELEASE_REF_TYPE: ${{ github.ref_type }}
RELEASE_MODE: ${{ inputs.mode }}
run: |
if [[ "${RELEASE_REF_TYPE}" != "branch" ]]; then
echo "Releases must be dispatched from a branch, not ${RELEASE_REF_TYPE}." >&2
exit 1
fi
if [[ "${RELEASE_BRANCH}" != "${DEFAULT_BRANCH}" ]]; then
echo "Releases must be dispatched from the default branch (${DEFAULT_BRANCH})." >&2
exit 1
fi
if git rev-parse --verify --quiet "refs/tags/${RELEASE_TAG}"; then
echo "Tag ${RELEASE_TAG} already exists." >&2
exit 1
fi
if gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" >/dev/null 2>&1; then
echo "A GitHub release for ${RELEASE_TAG} already exists." >&2
exit 1
fi
unexpected_changes="$(
git diff --name-only "${CURRENT_BUMP}..${RELEASE_COMMIT}" \
| grep -Ev '^(\.github/workflows/(android-release|update-store-source)\.yml|store\.json|scripts/(build-ios-ipa|generate-release-notes|prepare-ios-dependencies|release-metadata)\.sh|scripts/update-store-source\.py)$' \
|| true
)"
if [[ -n "${unexpected_changes}" ]]; then
echo "The version bump must be the final application change before release." >&2
echo "Unexpected files changed after the bump:" >&2
echo "${unexpected_changes}" >&2
exit 1
fi
if [[ "${RELEASE_MODE}" != "dry-run" ]]; then
required_secrets=(
RELEASE_PROPERTIES_BASE64
RELEASE_KEYSTORE_BASE64
)
missing=()
for secret_name in "${required_secrets[@]}"; do
if [[ -z "${!secret_name}" ]]; then
missing+=("${secret_name}")
fi
done
if (( ${#missing[@]} > 0 )); then
printf 'Missing required release secrets: %s\n' "${missing[*]}" >&2
exit 1
fi
fi
- name: Generate release notes
env:
PREVIOUS_BUMP: ${{ steps.release.outputs.previous_bump }}
CURRENT_BUMP: ${{ steps.release.outputs.current_bump }}
EXCLUDE_COMMITS: ${{ inputs.exclude_commits }}
run: |
./scripts/generate-release-notes.sh \
--from "${PREVIOUS_BUMP}" \
--to "${CURRENT_BUMP}" \
--repository "${GITHUB_REPOSITORY}" \
--exclude "${EXCLUDE_COMMITS}" \
> release-notes.md
if [[ ! -s release-notes.md ]]; then
echo "No release-note commits were found." >&2
exit 1
fi
{
echo "## ${{ steps.release.outputs.version }} release notes"
echo
cat release-notes.md
} >> "${GITHUB_STEP_SUMMARY}"
- name: Upload release notes
if: inputs.mode != 'dry-run'
uses: actions/upload-artifact@v7
with:
name: release-notes
path: release-notes.md
if-no-files-found: error
android:
name: Build Android APKs
if: inputs.mode != 'dry-run'
needs: prepare
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ needs.prepare.outputs.tag }}
RELEASE_PROPERTIES_BASE64: ${{ secrets.NUVIO_LOCAL_PROPERTIES_BASE64 }}
RELEASE_KEYSTORE_BASE64: ${{ secrets.NUVIO_RELEASE_KEYSTORE_BASE64 }}
steps:
- name: Check out source
uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Configure release properties
run: |
keystore_path="${RUNNER_TEMP}/nuvio-release.jks"
printf '%s' "${RELEASE_KEYSTORE_BASE64}" | base64 --decode > "${keystore_path}"
printf '%s' "${RELEASE_PROPERTIES_BASE64}" | base64 --decode > local.properties
sed -i -E '/^[[:space:]]*(sdk\.dir|NUVIO_RELEASE_STORE_FILE)[[:space:]]*=/d' local.properties
printf '\nNUVIO_RELEASE_STORE_FILE=%s\n' "${keystore_path}" >> local.properties
required_properties=(
NUVIO_RELEASE_STORE_PASSWORD
NUVIO_RELEASE_KEY_ALIAS
NUVIO_RELEASE_KEY_PASSWORD
TRAKT_CLIENT_ID
TRAKT_CLIENT_SECRET
)
for property_name in "${required_properties[@]}"; do
if ! grep -Eq "^${property_name}=.+" local.properties; then
echo "Missing required property: ${property_name}" >&2
exit 1
fi
done
- name: Build full release APKs
run: ./gradlew :androidApp:assembleFullRelease -Pnuvio.app.versionName="${RELEASE_VERSION}" --stacktrace
- name: Upload Android artifacts
uses: actions/upload-artifact@v7
with:
name: nuvio-${{ needs.prepare.outputs.version }}-android-full-release
path: androidApp/build/outputs/apk/full/release/*.apk
if-no-files-found: error
ios:
name: Build iOS IPA
if: inputs.mode != 'dry-run'
needs: prepare
runs-on: xcode-27
timeout-minutes: 120
env:
DEVELOPER_DIR: /Applications/Xcode_27.1.app/Contents/Developer
GRADLE_OPTS: -Dfile.encoding=UTF-8
KOTLIN_DAEMON_JVMARGS: -Xmx2048M
NUVIO_GRADLE_JVMARGS: -Xmx4608M -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=768M
NUVIO_KOTLIN_NATIVE_JVMARGS: -Xmx4608M
RELEASE_PROPERTIES_BASE64: ${{ secrets.NUVIO_LOCAL_PROPERTIES_BASE64 }}
steps:
- name: Check out source
uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Cache Kotlin Native
uses: actions/cache@v5
with:
path: ~/.konan
key: konan-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('gradle/libs.versions.toml') }}
restore-keys: |
konan-${{ runner.os }}-${{ runner.arch }}-
- name: Verify Apple toolchain
run: |
xcodebuild -version
xcrun --sdk iphoneos --show-sdk-version
- name: Configure runtime properties
run: |
printf '%s' "${RELEASE_PROPERTIES_BASE64}" | base64 --decode > local.properties
sed -i '' -E '/^[[:space:]]*(sdk\.dir|NUVIO_RELEASE_STORE_FILE)[[:space:]]*=/d' local.properties
- name: Prepare iOS dependencies
run: ./scripts/prepare-ios-dependencies.sh
- name: Build unsigned full IPA
run: |
(
while sleep 60; do
echo "::group::Build resources $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
uptime
vm_stat
ps -Ao pid,etime,%cpu,rss,command -r | head -n 12 || true
echo "::endgroup::"
done
) &
monitor_pid=$!
trap 'kill "${monitor_pid}" 2>/dev/null || true' EXIT
./scripts/build-ios-ipa.sh "${{ needs.prepare.outputs.version }}"
- name: Upload iOS artifact
uses: actions/upload-artifact@v7
with:
name: nuvio-${{ needs.prepare.outputs.version }}-ios-full-release
path: build/ios-ipa/*-full-release.ipa
if-no-files-found: error
release:
name: Create ${{ inputs.mode }} release
if: inputs.mode != 'dry-run'
needs:
- prepare
- android
- ios
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
RELEASE_MODE: ${{ inputs.mode }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
RELEASE_VERSION: ${{ needs.prepare.outputs.tag }}
RELEASE_BRANCH: ${{ github.ref_name }}
steps:
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
merge-multiple: true
- name: Create GitHub release
run: |
mapfile -t release_files < <(find release-assets -maxdepth 1 -type f \( -name '*.apk' -o -name '*.ipa' \) -print | sort)
if (( ${#release_files[@]} == 0 )); then
echo "No release packages were produced." >&2
exit 1
fi
release_args=(
"${RELEASE_TAG}"
--repo "${GITHUB_REPOSITORY}"
--target "${RELEASE_BRANCH}"
--title "${RELEASE_VERSION}"
--notes-file release-assets/release-notes.md
)
if [[ "${RELEASE_MODE}" == "draft" ]]; then
release_args+=(--draft)
fi
gh release create "${release_args[@]}" "${release_files[@]}"
store:
name: Update sideload source
if: inputs.mode == 'publish'
needs:
- prepare
- release
permissions:
contents: write
uses: ./.github/workflows/update-store-source.yml
with:
tag: ${{ needs.prepare.outputs.tag }}
version: ${{ needs.prepare.outputs.version }}