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