]> jfr.im git - yt-dlp.git/blob - .github/workflows/build.yml
[build] Make linux binary truly standalone using `conda` (#5423)
[yt-dlp.git] / .github / workflows / build.yml
1 name: Build
2 on: workflow_dispatch
3 permissions:
4 contents: read
5
6 jobs:
7 prepare:
8 permissions:
9 contents: write # for push_release
10 runs-on: ubuntu-latest
11 outputs:
12 version_suffix: ${{ steps.version_suffix.outputs.version_suffix }}
13 ytdlp_version: ${{ steps.bump_version.outputs.ytdlp_version }}
14 head_sha: ${{ steps.push_release.outputs.head_sha }}
15 steps:
16 - uses: actions/checkout@v3
17 with:
18 fetch-depth: 0
19 - uses: actions/setup-python@v4
20 with:
21 python-version: '3.10'
22
23 - name: Set version suffix
24 id: version_suffix
25 env:
26 PUSH_VERSION_COMMIT: ${{ secrets.PUSH_VERSION_COMMIT }}
27 if: "env.PUSH_VERSION_COMMIT == ''"
28 run: echo "version_suffix=$(date -u +"%H%M%S")" >> "$GITHUB_OUTPUT"
29 - name: Bump version
30 id: bump_version
31 run: |
32 python devscripts/update-version.py ${{ steps.version_suffix.outputs.version_suffix }}
33 make issuetemplates
34
35 - name: Push to release
36 id: push_release
37 run: |
38 git config --global user.name github-actions
39 git config --global user.email github-actions@example.com
40 git add -u
41 git commit -m "[version] update" -m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all :ci run dl"
42 git push origin --force ${{ github.event.ref }}:release
43 echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
44 - name: Update master
45 env:
46 PUSH_VERSION_COMMIT: ${{ secrets.PUSH_VERSION_COMMIT }}
47 if: "env.PUSH_VERSION_COMMIT != ''"
48 run: git push origin ${{ github.event.ref }}
49
50
51 build_unix:
52 needs: prepare
53 runs-on: ubuntu-latest
54
55 steps:
56 - uses: actions/checkout@v3
57 - uses: actions/setup-python@v4
58 with:
59 python-version: '3.10'
60 - uses: conda-incubator/setup-miniconda@v2
61 with:
62 miniforge-variant: Mambaforge
63 use-mamba: true
64 channels: conda-forge
65 auto-update-conda: true
66 activate-environment: ''
67 auto-activate-base: false
68 - name: Install Requirements
69 run: |
70 sudo apt-get -y install zip pandoc man sed
71 python -m pip install -U pip setuptools wheel twine
72 python -m pip install -U Pyinstaller -r requirements.txt
73 reqs=$(mktemp)
74 echo -e 'python=3.10.*\npyinstaller' >$reqs
75 sed 's/^brotli.*/brotli-python/' <requirements.txt >>$reqs
76 mamba create -n build --file $reqs
77
78 - name: Prepare
79 run: |
80 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
81 python devscripts/make_lazy_extractors.py
82 - name: Build Unix platform-independent binary
83 run: |
84 make all tar
85 - name: Build Unix standalone binary
86 shell: bash -l {0}
87 run: |
88 unset LD_LIBRARY_PATH # Harmful; set by setup-python
89 conda activate build
90 python pyinst.py --onedir
91 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
92 python pyinst.py
93
94 - name: Upload artifacts
95 uses: actions/upload-artifact@v3
96 with:
97 path: |
98 yt-dlp
99 yt-dlp.tar.gz
100 dist/yt-dlp_linux
101 dist/yt-dlp_linux.zip
102
103 - name: Build and publish on PyPi
104 env:
105 TWINE_USERNAME: __token__
106 TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
107 if: "env.TWINE_PASSWORD != ''"
108 run: |
109 rm -rf dist/*
110 python devscripts/set-variant.py pip -M "You installed yt-dlp with pip or using the wheel from PyPi; Use that to update"
111 python setup.py sdist bdist_wheel
112 twine upload dist/*
113
114 - name: Install SSH private key for Homebrew
115 env:
116 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
117 if: "env.BREW_TOKEN != ''"
118 uses: yt-dlp/ssh-agent@v0.5.3
119 with:
120 ssh-private-key: ${{ env.BREW_TOKEN }}
121 - name: Update Homebrew Formulae
122 env:
123 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
124 if: "env.BREW_TOKEN != ''"
125 run: |
126 git clone git@github.com:yt-dlp/homebrew-taps taps/
127 python devscripts/update-formulae.py taps/Formula/yt-dlp.rb "${{ needs.prepare.outputs.ytdlp_version }}"
128 git -C taps/ config user.name github-actions
129 git -C taps/ config user.email github-actions@example.com
130 git -C taps/ commit -am 'yt-dlp: ${{ needs.prepare.outputs.ytdlp_version }}'
131 git -C taps/ push
132
133
134 build_linux_arm:
135 permissions:
136 packages: write # for Creating cache
137 runs-on: ubuntu-latest
138 needs: prepare
139 strategy:
140 matrix:
141 architecture:
142 - armv7
143 - aarch64
144
145 steps:
146 - uses: actions/checkout@v3
147 with:
148 path: ./repo
149 - name: Virtualized Install, Prepare & Build
150 uses: yt-dlp/run-on-arch-action@v2
151 with:
152 githubToken: ${{ github.token }} # To cache image
153 arch: ${{ matrix.architecture }}
154 distro: ubuntu18.04 # Standalone executable should be built on minimum supported OS
155 dockerRunArgs: --volume "${PWD}/repo:/repo"
156 install: | # Installing Python 3.10 from the Deadsnakes repo raises errors
157 apt update
158 apt -y install zlib1g-dev python3.8 python3.8-dev python3.8-distutils python3-pip
159 python3.8 -m pip install -U pip setuptools wheel
160 # Cannot access requirements.txt from the repo directory at this stage
161 python3.8 -m pip install -U Pyinstaller mutagen pycryptodomex websockets brotli certifi
162
163 run: |
164 cd repo
165 python3.8 -m pip install -U Pyinstaller -r requirements.txt # Cached version may be out of date
166 python3.8 devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
167 python3.8 devscripts/make_lazy_extractors.py
168 python3.8 pyinst.py
169
170 - name: Upload artifacts
171 uses: actions/upload-artifact@v3
172 with:
173 path: | # run-on-arch-action designates armv7l as armv7
174 repo/dist/yt-dlp_linux_${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}
175
176
177 build_macos:
178 runs-on: macos-11
179 needs: prepare
180
181 steps:
182 - uses: actions/checkout@v3
183 # NB: In order to create a universal2 application, the version of python3 in /usr/bin has to be used
184 - name: Install Requirements
185 run: |
186 brew install coreutils
187 /usr/bin/python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
188
189 - name: Prepare
190 run: |
191 /usr/bin/python3 devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
192 /usr/bin/python3 devscripts/make_lazy_extractors.py
193 - name: Build
194 run: |
195 /usr/bin/python3 pyinst.py --target-architecture universal2 --onedir
196 (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
197 /usr/bin/python3 pyinst.py --target-architecture universal2
198
199 - name: Upload artifacts
200 uses: actions/upload-artifact@v3
201 with:
202 path: |
203 dist/yt-dlp_macos
204 dist/yt-dlp_macos.zip
205
206
207 build_macos_legacy:
208 runs-on: macos-latest
209 needs: prepare
210
211 steps:
212 - uses: actions/checkout@v3
213 - name: Install Python
214 # We need the official Python, because the GA ones only support newer macOS versions
215 env:
216 PYTHON_VERSION: 3.10.5
217 MACOSX_DEPLOYMENT_TARGET: 10.9 # Used up by the Python build tools
218 run: |
219 # Hack to get the latest patch version. Uncomment if needed
220 #brew install python@3.10
221 #export PYTHON_VERSION=$( $(brew --prefix)/opt/python@3.10/bin/python3 --version | cut -d ' ' -f 2 )
222 curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg -o "python.pkg"
223 sudo installer -pkg python.pkg -target /
224 python3 --version
225 - name: Install Requirements
226 run: |
227 brew install coreutils
228 python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
229
230 - name: Prepare
231 run: |
232 python3 devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
233 python3 devscripts/make_lazy_extractors.py
234 - name: Build
235 run: |
236 python3 pyinst.py
237 mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
238
239 - name: Upload artifacts
240 uses: actions/upload-artifact@v3
241 with:
242 path: |
243 dist/yt-dlp_macos_legacy
244
245
246 build_windows:
247 runs-on: windows-latest
248 needs: prepare
249
250 steps:
251 - uses: actions/checkout@v3
252 - uses: actions/setup-python@v4
253 with: # 3.8 is used for Win7 support
254 python-version: '3.8'
255 - name: Install Requirements
256 run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
257 python -m pip install -U pip setuptools wheel py2exe
258 pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.3-py3-none-any.whl" -r requirements.txt
259
260 - name: Prepare
261 run: |
262 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
263 python devscripts/make_lazy_extractors.py
264 - name: Build
265 run: |
266 python setup.py py2exe
267 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
268 python pyinst.py
269 python pyinst.py --onedir
270 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
271
272 - name: Upload artifacts
273 uses: actions/upload-artifact@v3
274 with:
275 path: |
276 dist/yt-dlp.exe
277 dist/yt-dlp_min.exe
278 dist/yt-dlp_win.zip
279
280
281 build_windows32:
282 runs-on: windows-latest
283 needs: prepare
284
285 steps:
286 - uses: actions/checkout@v3
287 - uses: actions/setup-python@v4
288 with: # 3.7 is used for Vista support. See https://github.com/yt-dlp/yt-dlp/issues/390
289 python-version: '3.7'
290 architecture: 'x86'
291 - name: Install Requirements
292 run: |
293 python -m pip install -U pip setuptools wheel
294 pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-5.3-py3-none-any.whl" -r requirements.txt
295
296 - name: Prepare
297 run: |
298 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
299 python devscripts/make_lazy_extractors.py
300 - name: Build
301 run: |
302 python pyinst.py
303
304 - name: Upload artifacts
305 uses: actions/upload-artifact@v3
306 with:
307 path: |
308 dist/yt-dlp_x86.exe
309
310
311 publish_release:
312 permissions:
313 contents: write # for action-gh-release
314 runs-on: ubuntu-latest
315 needs: [prepare, build_unix, build_linux_arm, build_windows, build_windows32, build_macos, build_macos_legacy]
316
317 steps:
318 - uses: actions/checkout@v3
319 - uses: actions/download-artifact@v3
320
321 - name: Get Changelog
322 run: |
323 changelog=$(grep -oPz '(?s)(?<=### ${{ needs.prepare.outputs.ytdlp_version }}\n{2}).+?(?=\n{2,3}###)' Changelog.md) || true
324 echo "changelog<<EOF" >> $GITHUB_ENV
325 echo "$changelog" >> $GITHUB_ENV
326 echo "EOF" >> $GITHUB_ENV
327 - name: Make Update spec
328 run: |
329 echo "# This file is used for regulating self-update" >> _update_spec
330 echo "lock 2022.07.18 .+ Python 3.6" >> _update_spec
331 - name: Make SHA2-SUMS files
332 run: |
333 sha256sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-256SUMS
334 sha256sum artifact/yt-dlp.tar.gz | awk '{print $1 " yt-dlp.tar.gz"}' >> SHA2-256SUMS
335 sha256sum artifact/yt-dlp.exe | awk '{print $1 " yt-dlp.exe"}' >> SHA2-256SUMS
336 sha256sum artifact/yt-dlp_win.zip | awk '{print $1 " yt-dlp_win.zip"}' >> SHA2-256SUMS
337 sha256sum artifact/yt-dlp_min.exe | awk '{print $1 " yt-dlp_min.exe"}' >> SHA2-256SUMS
338 sha256sum artifact/yt-dlp_x86.exe | awk '{print $1 " yt-dlp_x86.exe"}' >> SHA2-256SUMS
339 sha256sum artifact/yt-dlp_macos | awk '{print $1 " yt-dlp_macos"}' >> SHA2-256SUMS
340 sha256sum artifact/yt-dlp_macos.zip | awk '{print $1 " yt-dlp_macos.zip"}' >> SHA2-256SUMS
341 sha256sum artifact/yt-dlp_macos_legacy | awk '{print $1 " yt-dlp_macos_legacy"}' >> SHA2-256SUMS
342 sha256sum artifact/yt-dlp_linux_armv7l | awk '{print $1 " yt-dlp_linux_armv7l"}' >> SHA2-256SUMS
343 sha256sum artifact/yt-dlp_linux_aarch64 | awk '{print $1 " yt-dlp_linux_aarch64"}' >> SHA2-256SUMS
344 sha256sum artifact/dist/yt-dlp_linux | awk '{print $1 " yt-dlp_linux"}' >> SHA2-256SUMS
345 sha256sum artifact/dist/yt-dlp_linux.zip | awk '{print $1 " yt-dlp_linux.zip"}' >> SHA2-256SUMS
346 sha512sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-512SUMS
347 sha512sum artifact/yt-dlp.tar.gz | awk '{print $1 " yt-dlp.tar.gz"}' >> SHA2-512SUMS
348 sha512sum artifact/yt-dlp.exe | awk '{print $1 " yt-dlp.exe"}' >> SHA2-512SUMS
349 sha512sum artifact/yt-dlp_win.zip | awk '{print $1 " yt-dlp_win.zip"}' >> SHA2-512SUMS
350 sha512sum artifact/yt-dlp_min.exe | awk '{print $1 " yt-dlp_min.exe"}' >> SHA2-512SUMS
351 sha512sum artifact/yt-dlp_x86.exe | awk '{print $1 " yt-dlp_x86.exe"}' >> SHA2-512SUMS
352 sha512sum artifact/yt-dlp_macos | awk '{print $1 " yt-dlp_macos"}' >> SHA2-512SUMS
353 sha512sum artifact/yt-dlp_macos.zip | awk '{print $1 " yt-dlp_macos.zip"}' >> SHA2-512SUMS
354 sha512sum artifact/yt-dlp_macos_legacy | awk '{print $1 " yt-dlp_macos_legacy"}' >> SHA2-512SUMS
355 sha512sum artifact/yt-dlp_linux_armv7l | awk '{print $1 " yt-dlp_linux_armv7l"}' >> SHA2-512SUMS
356 sha512sum artifact/yt-dlp_linux_aarch64 | awk '{print $1 " yt-dlp_linux_aarch64"}' >> SHA2-512SUMS
357 sha512sum artifact/dist/yt-dlp_linux | awk '{print $1 " yt-dlp_linux"}' >> SHA2-512SUMS
358 sha512sum artifact/dist/yt-dlp_linux.zip | awk '{print $1 " yt-dlp_linux.zip"}' >> SHA2-512SUMS
359
360 - name: Publish Release
361 uses: yt-dlp/action-gh-release@v1
362 with:
363 tag_name: ${{ needs.prepare.outputs.ytdlp_version }}
364 name: yt-dlp ${{ needs.prepare.outputs.ytdlp_version }}
365 target_commitish: ${{ needs.prepare.outputs.head_sha }}
366 body: |
367 #### [A description of the various files]((https://github.com/yt-dlp/yt-dlp#release-files)) are in the README
368
369 ---
370 <details open><summary><h3>Changelog</summary>
371 <p>
372
373 ${{ env.changelog }}
374
375 </p>
376 </details>
377 files: |
378 SHA2-256SUMS
379 SHA2-512SUMS
380 artifact/yt-dlp
381 artifact/yt-dlp.tar.gz
382 artifact/yt-dlp.exe
383 artifact/yt-dlp_win.zip
384 artifact/yt-dlp_min.exe
385 artifact/yt-dlp_x86.exe
386 artifact/yt-dlp_macos
387 artifact/yt-dlp_macos.zip
388 artifact/yt-dlp_macos_legacy
389 artifact/yt-dlp_linux_armv7l
390 artifact/yt-dlp_linux_aarch64
391 artifact/dist/yt-dlp_linux
392 artifact/dist/yt-dlp_linux.zip
393 _update_spec