forked from marlboro-advance/mpvlibAndroid
-
Notifications
You must be signed in to change notification settings - Fork 4
339 lines (284 loc) · 10.3 KB
/
release.yml
File metadata and controls
339 lines (284 loc) · 10.3 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: release
on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
release_tag:
description: "Existing tag to release manually, example: v1.0.0"
required: true
type: string
draft:
description: "Create release as draft"
required: true
default: true
type: boolean
prerelease:
description: "Mark release as prerelease"
required: true
default: false
type: boolean
concurrency:
group: release-${{ github.ref }}-${{ inputs.release_tag || '' }}
cancel-in-progress: false
jobs:
release:
name: Build and publish release
runs-on: ubuntu-24.04
permissions:
contents: write
env:
CACHE_MODE: folder
CACHE_FOLDER: ${{ github.workspace }}/gh-cache
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_MAXSIZE: 5G
CCACHE_COMPRESS: "true"
CCACHE_NOHASHDIR: "true"
CCACHE_DISABLE: "true"
GRADLE_OPTS: >-
-Xmx4G
-Dorg.gradle.daemon=false
-Dorg.gradle.caching=true
-Dorg.gradle.parallel=true
-Dorg.gradle.configureondemand=true
steps:
- name: Resolve release tag
id: resolve_tag
run: |
set -euo pipefail
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION_TAG="${GITHUB_REF#refs/tags/}"
else
VERSION_TAG="${{ inputs.release_tag }}"
fi
if [[ -z "$VERSION_TAG" ]]; then
echo "Release tag is empty."
exit 1
fi
echo "VERSION_TAG=$VERSION_TAG" >> "$GITHUB_ENV"
echo "version_tag=$VERSION_TAG" >> "$GITHUB_OUTPUT"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.resolve_tag.outputs.version_tag }}
- name: Verify release tag exists
run: |
set -euo pipefail
git fetch --force --tags
if ! git rev-parse "$VERSION_TAG" >/dev/null 2>&1; then
echo "Tag '$VERSION_TAG' does not exist."
echo "Create it first:"
echo "git tag $VERSION_TAG"
echo "git push origin $VERSION_TAG"
exit 1
fi
echo "Using release tag: $VERSION_TAG"
- name: Setup Java 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin
cache: gradle
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Export CI environment variables
run: |
buildscripts/include/ci.sh export >> "$GITHUB_ENV"
- name: Restore Android SDK cache
id: android-sdk-cache
uses: actions/cache/restore@v4
with:
path: buildscripts/sdk/
key: android-sdk-${{ runner.os }}-${{ hashFiles('buildscripts/include/depinfo.sh', 'buildscripts/include/download-sdk.sh') }}
restore-keys: |
android-sdk-${{ runner.os }}-
- name: Restore native prefix cache
id: native-prefix-cache
uses: actions/cache/restore@v4
with:
path: gh-cache/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}
restore-keys: |
native-prefix-${{ runner.os }}-
- name: Restore ccache
id: ccache-cache
uses: actions/cache/restore@v4
with:
path: .ccache/
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ github.ref_name }}-
ccache-${{ runner.os }}-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
autoconf \
automake \
build-essential \
ccache \
cmake \
gcc g++ \
gettext \
gperf \
libtool \
nasm \
ninja-build \
pkg-config \
python3 \
python3-pip \
unzip \
wget
- name: Install Python build dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade meson jinja2 jsonschema
- name: Download and extract source dependencies
run: |
set -euxo pipefail
cd buildscripts
./download.sh
- name: Save Android SDK cache
if: steps.android-sdk-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: buildscripts/sdk/
key: android-sdk-${{ runner.os }}-${{ hashFiles('buildscripts/include/depinfo.sh', 'buildscripts/include/download-sdk.sh') }}
- name: Save native prefix cache
if: steps.native-prefix-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: gh-cache/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}
- name: Show ccache stats before build
run: |
ccache --zero-stats || true
ccache --show-stats || true
- name: Build release AAR for all Android architectures
run: |
set -euxo pipefail
unset ANDROID_SDK_ROOT
cd buildscripts
source include/build_config.sh
arches=(arm64)
[ "$ENABLE_ARM_V9A" = "true" ] && arches+=(arm64-v9a)
[ "$ENABLE_X86_ARCH" = "true" ] && arches+=(x86 x86_64)
for arch in "${arches[@]}"; do
./buildall.sh --arch "$arch" mpv
done
./buildall.sh --clean mpv-android
- name: Show ccache stats after build
if: always()
run: |
ccache --show-stats || true
- name: Save ccache
if: always() && steps.ccache-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .ccache/
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ github.sha }}
- name: Stage release files
run: |
set -euxo pipefail
mkdir -p dist
AAR_PATH="app/build/outputs/aar/app-release.aar"
RELEASE_AAR="dist/mpv-android-lib-${VERSION_TAG}.aar"
if [ ! -f "$AAR_PATH" ]; then
echo "AAR file not found at: $AAR_PATH"
find app/build/outputs -type f || true
exit 1
fi
cp "$AAR_PATH" "$RELEASE_AAR"
sha256sum "$RELEASE_AAR" > "dist/mpv-android-lib-${VERSION_TAG}.aar.sha256"
- name: Generate release notes from commit history
run: |
set -euo pipefail
source buildscripts/include/build_config.sh
RELEASE_NOTES="dist/release-notes-${VERSION_TAG}.md"
CURRENT_COMMIT="$(git rev-list -n 1 "$VERSION_TAG")"
PREVIOUS_TAG="$(git describe --tags --abbrev=0 "${VERSION_TAG}^" 2>/dev/null || true)"
{
echo "# mpv-android-lib ${VERSION_TAG}"
echo ""
echo "## Release Artifact"
echo ""
echo "- \`mpv-android-lib-${VERSION_TAG}.aar\`"
echo "- \`mpv-android-lib-${VERSION_TAG}.aar.sha256\`"
echo ""
echo "## Included Android ABIs"
echo ""
echo "- \`arm64-v8a\` / \`arm64\` (NEON optimized, 8-10% boost)"
if [ "$ENABLE_ARM_V9A" = "true" ]; then
echo "- \`arm64-v9a\` (SVE2 optimized, 15-18% boost — Snapdragon 8 Gen 2+, Dimensity 9200+, Exynos 2400+)"
fi
if [ "$ENABLE_X86_ARCH" = "true" ]; then
echo "- \`x86\`"
echo "- \`x86_64\`"
fi
echo ""
echo "## Build Environment"
echo ""
echo "- Runner: \`${RUNNER_OS}\`"
echo "- Ubuntu: \`24.04\`"
echo "- Java: \`17 / Temurin\`"
echo "- Python: \`3.13\`"
echo "- Repository: \`${GITHUB_REPOSITORY}\`"
echo "- Tag: \`${VERSION_TAG}\`"
echo "- Commit: \`${CURRENT_COMMIT}\`"
echo ""
echo "## Checksums"
echo ""
echo '```text'
cat "dist/mpv-android-lib-${VERSION_TAG}.aar.sha256"
echo '```'
echo ""
if [[ -n "$PREVIOUS_TAG" ]]; then
echo "## Commit History"
echo ""
echo "Changes from \`${PREVIOUS_TAG}\` to \`${VERSION_TAG}\`:"
echo ""
if git log --oneline "${PREVIOUS_TAG}..${VERSION_TAG}" | grep -q .; then
git log \
--pretty=format:"- %s ([%h](https://github.com/${GITHUB_REPOSITORY}/commit/%H)) by %an" \
"${PREVIOUS_TAG}..${VERSION_TAG}"
else
echo "- No commits found between \`${PREVIOUS_TAG}\` and \`${VERSION_TAG}\`."
fi
else
echo "## Commit History"
echo ""
echo "No previous tag found. Showing commits reachable from \`${VERSION_TAG}\`:"
echo ""
git log \
--pretty=format:"- %s ([%h](https://github.com/${GITHUB_REPOSITORY}/commit/%H)) by %an" \
"$VERSION_TAG"
fi
echo ""
} > "$RELEASE_NOTES"
cat "$RELEASE_NOTES"
- name: Upload release files to workflow artifacts
uses: actions/upload-artifact@v4
with:
name: mpv-android-lib-${{ env.VERSION_TAG }}
path: |
dist/mpv-android-lib-${{ env.VERSION_TAG }}.aar
dist/mpv-android-lib-${{ env.VERSION_TAG }}.aar.sha256
dist/release-notes-${{ env.VERSION_TAG }}.md
if-no-files-found: error
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION_TAG }}
name: mpv-android-lib ${{ env.VERSION_TAG }}
body_path: dist/release-notes-${{ env.VERSION_TAG }}.md
files: |
dist/mpv-android-lib-${{ env.VERSION_TAG }}.aar
dist/mpv-android-lib-${{ env.VERSION_TAG }}.aar.sha256
dist/release-notes-${{ env.VERSION_TAG }}.md
draft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft || true }}
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}