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