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