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