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