]> jfr.im git - yt-dlp.git/blame - .github/workflows/build.yml
[ie/afreecatv:live] Add `cdn` extractor-arg (#9666)
[yt-dlp.git] / .github / workflows / build.yml
CommitLineData
29cb20bd
SS
1name: Build Artifacts
2on:
3 workflow_call:
4 inputs:
5 version:
6 required: true
7 type: string
8 channel:
9 required: false
10 default: stable
11 type: string
12 unix:
13 default: true
14 type: boolean
15 linux_arm:
16 default: true
17 type: boolean
18 macos:
19 default: true
20 type: boolean
21 macos_legacy:
22 default: true
23 type: boolean
24 windows:
25 default: true
26 type: boolean
27 windows32:
28 default: true
29 type: boolean
30 meta_files:
31 default: true
32 type: boolean
20314dd4 33 origin:
34 required: false
35 default: ''
36 type: string
12647e03
SS
37 secrets:
38 GPG_SIGNING_KEY:
39 required: false
29cb20bd
SS
40
41 workflow_dispatch:
42 inputs:
43 version:
20314dd4 44 description: |
45 VERSION: yyyy.mm.dd[.rev] or rev
29cb20bd
SS
46 required: true
47 type: string
48 channel:
20314dd4 49 description: |
50 SOURCE of this build's updates: stable/nightly/master/<repo>
29cb20bd
SS
51 required: true
52 default: stable
53 type: string
54 unix:
55 description: yt-dlp, yt-dlp.tar.gz, yt-dlp_linux, yt-dlp_linux.zip
56 default: true
57 type: boolean
58 linux_arm:
59 description: yt-dlp_linux_aarch64, yt-dlp_linux_armv7l
60 default: true
61 type: boolean
62 macos:
63 description: yt-dlp_macos, yt-dlp_macos.zip
64 default: true
65 type: boolean
66 macos_legacy:
67 description: yt-dlp_macos_legacy
68 default: true
69 type: boolean
70 windows:
71 description: yt-dlp.exe, yt-dlp_min.exe, yt-dlp_win.zip
72 default: true
73 type: boolean
74 windows32:
75 description: yt-dlp_x86.exe
76 default: true
77 type: boolean
78 meta_files:
79 description: SHA2-256SUMS, SHA2-512SUMS, _update_spec
80 default: true
81 type: boolean
20314dd4 82 origin:
632b8ee5 83 description: Origin
20314dd4 84 required: false
632b8ee5 85 default: 'current repo'
20314dd4 86 type: choice
87 options:
632b8ee5 88 - 'current repo'
29cb20bd 89
c789fb77
A
90permissions:
91 contents: read
915f2a92
U
92
93jobs:
20314dd4 94 process:
95 runs-on: ubuntu-latest
96 outputs:
97 origin: ${{ steps.process_origin.outputs.origin }}
98 steps:
99 - name: Process origin
100 id: process_origin
101 run: |
632b8ee5 102 echo "origin=${{ inputs.origin == 'current repo' && github.repository || inputs.origin }}" | tee "$GITHUB_OUTPUT"
20314dd4 103
29cb20bd 104 unix:
20314dd4 105 needs: process
29cb20bd 106 if: inputs.unix
a6858cda 107 runs-on: ubuntu-latest
b5899f4f 108 steps:
5438593a 109 - uses: actions/checkout@v4
17b96974 110 with:
111 fetch-depth: 0 # Needed for changelog
b14e818b 112 - uses: actions/setup-python@v5
29cb20bd
SS
113 with:
114 python-version: "3.10"
b0059f04 115 - uses: conda-incubator/setup-miniconda@v3
29cb20bd 116 with:
a6858cda 117 miniforge-variant: Mambaforge
118 use-mamba: true
119 channels: conda-forge
120 auto-update-conda: true
29cb20bd 121 activate-environment: ""
a6858cda 122 auto-activate-base: false
29cb20bd
SS
123 - name: Install Requirements
124 run: |
1d03633c 125 sudo apt -y install zip pandoc man sed
b8a433aa 126 cat > ./requirements.txt << EOF
776d1c3f 127 python=3.10.*
58dd0f8d 128 pyinstaller
776d1c3f 129 brotli-python
130 EOF
b8a433aa 131 python devscripts/install_deps.py --print \
132 --exclude brotli --exclude brotlicffi \
58dd0f8d 133 --include secretstorage >> ./requirements.txt
b8a433aa 134 mamba create -n build --file ./requirements.txt
b5899f4f 135
29cb20bd
SS
136 - name: Prepare
137 run: |
20314dd4 138 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
17b96974 139 python devscripts/update_changelog.py -vv
b5899f4f 140 python devscripts/make_lazy_extractors.py
29cb20bd
SS
141 - name: Build Unix platform-independent binary
142 run: |
b5899f4f 143 make all tar
29cb20bd
SS
144 - name: Build Unix standalone binary
145 shell: bash -l {0}
146 run: |
a6858cda 147 unset LD_LIBRARY_PATH # Harmful; set by setup-python
148 conda activate build
a1b77842 149 python -m bundle.pyinstaller --onedir
e4afcfde 150 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
a1b77842 151 python -m bundle.pyinstaller
29cb20bd
SS
152 mv ./dist/yt-dlp_linux ./yt-dlp_linux
153 mv ./dist/yt-dlp_linux.zip ./yt-dlp_linux.zip
154
b73193c9 155 - name: Verify --update-to
156 if: vars.UPDATE_TO_VERIFICATION
157 run: |
158 binaries=("yt-dlp" "yt-dlp_linux")
159 for binary in "${binaries[@]}"; do
160 chmod +x ./${binary}
161 cp ./${binary} ./${binary}_downgraded
162 version="$(./${binary} --version)"
163 ./${binary}_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
164 downgraded_version="$(./${binary}_downgraded --version)"
165 [[ "$version" != "$downgraded_version" ]]
166 done
167
29cb20bd 168 - name: Upload artifacts
3876429d 169 uses: actions/upload-artifact@v4
29cb20bd 170 with:
eabbccc4 171 name: build-bin-${{ github.job }}
29cb20bd
SS
172 path: |
173 yt-dlp
174 yt-dlp.tar.gz
175 yt-dlp_linux
176 yt-dlp_linux.zip
3876429d 177 compression-level: 0
29cb20bd
SS
178
179 linux_arm:
20314dd4 180 needs: process
29cb20bd 181 if: inputs.linux_arm
17fc3dc4 182 permissions:
29cb20bd
SS
183 contents: read
184 packages: write # for creating cache
17fc3dc4 185 runs-on: ubuntu-latest
17fc3dc4
M
186 strategy:
187 matrix:
188 architecture:
29cb20bd
SS
189 - armv7
190 - aarch64
17fc3dc4
M
191
192 steps:
5438593a 193 - uses: actions/checkout@v4
29cb20bd
SS
194 with:
195 path: ./repo
196 - name: Virtualized Install, Prepare & Build
197 uses: yt-dlp/run-on-arch-action@v2
198 with:
199 # Ref: https://github.com/uraimo/run-on-arch-action/issues/55
200 env: |
201 GITHUB_WORKFLOW: build
202 githubToken: ${{ github.token }} # To cache image
203 arch: ${{ matrix.architecture }}
204 distro: ubuntu18.04 # Standalone executable should be built on minimum supported OS
205 dockerRunArgs: --volume "${PWD}/repo:/repo"
206 install: | # Installing Python 3.10 from the Deadsnakes repo raises errors
207 apt update
92039763 208 apt -y install zlib1g-dev libffi-dev python3.8 python3.8-dev python3.8-distutils python3-pip
29cb20bd 209 python3.8 -m pip install -U pip setuptools wheel
b8a433aa 210 # Cannot access any files from the repo directory at this stage
92039763 211 python3.8 -m pip install -U Pyinstaller mutagen pycryptodomex websockets brotli certifi secretstorage cffi
29cb20bd
SS
212
213 run: |
214 cd repo
b8a433aa 215 python3.8 devscripts/install_deps.py -o --include build
216 python3.8 devscripts/install_deps.py --include pyinstaller --include secretstorage # Cached version may be out of date
20314dd4 217 python3.8 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
29cb20bd 218 python3.8 devscripts/make_lazy_extractors.py
a1b77842 219 python3.8 -m bundle.pyinstaller
29cb20bd 220
b73193c9 221 if ${{ vars.UPDATE_TO_VERIFICATION && 'true' || 'false' }}; then
222 arch="${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}"
223 chmod +x ./dist/yt-dlp_linux_${arch}
224 cp ./dist/yt-dlp_linux_${arch} ./dist/yt-dlp_linux_${arch}_downgraded
225 version="$(./dist/yt-dlp_linux_${arch} --version)"
226 ./dist/yt-dlp_linux_${arch}_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
227 downgraded_version="$(./dist/yt-dlp_linux_${arch}_downgraded --version)"
228 [[ "$version" != "$downgraded_version" ]]
229 fi
230
29cb20bd 231 - name: Upload artifacts
3876429d 232 uses: actions/upload-artifact@v4
29cb20bd 233 with:
eabbccc4 234 name: build-bin-linux_${{ matrix.architecture }}
29cb20bd
SS
235 path: | # run-on-arch-action designates armv7l as armv7
236 repo/dist/yt-dlp_linux_${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}
3876429d 237 compression-level: 0
29cb20bd
SS
238
239 macos:
20314dd4 240 needs: process
29cb20bd 241 if: inputs.macos
0e5927ee 242 runs-on: macos-11
0e5927ee
R
243
244 steps:
5438593a 245 - uses: actions/checkout@v4
44a79958 246 # NB: Building universal2 does not work with python from actions/setup-python
29cb20bd
SS
247 - name: Install Requirements
248 run: |
0e5927ee 249 brew install coreutils
b8a433aa 250 python3 devscripts/install_deps.py --user -o --include build
58dd0f8d 251 python3 devscripts/install_deps.py --print --include pyinstaller > requirements.txt
44a79958 252 # We need to ignore wheels otherwise we break universal2 builds
b8a433aa 253 python3 -m pip install -U --user --no-binary :all: -r requirements.txt
52f5be1f 254 # We need to fuse our own universal2 wheels for curl_cffi
255 python3 -m pip install -U --user delocate
256 mkdir curl_cffi_whls curl_cffi_universal2
257 python3 devscripts/install_deps.py --print -o --include curl_cffi > requirements.txt
258 for platform in "macosx_11_0_arm64" "macosx_11_0_x86_64"; do
259 python3 -m pip download \
260 --only-binary=:all: \
261 --platform "${platform}" \
262 --pre -d curl_cffi_whls \
263 -r requirements.txt
264 done
265 python3 -m delocate.cmd.delocate_fuse curl_cffi_whls/curl_cffi*.whl -w curl_cffi_universal2
266 python3 -m delocate.cmd.delocate_fuse curl_cffi_whls/cffi*.whl -w curl_cffi_universal2
267 cd curl_cffi_universal2
268 for wheel in *cffi*.whl; do mv -n -- "${wheel}" "${wheel/x86_64/universal2}"; done
269 python3 -m pip install -U --user *cffi*.whl
b5899f4f 270
29cb20bd
SS
271 - name: Prepare
272 run: |
20314dd4 273 python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
44a79958 274 python3 devscripts/make_lazy_extractors.py
29cb20bd
SS
275 - name: Build
276 run: |
a1b77842 277 python3 -m bundle.pyinstaller --target-architecture universal2 --onedir
b5899f4f 278 (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
a1b77842 279 python3 -m bundle.pyinstaller --target-architecture universal2
b5899f4f 280
b73193c9 281 - name: Verify --update-to
282 if: vars.UPDATE_TO_VERIFICATION
283 run: |
284 chmod +x ./dist/yt-dlp_macos
285 cp ./dist/yt-dlp_macos ./dist/yt-dlp_macos_downgraded
286 version="$(./dist/yt-dlp_macos --version)"
287 ./dist/yt-dlp_macos_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
288 downgraded_version="$(./dist/yt-dlp_macos_downgraded --version)"
289 [[ "$version" != "$downgraded_version" ]]
290
29cb20bd 291 - name: Upload artifacts
3876429d 292 uses: actions/upload-artifact@v4
29cb20bd 293 with:
eabbccc4 294 name: build-bin-${{ github.job }}
29cb20bd
SS
295 path: |
296 dist/yt-dlp_macos
297 dist/yt-dlp_macos.zip
3876429d 298 compression-level: 0
b5899f4f 299
29cb20bd 300 macos_legacy:
20314dd4 301 needs: process
29cb20bd 302 if: inputs.macos_legacy
6d916fe7 303 runs-on: macos-latest
28cdb605 304
6d916fe7 305 steps:
5438593a 306 - uses: actions/checkout@v4
29cb20bd
SS
307 - name: Install Python
308 # We need the official Python, because the GA ones only support newer macOS versions
309 env:
310 PYTHON_VERSION: 3.10.5
311 MACOSX_DEPLOYMENT_TARGET: 10.9 # Used up by the Python build tools
312 run: |
6d916fe7
SL
313 # Hack to get the latest patch version. Uncomment if needed
314 #brew install python@3.10
315 #export PYTHON_VERSION=$( $(brew --prefix)/opt/python@3.10/bin/python3 --version | cut -d ' ' -f 2 )
316 curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg -o "python.pkg"
317 sudo installer -pkg python.pkg -target /
318 python3 --version
29cb20bd
SS
319 - name: Install Requirements
320 run: |
6d916fe7 321 brew install coreutils
b8a433aa 322 python3 devscripts/install_deps.py --user -o --include build
b19ae095 323 python3 devscripts/install_deps.py --user --include pyinstaller
6d916fe7 324
29cb20bd
SS
325 - name: Prepare
326 run: |
20314dd4 327 python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
6d916fe7 328 python3 devscripts/make_lazy_extractors.py
29cb20bd
SS
329 - name: Build
330 run: |
a1b77842 331 python3 -m bundle.pyinstaller
c4b6c5c7 332 mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
6d916fe7 333
b73193c9 334 - name: Verify --update-to
335 if: vars.UPDATE_TO_VERIFICATION
336 run: |
337 chmod +x ./dist/yt-dlp_macos_legacy
338 cp ./dist/yt-dlp_macos_legacy ./dist/yt-dlp_macos_legacy_downgraded
339 version="$(./dist/yt-dlp_macos_legacy --version)"
340 ./dist/yt-dlp_macos_legacy_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
341 downgraded_version="$(./dist/yt-dlp_macos_legacy_downgraded --version)"
342 [[ "$version" != "$downgraded_version" ]]
343
29cb20bd 344 - name: Upload artifacts
3876429d 345 uses: actions/upload-artifact@v4
29cb20bd 346 with:
eabbccc4 347 name: build-bin-${{ github.job }}
29cb20bd
SS
348 path: |
349 dist/yt-dlp_macos_legacy
3876429d 350 compression-level: 0
6d916fe7 351
29cb20bd 352 windows:
20314dd4 353 needs: process
29cb20bd 354 if: inputs.windows
915f2a92 355 runs-on: windows-latest
47930b73 356
915f2a92 357 steps:
5438593a 358 - uses: actions/checkout@v4
b14e818b 359 - uses: actions/setup-python@v5
29cb20bd
SS
360 with: # 3.8 is used for Win7 support
361 python-version: "3.8"
362 - name: Install Requirements
363 run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
b8a433aa 364 python devscripts/install_deps.py -o --include build
52f5be1f 365 python devscripts/install_deps.py --include py2exe --include curl_cffi
b8a433aa 366 python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.8.0-py3-none-any.whl"
b5899f4f 367
29cb20bd
SS
368 - name: Prepare
369 run: |
20314dd4 370 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
b5899f4f 371 python devscripts/make_lazy_extractors.py
29cb20bd
SS
372 - name: Build
373 run: |
a1b77842 374 python -m bundle.py2exe
b5899f4f 375 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
a1b77842 376 python -m bundle.pyinstaller
377 python -m bundle.pyinstaller --onedir
b5899f4f 378 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
c4b6c5c7 379
b73193c9 380 - name: Verify --update-to
381 if: vars.UPDATE_TO_VERIFICATION
382 run: |
383 foreach ($name in @("yt-dlp","yt-dlp_min")) {
384 Copy-Item "./dist/${name}.exe" "./dist/${name}_downgraded.exe"
385 $version = & "./dist/${name}.exe" --version
386 & "./dist/${name}_downgraded.exe" -v --update-to yt-dlp/yt-dlp@2023.03.04
387 $downgraded_version = & "./dist/${name}_downgraded.exe" --version
388 if ($version -eq $downgraded_version) {
389 exit 1
390 }
391 }
392
29cb20bd 393 - name: Upload artifacts
3876429d 394 uses: actions/upload-artifact@v4
29cb20bd 395 with:
eabbccc4 396 name: build-bin-${{ github.job }}
29cb20bd
SS
397 path: |
398 dist/yt-dlp.exe
399 dist/yt-dlp_min.exe
400 dist/yt-dlp_win.zip
3876429d 401 compression-level: 0
386cdfdb 402
29cb20bd 403 windows32:
20314dd4 404 needs: process
29cb20bd 405 if: inputs.windows32
915f2a92 406 runs-on: windows-latest
47930b73 407
915f2a92 408 steps:
5438593a 409 - uses: actions/checkout@v4
b14e818b 410 - uses: actions/setup-python@v5
f4b95aca 411 with:
412 python-version: "3.8"
29cb20bd
SS
413 architecture: "x86"
414 - name: Install Requirements
415 run: |
b8a433aa 416 python devscripts/install_deps.py -o --include build
417 python devscripts/install_deps.py
418 python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-5.8.0-py3-none-any.whl"
b5899f4f 419
29cb20bd
SS
420 - name: Prepare
421 run: |
20314dd4 422 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
b5899f4f 423 python devscripts/make_lazy_extractors.py
29cb20bd
SS
424 - name: Build
425 run: |
a1b77842 426 python -m bundle.pyinstaller
b5899f4f 427
b73193c9 428 - name: Verify --update-to
429 if: vars.UPDATE_TO_VERIFICATION
430 run: |
431 foreach ($name in @("yt-dlp_x86")) {
432 Copy-Item "./dist/${name}.exe" "./dist/${name}_downgraded.exe"
433 $version = & "./dist/${name}.exe" --version
434 & "./dist/${name}_downgraded.exe" -v --update-to yt-dlp/yt-dlp@2023.03.04
435 $downgraded_version = & "./dist/${name}_downgraded.exe" --version
436 if ($version -eq $downgraded_version) {
437 exit 1
438 }
439 }
440
29cb20bd 441 - name: Upload artifacts
3876429d 442 uses: actions/upload-artifact@v4
29cb20bd 443 with:
eabbccc4 444 name: build-bin-${{ github.job }}
29cb20bd
SS
445 path: |
446 dist/yt-dlp_x86.exe
3876429d 447 compression-level: 0
29cb20bd
SS
448
449 meta_files:
c4efa0ae 450 if: inputs.meta_files && always() && !cancelled()
29cb20bd 451 needs:
20314dd4 452 - process
29cb20bd
SS
453 - unix
454 - linux_arm
455 - macos
456 - macos_legacy
457 - windows
458 - windows32
14b17a55 459 runs-on: ubuntu-latest
14b17a55 460 steps:
3876429d 461 - uses: actions/download-artifact@v4
462 with:
463 path: artifact
eabbccc4 464 pattern: build-bin-*
3876429d 465 merge-multiple: true
b1f94422 466
29cb20bd
SS
467 - name: Make SHA2-SUMS files
468 run: |
469 cd ./artifact/
e8032503 470 # make sure SHA sums are also printed to stdout
471 sha256sum * | tee ../SHA2-256SUMS
472 sha512sum * | tee ../SHA2-512SUMS
c4b6c5c7 473
29cb20bd
SS
474 - name: Make Update spec
475 run: |
476 cat >> _update_spec << EOF
477 # This file is used for regulating self-update
f4b95aca 478 lock 2022.08.18.36 .+ Python 3\.6
479 lock 2023.11.16 (?!win_x86_exe).+ Python 3\.7
480 lock 2023.11.16 win_x86_exe .+ Windows-(?:Vista|2008Server)
481 lockV2 yt-dlp/yt-dlp 2022.08.18.36 .+ Python 3\.6
482 lockV2 yt-dlp/yt-dlp 2023.11.16 (?!win_x86_exe).+ Python 3\.7
483 lockV2 yt-dlp/yt-dlp 2023.11.16 win_x86_exe .+ Windows-(?:Vista|2008Server)
484 lockV2 yt-dlp/yt-dlp-nightly-builds 2023.11.15.232826 (?!win_x86_exe).+ Python 3\.7
485 lockV2 yt-dlp/yt-dlp-nightly-builds 2023.11.15.232826 win_x86_exe .+ Windows-(?:Vista|2008Server)
486 lockV2 yt-dlp/yt-dlp-master-builds 2023.11.15.232812 (?!win_x86_exe).+ Python 3\.7
487 lockV2 yt-dlp/yt-dlp-master-builds 2023.11.15.232812 win_x86_exe .+ Windows-(?:Vista|2008Server)
29cb20bd
SS
488 EOF
489
12647e03
SS
490 - name: Sign checksum files
491 env:
492 GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
493 if: env.GPG_SIGNING_KEY != ''
494 run: |
495 gpg --batch --import <<< "${{ secrets.GPG_SIGNING_KEY }}"
496 for signfile in ./SHA*SUMS; do
497 gpg --batch --detach-sign "$signfile"
498 done
499
29cb20bd 500 - name: Upload artifacts
3876429d 501 uses: actions/upload-artifact@v4
29cb20bd 502 with:
3876429d 503 name: build-${{ github.job }}
29cb20bd 504 path: |
29cb20bd 505 _update_spec
3876429d 506 SHA*SUMS*
507 compression-level: 0
eabbccc4 508 overwrite: true