This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
forked from zhongfly/mpv-winbuild
-
Notifications
You must be signed in to change notification settings - Fork 12
355 lines (318 loc) · 13.8 KB
/
mpv_clang.yml
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
name: mpv clang
defaults:
run:
shell: bash
on:
workflow_dispatch:
inputs:
command:
description: 'Run custom command before building'
required: false
type: string
sourceforge:
description: 'Upload to Sourceforge'
required: false
default: false
type: boolean
github_release:
description: 'Upload to Github release'
required: false
default: false
type: boolean
mpv_tarball:
description: 'Build latest mpv tarball'
required: false
default: false
type: boolean
jobs:
build_mpv:
name: Building mpv
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
strategy:
fail-fast: false
matrix:
bit: [i686, x86_64, x86_64_v3]
env:
BIT: ${{ matrix.bit }}
container:
image: docker://ghcr.io/shinchiro/archlinux:latest
outputs:
mpv_ver: ${{ steps.build_mpv_step.outputs.mpv_ver }}
steps:
- name: Init variable
run: |
if [[ $BIT == "i686" ]]; then
echo "arch=i686" >> $GITHUB_ENV
elif [[ $BIT == "x86_64" ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
elif [[ $BIT == "x86_64_v3" ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
echo "x86_64_level=-v3" >> $GITHUB_ENV
fi
- name: Setup git config
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global pull.rebase true
git config --global rebase.autoStash true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: master
- name: Loading clang sysroot cache
uses: actions/cache/restore@main
with:
path: |
clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-clang_root
- name: Loading repository cache
uses: actions/cache/restore@main
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-repository
- name: Loading ${{ matrix.bit }} toolchain cache
uses: actions/cache/restore@main
with:
path: |
build_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain
- name: Running custom command
if: ${{ github.event.inputs.command != '' }}
continue-on-error: true
run: ${{ github.event.inputs.command }}
- name: Configuring CMake & Downloading source
run: |
if [[ $BIT == x86_64_v3 ]]; then echo "x86_64_v3_ARCH=-DGCC_ARCH=x86-64-v3" >> $GITHUB_ENV; fi
cmake -DTARGET_ARCH=${{ env.arch }}-w64-mingw32 -DCOMPILER_TOOLCHAIN=clang ${{ env.x86_64_v3_ARCH }} -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_$BIT/$BIT-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -DENABLE_CCACHE=ON -DCLANG_PACKAGES_LTO=ON -G Ninja --fresh -B build_$BIT -S $PWD
ninja -C build_$BIT download || true
- name: Building mpv
id: build_mpv_step
env:
MPV_TARBALL: ${{ github.event.inputs.mpv_tarball }}
run: |
ninja -C build_$BIT update
ninja -C build_$BIT llvm-copy-builtin
$MPV_TARBALL && ninja -C build_$BIT mpv-release || ninja -C build_$BIT mpv
$MPV_TARBALL && echo "mpv_ver=$(cat build_$BIT/packages/mpv-release-prefix/VERSION)" >> $GITHUB_OUTPUT || echo "mpv_ver=UNKNOWN" >> $GITHUB_OUTPUT
- name: Packaging mpv
run: |
mkdir -p release_$BIT
ninja -C build_$BIT mpv-packaging; mv build_$BIT/mpv*.7z release_$BIT
if [[ $BIT == x86_64_v3 ]]; then for dir in release_$BIT/mpv-*; do name=$(basename $dir); mv $dir $(dirname $dir)/${name/x86_64/x86_64-v3}; done; fi
- name: Copying ffmpeg
run: |
hash=$(git -C src_packages/ffmpeg rev-parse --short HEAD)
7z a -m0=lzma2 -mx=9 -ms=on release_$BIT/ffmpeg-${{ env.arch }}${{ env.x86_64_level }}-git-$hash.7z ./build_$BIT/$BIT-w64-mingw32/bin/ffmpeg.exe
- name: Collecting logs
if: always()
run: |
mkdir -p build_${BIT}_logs
cp -fr $(find build_$BIT -type f -iname "*-*.log" -or -wholename "*/ffbuild/config.log") build_${BIT}_logs || true
7z a -m0=lzma2 -mx=9 -ms=on logs.7z build*logs
- name: Uploading logs
uses: actions/upload-artifact@master
if: always()
with:
name: mpv-${{ matrix.bit }}-logs
path: logs.7z
retention-days: 1
- name: Uploading ${{ matrix.bit }} build
uses: actions/upload-artifact@master
with:
name: mpv-${{ matrix.bit }}
path: release_${{ matrix.bit }}/mpv-${{ env.arch }}*
- name: Uploading ${{ matrix.bit }} debug
uses: actions/upload-artifact@master
with:
name: mpv-${{ matrix.bit }}-debug
path: release_${{ matrix.bit }}/mpv-debug-${{ env.arch }}*
- name: Cleaning build directory
if: always()
run: |
rm -rf build_$BIT/mpv*
rm -rf release_$BIT/mpv-debug*.7z
- name: Cleaning rust toolchain directory
if: always()
run: |
ninja -C build_$BIT cargo-clean
- name: Saving clang sysroot cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == 'x86_64' }}
with:
path: |
clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
- name: Saving repository cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == 'x86_64' }}
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
- name: Saving ${{ matrix.bit }} toolchain cache
uses: actions/cache/save@main
if: always()
with:
path: |
build_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain-${{ github.run_id }}
- name: Saving release_${{ matrix.bit }} cache
uses: actions/cache/save@main
with:
path: release_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-release_${{ matrix.bit }}-${{ github.run_id }}
release:
name: Upload releases
runs-on: ubuntu-latest
needs: build_mpv
env:
GH_TOKEN: ${{ github.token }}
CURL_RETRIES: "--connect-timeout 60 --retry 999 --retry-delay 5 --retry-all-errors"
release_i686_key: ${{ secrets.CACHE_VERSION }}-release_i686-${{ github.run_id }}
release_x86_64_key: ${{ secrets.CACHE_VERSION }}-release_x86_64-${{ github.run_id }}
release_x86_64_v3_key: ${{ secrets.CACHE_VERSION }}-release_x86_64_v3-${{ github.run_id }}
container:
image: docker://alpine:latest
steps:
- name: Installing dependencies
shell: sh
run: |
apk add --update --no-cache bash git file openssh curl tar zstd jq
git config --global pull.rebase true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: master
- name: Loading release_i686 cache
uses: actions/cache/restore@main
with:
path: release_i686
key: ${{ env.release_i686_key }}
- name: Loading release_x86_64 cache
uses: actions/cache/restore@main
with:
path: release_x86_64
key: ${{ env.release_x86_64_key }}
- name: Loading release_x86_64_v3 cache
uses: actions/cache/restore@main
with:
path: release_x86_64_v3
key: ${{ env.release_x86_64_v3_key }}
- name: Moving archives
run: |
mkdir -p release
mv release_i686/* release_x86_64/* release_x86_64_v3/* release
du -ah release/*
- name: Uploading packages to Sourceforge
id: upload_packages_sf
if: ${{ github.event.inputs.sourceforge == 'true' }}
continue-on-error: true
env:
MPV_VER: ${{ needs.build_mpv.outputs.mpv_ver }}
run: |
mkdir -p /root/.ssh/
echo "${{ secrets.SF_PRIVATE_KEY }}" > sf_key
pubkey=$(cat <<END
frs.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC
END
)
echo $pubkey > /root/.ssh/known_hosts
chmod 400 sf_key
chmod -R 700 /root
sftp -i sf_key [email protected]:/home/frs/project/mpv-player-windows <<END
put release/mpv-dev* libmpv
put release/mpv-i686* 32bit
put release/mpv-x86_64-[!v3]* 64bit
put release/mpv-x86_64-v3* 64bit-v3
put release/mpv-$MPV_VER* release
END
- name: Uploading packages to Github release
id: upload_packages_gh
if: ${{ github.event.inputs.github_release == 'true' && github.event.inputs.mpv_tarball == 'false' }}
continue-on-error: true
run: |
short_date=$(date "+%Y%m%d")
body=$(cat <<END
![GitHub release (by tag)](https://img.shields.io/github/downloads/shinchiro/mpv-winbuild-cmake/$short_date/total?label=Downloads)
**Workflow run**: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
END
)
id=$(curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases -d @- <<END | jq -r '.id'
{
"tag_name": "$short_date",
"name": "$short_date",
"body": "$(echo ${body//$'\n'/'\n'})"
}
END
)
for file in release/*.7z; do curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -X POST -H "Accept: application/vnd.github.v3+json" -H "Content-Type: $(file -b --mime-type $file)" https://uploads.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/$id/assets?name=$(basename $file) --data-binary @$file; done
- name: Pruning tags
continue-on-error: true
run: |
# Keep latest 30 tags/releases
git fetch --tags
tag_list=($(git tag | sort -r))
old=${tag_list[@]:30}
for tag in ${old[@]}; do
id=$(curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X GET -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/tags/$tag | jq -r '.id')
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/$id
git tag -d $tag
done
git push --tags --prune https://shinchiro:[email protected]/shinchiro/mpv-winbuild-cmake
- name: Delete releases cache
if: ${{ github.event.inputs.github_release == 'false' || steps.upload_packages_gh.outcome == 'success' }}
run: |
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release_i686_key
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release_x86_64_key
curl -u shinchiro:$GH_TOKEN $CURL_RETRIES -s -o /dev/null -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/caches?key=$release_x86_64_v3_key
call_workflow:
name: Run mpv_gcc
runs-on: ubuntu-latest
needs: build_mpv
env:
GH_TOKEN: ${{ github.token }}
GH_COMMAND: ${{ github.event.inputs.command }}
steps:
- name: Run mpv_gcc.yml
run: |
curl -u shinchiro:$GH_TOKEN -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/workflows/mpv_gcc.yml/dispatches -d @- <<EOF
{
"ref": "master",
"inputs": {
"sourceforge": "false",
"github_release": "true",
"mpv_tarball": "false",
"command": "$GH_COMMAND"
}
}
EOF
gist:
name: Gist
runs-on: ubuntu-latest
needs: build_mpv
if: ${{ always() }}
env:
GH_TOKEN: ${{ secrets.GIST_TOKEN }}
RUN_ID: ${{ github.run_id }}
steps:
- name: Setup git credentials
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Upload job logs to gist
run: |
url=$(curl -su shinchiro:$GH_TOKEN -X GET -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/runs/$RUN_ID/jobs | jq -r '.jobs[0] | .url')
curl -sLu shinchiro:$GH_TOKEN -X GET -H "Accept: application/vnd.github.v3+json" $url/logs -o mpv_log
git clone --depth 1 https://shinchiro:[email protected]/90308c6632c9010d03b325c9ca6a4b6f job_log
cp -f mpv_log job_log/mpv_log
git -C job_log add .
git -C job_log commit --amend --no-edit
git -C job_log push -f https://shinchiro:[email protected]/90308c6632c9010d03b325c9ca6a4b6f