]> jfr.im git - yt-dlp.git/blob - .github/workflows/build.yml
[build] Bump `actions/upload-artifact` to v4 and adjust workflows
[yt-dlp.git] / .github / workflows / build.yml
1 name: Build Artifacts
2 on:
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
33 origin:
34 required: false
35 default: ''
36 type: string
37 secrets:
38 GPG_SIGNING_KEY:
39 required: false
40
41 workflow_dispatch:
42 inputs:
43 version:
44 description: |
45 VERSION: yyyy.mm.dd[.rev] or rev
46 required: true
47 type: string
48 channel:
49 description: |
50 SOURCE of this build's updates: stable/nightly/master/<repo>
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
82 origin:
83 description: Origin
84 required: false
85 default: 'current repo'
86 type: choice
87 options:
88 - 'current repo'
89
90 permissions:
91 contents: read
92
93 jobs:
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: |
102 echo "origin=${{ inputs.origin == 'current repo' && github.repository || inputs.origin }}" | tee "$GITHUB_OUTPUT"
103
104 unix:
105 needs: process
106 if: inputs.unix
107 runs-on: ubuntu-latest
108 steps:
109 - uses: actions/checkout@v4
110 - uses: actions/setup-python@v5
111 with:
112 python-version: "3.10"
113 - uses: conda-incubator/setup-miniconda@v3
114 with:
115 miniforge-variant: Mambaforge
116 use-mamba: true
117 channels: conda-forge
118 auto-update-conda: true
119 activate-environment: ""
120 auto-activate-base: false
121 - name: Install Requirements
122 run: |
123 sudo apt -y install zip pandoc man sed
124 cat > ./requirements.txt << EOF
125 python=3.10.*
126 brotli-python
127 EOF
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
132
133 - name: Prepare
134 run: |
135 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
136 python devscripts/make_lazy_extractors.py
137 - name: Build Unix platform-independent binary
138 run: |
139 make all tar
140 - name: Build Unix standalone binary
141 shell: bash -l {0}
142 run: |
143 unset LD_LIBRARY_PATH # Harmful; set by setup-python
144 conda activate build
145 python -m bundle.pyinstaller --onedir
146 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
147 python -m bundle.pyinstaller
148 mv ./dist/yt-dlp_linux ./yt-dlp_linux
149 mv ./dist/yt-dlp_linux.zip ./yt-dlp_linux.zip
150
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
164 - name: Upload artifacts
165 uses: actions/upload-artifact@v4
166 with:
167 name: build-${{ github.job }}
168 path: |
169 yt-dlp
170 yt-dlp.tar.gz
171 yt-dlp_linux
172 yt-dlp_linux.zip
173 compression-level: 0
174
175 linux_arm:
176 needs: process
177 if: inputs.linux_arm
178 permissions:
179 contents: read
180 packages: write # for creating cache
181 runs-on: ubuntu-latest
182 strategy:
183 matrix:
184 architecture:
185 - armv7
186 - aarch64
187
188 steps:
189 - uses: actions/checkout@v4
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
204 apt -y install zlib1g-dev libffi-dev python3.8 python3.8-dev python3.8-distutils python3-pip
205 python3.8 -m pip install -U pip setuptools wheel
206 # Cannot access any files from the repo directory at this stage
207 python3.8 -m pip install -U Pyinstaller mutagen pycryptodomex websockets brotli certifi secretstorage cffi
208
209 run: |
210 cd repo
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
213 python3.8 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
214 python3.8 devscripts/make_lazy_extractors.py
215 python3.8 -m bundle.pyinstaller
216
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
227 - name: Upload artifacts
228 uses: actions/upload-artifact@v4
229 with:
230 name: build-linux_${{ matrix.architecture }}
231 path: | # run-on-arch-action designates armv7l as armv7
232 repo/dist/yt-dlp_linux_${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}
233 compression-level: 0
234
235 macos:
236 needs: process
237 if: inputs.macos
238 runs-on: macos-11
239
240 steps:
241 - uses: actions/checkout@v4
242 # NB: Building universal2 does not work with python from actions/setup-python
243 - name: Install Requirements
244 run: |
245 brew install coreutils
246 python3 devscripts/install_deps.py --user -o --include build
247 python3 devscripts/install_deps.py --print --include pyinstaller > requirements.txt
248 # We need to ignore wheels otherwise we break universal2 builds
249 python3 -m pip install -U --user --no-binary :all: -r requirements.txt
250
251 - name: Prepare
252 run: |
253 python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
254 python3 devscripts/make_lazy_extractors.py
255 - name: Build
256 run: |
257 python3 -m bundle.pyinstaller --target-architecture universal2 --onedir
258 (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
259 python3 -m bundle.pyinstaller --target-architecture universal2
260
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
271 - name: Upload artifacts
272 uses: actions/upload-artifact@v4
273 with:
274 name: build-${{ github.job }}
275 path: |
276 dist/yt-dlp_macos
277 dist/yt-dlp_macos.zip
278 compression-level: 0
279
280 macos_legacy:
281 needs: process
282 if: inputs.macos_legacy
283 runs-on: macos-latest
284
285 steps:
286 - uses: actions/checkout@v4
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: |
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
299 - name: Install Requirements
300 run: |
301 brew install coreutils
302 python3 devscripts/install_deps.py --user -o --include build
303 python3 devscripts/install_deps.py --user --include pyinstaller
304
305 - name: Prepare
306 run: |
307 python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
308 python3 devscripts/make_lazy_extractors.py
309 - name: Build
310 run: |
311 python3 -m bundle.pyinstaller
312 mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
313
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
324 - name: Upload artifacts
325 uses: actions/upload-artifact@v4
326 with:
327 name: build-${{ github.job }}
328 path: |
329 dist/yt-dlp_macos_legacy
330 compression-level: 0
331
332 windows:
333 needs: process
334 if: inputs.windows
335 runs-on: windows-latest
336
337 steps:
338 - uses: actions/checkout@v4
339 - uses: actions/setup-python@v5
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
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"
347
348 - name: Prepare
349 run: |
350 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
351 python devscripts/make_lazy_extractors.py
352 - name: Build
353 run: |
354 python -m bundle.py2exe
355 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
356 python -m bundle.pyinstaller
357 python -m bundle.pyinstaller --onedir
358 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
359
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
373 - name: Upload artifacts
374 uses: actions/upload-artifact@v4
375 with:
376 name: build-${{ github.job }}
377 path: |
378 dist/yt-dlp.exe
379 dist/yt-dlp_min.exe
380 dist/yt-dlp_win.zip
381 compression-level: 0
382
383 windows32:
384 needs: process
385 if: inputs.windows32
386 runs-on: windows-latest
387
388 steps:
389 - uses: actions/checkout@v4
390 - uses: actions/setup-python@v5
391 with:
392 python-version: "3.8"
393 architecture: "x86"
394 - name: Install Requirements
395 run: |
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"
399
400 - name: Prepare
401 run: |
402 python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
403 python devscripts/make_lazy_extractors.py
404 - name: Build
405 run: |
406 python -m bundle.pyinstaller
407
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
421 - name: Upload artifacts
422 uses: actions/upload-artifact@v4
423 with:
424 name: build-${{ github.job }}
425 path: |
426 dist/yt-dlp_x86.exe
427 compression-level: 0
428
429 meta_files:
430 if: inputs.meta_files && always() && !cancelled()
431 needs:
432 - process
433 - unix
434 - linux_arm
435 - macos
436 - macos_legacy
437 - windows
438 - windows32
439 runs-on: ubuntu-latest
440 steps:
441 - uses: actions/download-artifact@v4
442 with:
443 path: artifact
444 pattern: build-*
445 merge-multiple: true
446
447 - name: Make SHA2-SUMS files
448 run: |
449 cd ./artifact/
450 sha256sum * > ../SHA2-256SUMS
451 sha512sum * > ../SHA2-512SUMS
452
453 - name: Make Update spec
454 run: |
455 cat >> _update_spec << EOF
456 # This file is used for regulating self-update
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)
467 EOF
468
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
479 - name: Upload artifacts
480 uses: actions/upload-artifact@v4
481 with:
482 name: build-${{ github.job }}
483 path: |
484 _update_spec
485 SHA*SUMS*
486 compression-level: 0