]> jfr.im git - yt-dlp.git/blame - .github/workflows/build.yml
[version] update
[yt-dlp.git] / .github / workflows / build.yml
CommitLineData
915f2a92 1name: Build
75b725a7 2on: workflow_dispatch
915f2a92
U
3
4jobs:
b5899f4f 5 create_release:
915f2a92 6 runs-on: ubuntu-latest
915f2a92 7 outputs:
75b725a7 8 version_suffix: ${{ steps.version_suffix.outputs.version_suffix }}
7a5c1cfe 9 ytdlp_version: ${{ steps.bump_version.outputs.ytdlp_version }}
915f2a92 10 upload_url: ${{ steps.create_release.outputs.upload_url }}
915f2a92
U
11 steps:
12 - uses: actions/checkout@v2
4c88ff87 13 with:
14 fetch-depth: 0
b5899f4f 15 - uses: actions/setup-python@v2
915f2a92 16 with:
b5899f4f 17 python-version: '3.10'
18
75b725a7 19 - name: Set version suffix
20 id: version_suffix
21 env:
22 PUSH_VERSION_COMMIT: ${{ secrets.PUSH_VERSION_COMMIT }}
23 if: "env.PUSH_VERSION_COMMIT == ''"
24 run: echo ::set-output name=version_suffix::$(date -u +"%H%M%S")
915f2a92
U
25 - name: Bump version
26 id: bump_version
4c88ff87 27 run: |
75b725a7 28 python devscripts/update-version.py ${{ steps.version_suffix.outputs.version_suffix }}
4c88ff87 29 make issuetemplates
b5899f4f 30
75b725a7 31 - name: Push to release
4c88ff87 32 run: |
75b725a7 33 git config --global user.name github-actions
34 git config --global user.email github-actions@example.com
4c88ff87 35 git add -u
b5899f4f 36 git commit -m "[version] update" -m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all :ci run dl"
75b725a7 37 git push origin --force ${{ github.event.ref }}:release
4c88ff87 38 echo ::set-output name=head_sha::$(git rev-parse HEAD)
75b725a7 39 - name: Update master
75b725a7 40 env:
41 PUSH_VERSION_COMMIT: ${{ secrets.PUSH_VERSION_COMMIT }}
42 if: "env.PUSH_VERSION_COMMIT != ''"
43 run: git push origin ${{ github.event.ref }}
4c88ff87 44 - name: Get Changelog
4c88ff87 45 run: |
64fa820c 46 changelog=$(grep -oPz '(?s)(?<=### ${{ steps.bump_version.outputs.ytdlp_version }}\n{2}).+?(?=\n{2,3}###)' Changelog.md) || true
4c88ff87 47 echo "changelog<<EOF" >> $GITHUB_ENV
48 echo "$changelog" >> $GITHUB_ENV
49 echo "EOF" >> $GITHUB_ENV
6e21fdd2 50
915f2a92
U
51 - name: Create Release
52 id: create_release
53 uses: actions/create-release@v1
54 env:
55 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 with:
7a5c1cfe
P
57 tag_name: ${{ steps.bump_version.outputs.ytdlp_version }}
58 release_name: yt-dlp ${{ steps.bump_version.outputs.ytdlp_version }}
a804f6d8 59 commitish: ${{ steps.push_release.outputs.head_sha }}
915f2a92 60 body: |
0930b11f 61 #### [A description of the various files]((https://github.com/yt-dlp/yt-dlp#release-files)) are in the README
49a57e70 62
63 ---
64
0930b11f 65 ### Changelog:
66 ${{ env.changelog }}
915f2a92
U
67 draft: false
68 prerelease: false
b5899f4f 69
70
71 build_unix:
72 needs: create_release
e4afcfde 73 runs-on: ubuntu-18.04 # Standalone executable should be built on minimum supported OS
b5899f4f 74 outputs:
75 sha256_bin: ${{ steps.get_sha.outputs.sha256_bin }}
76 sha512_bin: ${{ steps.get_sha.outputs.sha512_bin }}
77 sha256_tar: ${{ steps.get_sha.outputs.sha256_tar }}
78 sha512_tar: ${{ steps.get_sha.outputs.sha512_tar }}
e4afcfde 79 sha256_linux: ${{ steps.get_sha.outputs.sha256_linux }}
80 sha512_linux: ${{ steps.get_sha.outputs.sha512_linux }}
81 sha256_linux_zip: ${{ steps.get_sha.outputs.sha256_linux_zip }}
82 sha512_linux_zip: ${{ steps.get_sha.outputs.sha512_linux_zip }}
b5899f4f 83
84 steps:
85 - uses: actions/checkout@v2
86 - uses: actions/setup-python@v2
87 with:
88 python-version: '3.10'
89 - name: Install Requirements
90 run: |
91 sudo apt-get -y install zip pandoc man
92 python -m pip install --upgrade pip setuptools wheel twine
93 python -m pip install Pyinstaller -r requirements.txt
94
95 - name: Prepare
96 run: |
97 python devscripts/update-version.py ${{ needs.create_release.outputs.version_suffix }}
98 python devscripts/make_lazy_extractors.py
e4afcfde 99 - name: Build Unix executables
b5899f4f 100 run: |
101 make all tar
e4afcfde 102 python pyinst.py --onedir
103 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
104 python pyinst.py
b5899f4f 105 - name: Get SHA2-SUMS
106 id: get_sha
107 run: |
108 echo "::set-output name=sha256_bin::$(sha256sum yt-dlp | awk '{print $1}')"
109 echo "::set-output name=sha512_bin::$(sha512sum yt-dlp | awk '{print $1}')"
110 echo "::set-output name=sha256_tar::$(sha256sum yt-dlp.tar.gz | awk '{print $1}')"
111 echo "::set-output name=sha512_tar::$(sha512sum yt-dlp.tar.gz | awk '{print $1}')"
e4afcfde 112 echo "::set-output name=sha256_linux::$(sha256sum dist/yt-dlp_linux | awk '{print $1}')"
113 echo "::set-output name=sha512_linux::$(sha512sum dist/yt-dlp_linux | awk '{print $1}')"
114 echo "::set-output name=sha256_linux_zip::$(sha256sum dist/yt-dlp_linux.zip | awk '{print $1}')"
115 echo "::set-output name=sha512_linux_zip::$(sha512sum dist/yt-dlp_linux.zip | awk '{print $1}')"
b5899f4f 116
117 - name: Upload zip binary
915f2a92
U
118 uses: actions/upload-release-asset@v1
119 env:
120 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121 with:
b5899f4f 122 upload_url: ${{ needs.create_release.outputs.upload_url }}
7a5c1cfe
P
123 asset_path: ./yt-dlp
124 asset_name: yt-dlp
915f2a92 125 asset_content_type: application/octet-stream
ed64ce59 126 - name: Upload Source tar
127 uses: actions/upload-release-asset@v1
128 env:
129 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130 with:
b5899f4f 131 upload_url: ${{ needs.create_release.outputs.upload_url }}
ed64ce59 132 asset_path: ./yt-dlp.tar.gz
133 asset_name: yt-dlp.tar.gz
134 asset_content_type: application/gzip
e4afcfde 135 - name: Upload standalone binary
136 uses: actions/upload-release-asset@v1
137 env:
138 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139 with:
140 upload_url: ${{ needs.create_release.outputs.upload_url }}
141 asset_path: ./dist/yt-dlp_linux
142 asset_name: yt-dlp_linux
143 asset_content_type: application/octet-stream
144 - name: Upload onedir binary
145 uses: actions/upload-release-asset@v1
146 env:
147 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148 with:
149 upload_url: ${{ needs.create_release.outputs.upload_url }}
150 asset_path: ./dist/yt-dlp_linux.zip
151 asset_name: yt-dlp_linux.zip
152 asset_content_type: application/zip
915f2a92 153
b5899f4f 154 - name: Build and publish on PyPi
155 env:
156 TWINE_USERNAME: __token__
157 TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
158 if: "env.TWINE_PASSWORD != ''"
159 run: |
160 rm -rf dist/*
161 python setup.py sdist bdist_wheel
162 twine upload dist/*
163
164 - name: Install SSH private key for Homebrew
165 env:
166 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
167 if: "env.BREW_TOKEN != ''"
168 uses: yt-dlp/ssh-agent@v0.5.3
169 with:
170 ssh-private-key: ${{ env.BREW_TOKEN }}
171 - name: Update Homebrew Formulae
172 env:
173 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
174 if: "env.BREW_TOKEN != ''"
175 run: |
176 git clone git@github.com:yt-dlp/homebrew-taps taps/
1ed70fd0 177 python devscripts/update-formulae.py taps/Formula/yt-dlp.rb "${{ needs.create_release.outputs.ytdlp_version }}"
b5899f4f 178 git -C taps/ config user.name github-actions
179 git -C taps/ config user.email github-actions@example.com
1ed70fd0 180 git -C taps/ commit -am 'yt-dlp: ${{ needs.create_release.outputs.ytdlp_version }}'
b5899f4f 181 git -C taps/ push
182
183
0e5927ee
R
184 build_macos:
185 runs-on: macos-11
b5899f4f 186 needs: create_release
0e5927ee 187 outputs:
b5899f4f 188 sha256_macos: ${{ steps.get_sha.outputs.sha256_macos }}
189 sha512_macos: ${{ steps.get_sha.outputs.sha512_macos }}
190 sha256_macos_zip: ${{ steps.get_sha.outputs.sha256_macos_zip }}
191 sha512_macos_zip: ${{ steps.get_sha.outputs.sha512_macos_zip }}
0e5927ee
R
192
193 steps:
194 - uses: actions/checkout@v2
b5899f4f 195 # NB: In order to create a universal2 application, the version of python3 in /usr/bin has to be used
0e5927ee
R
196 - name: Install Requirements
197 run: |
198 brew install coreutils
b5899f4f 199 /usr/bin/python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
200
201 - name: Prepare
202 run: |
203 /usr/bin/python3 devscripts/update-version.py ${{ needs.create_release.outputs.version_suffix }}
204 /usr/bin/python3 devscripts/make_lazy_extractors.py
205 - name: Build
206 run: |
207 /usr/bin/python3 pyinst.py --target-architecture universal2 --onedir
208 (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
209 /usr/bin/python3 pyinst.py --target-architecture universal2
210 - name: Get SHA2-SUMS
211 id: get_sha
212 run: |
213 echo "::set-output name=sha256_macos::$(sha256sum dist/yt-dlp_macos | awk '{print $1}')"
214 echo "::set-output name=sha512_macos::$(sha512sum dist/yt-dlp_macos | awk '{print $1}')"
215 echo "::set-output name=sha256_macos_zip::$(sha256sum dist/yt-dlp_macos.zip | awk '{print $1}')"
216 echo "::set-output name=sha512_macos_zip::$(sha512sum dist/yt-dlp_macos.zip | awk '{print $1}')"
217
218 - name: Upload standalone binary
0e5927ee
R
219 uses: actions/upload-release-asset@v1
220 env:
221 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222 with:
b5899f4f 223 upload_url: ${{ needs.create_release.outputs.upload_url }}
0e5927ee
R
224 asset_path: ./dist/yt-dlp_macos
225 asset_name: yt-dlp_macos
226 asset_content_type: application/octet-stream
b5899f4f 227 - name: Upload onedir binary
0e5927ee
R
228 uses: actions/upload-release-asset@v1
229 env:
230 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
231 with:
b5899f4f 232 upload_url: ${{ needs.create_release.outputs.upload_url }}
0e5927ee
R
233 asset_path: ./dist/yt-dlp_macos.zip
234 asset_name: yt-dlp_macos.zip
235 asset_content_type: application/zip
b5899f4f 236
0e5927ee 237
7e8772bf 238 build_windows:
915f2a92 239 runs-on: windows-latest
b5899f4f 240 needs: create_release
47930b73 241 outputs:
b5899f4f 242 sha256_win: ${{ steps.get_sha.outputs.sha256_win }}
243 sha512_win: ${{ steps.get_sha.outputs.sha512_win }}
244 sha256_py2exe: ${{ steps.get_sha.outputs.sha256_py2exe }}
245 sha512_py2exe: ${{ steps.get_sha.outputs.sha512_py2exe }}
246 sha256_win_zip: ${{ steps.get_sha.outputs.sha256_win_zip }}
247 sha512_win_zip: ${{ steps.get_sha.outputs.sha512_win_zip }}
47930b73 248
915f2a92
U
249 steps:
250 - uses: actions/checkout@v2
b5899f4f 251 - uses: actions/setup-python@v2
252 with: # 3.8 is used for Win7 support
da8fb75d 253 python-version: '3.8'
915f2a92 254 - name: Install Requirements
b5899f4f 255 run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
386cdfdb 256 python -m pip install --upgrade pip setuptools wheel py2exe
b46ccbc6 257 pip install "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-4.10-py3-none-any.whl" -r requirements.txt
b5899f4f 258
259 - name: Prepare
260 run: |
261 python devscripts/update-version.py ${{ needs.create_release.outputs.version_suffix }}
262 python devscripts/make_lazy_extractors.py
263 - name: Build
264 run: |
265 python setup.py py2exe
266 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
267 python pyinst.py
268 python pyinst.py --onedir
269 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
270 - name: Get SHA2-SUMS
271 id: get_sha
272 run: |
273 echo "::set-output name=sha256_py2exe::$((Get-FileHash dist\yt-dlp_min.exe -Algorithm SHA256).Hash.ToLower())"
274 echo "::set-output name=sha512_py2exe::$((Get-FileHash dist\yt-dlp_min.exe -Algorithm SHA512).Hash.ToLower())"
275 echo "::set-output name=sha256_win::$((Get-FileHash dist\yt-dlp.exe -Algorithm SHA256).Hash.ToLower())"
276 echo "::set-output name=sha512_win::$((Get-FileHash dist\yt-dlp.exe -Algorithm SHA512).Hash.ToLower())"
277 echo "::set-output name=sha256_win_zip::$((Get-FileHash dist\yt-dlp_win.zip -Algorithm SHA256).Hash.ToLower())"
278 echo "::set-output name=sha512_win_zip::$((Get-FileHash dist\yt-dlp_win.zip -Algorithm SHA512).Hash.ToLower())"
279
280 - name: Upload py2exe binary
281 uses: actions/upload-release-asset@v1
75b725a7 282 env:
b5899f4f 283 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
284 with:
285 upload_url: ${{ needs.create_release.outputs.upload_url }}
286 asset_path: ./dist/yt-dlp_min.exe
287 asset_name: yt-dlp_min.exe
288 asset_content_type: application/vnd.microsoft.portable-executable
289 - name: Upload standalone binary
915f2a92
U
290 uses: actions/upload-release-asset@v1
291 env:
292 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
293 with:
b5899f4f 294 upload_url: ${{ needs.create_release.outputs.upload_url }}
7a5c1cfe
P
295 asset_path: ./dist/yt-dlp.exe
296 asset_name: yt-dlp.exe
98918847 297 asset_content_type: application/vnd.microsoft.portable-executable
b5899f4f 298 - name: Upload onedir binary
4c88ff87 299 uses: actions/upload-release-asset@v1
300 env:
301 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
302 with:
b5899f4f 303 upload_url: ${{ needs.create_release.outputs.upload_url }}
0e5927ee
R
304 asset_path: ./dist/yt-dlp_win.zip
305 asset_name: yt-dlp_win.zip
4c88ff87 306 asset_content_type: application/zip
b5899f4f 307
386cdfdb 308
915f2a92 309 build_windows32:
915f2a92 310 runs-on: windows-latest
b5899f4f 311 needs: create_release
47930b73 312 outputs:
b5899f4f 313 sha256_win32: ${{ steps.get_sha.outputs.sha256_win32 }}
314 sha512_win32: ${{ steps.get_sha.outputs.sha512_win32 }}
47930b73 315
915f2a92
U
316 steps:
317 - uses: actions/checkout@v2
b5899f4f 318 - uses: actions/setup-python@v2
319 with: # 3.7 is used for Vista support. See https://github.com/yt-dlp/yt-dlp/issues/390
0181adef 320 python-version: '3.7'
915f2a92 321 architecture: 'x86'
0181adef 322 - name: Install Requirements
0e5927ee
R
323 run: |
324 python -m pip install --upgrade pip setuptools wheel
b46ccbc6 325 pip install "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-4.10-py3-none-any.whl" -r requirements.txt
b5899f4f 326
327 - name: Prepare
328 run: |
329 python devscripts/update-version.py ${{ needs.create_release.outputs.version_suffix }}
330 python devscripts/make_lazy_extractors.py
331 - name: Build
332 run: |
333 python pyinst.py
334 - name: Get SHA2-SUMS
335 id: get_sha
336 run: |
337 echo "::set-output name=sha256_win32::$((Get-FileHash dist\yt-dlp_x86.exe -Algorithm SHA256).Hash.ToLower())"
338 echo "::set-output name=sha512_win32::$((Get-FileHash dist\yt-dlp_x86.exe -Algorithm SHA512).Hash.ToLower())"
339
340 - name: Upload standalone binary
915f2a92
U
341 uses: actions/upload-release-asset@v1
342 env:
343 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
344 with:
b5899f4f 345 upload_url: ${{ needs.create_release.outputs.upload_url }}
7a5c1cfe
P
346 asset_path: ./dist/yt-dlp_x86.exe
347 asset_name: yt-dlp_x86.exe
98918847 348 asset_content_type: application/vnd.microsoft.portable-executable
b5899f4f 349
14b17a55 350
351 finish:
352 runs-on: ubuntu-latest
b5899f4f 353 needs: [create_release, build_unix, build_windows, build_windows32, build_macos]
14b17a55 354
355 steps:
b5899f4f 356 - name: Make SHA2-SUMS files
915f2a92 357 run: |
b5899f4f 358 echo "${{ needs.build_unix.outputs.sha256_bin }} yt-dlp" >> SHA2-256SUMS
359 echo "${{ needs.build_unix.outputs.sha256_tar }} yt-dlp.tar.gz" >> SHA2-256SUMS
e4afcfde 360 echo "${{ needs.build_unix.outputs.sha256_linux }} yt-dlp_linux" >> SHA2-256SUMS
361 echo "${{ needs.build_unix.outputs.sha256_linux_zip }} yt-dlp_linux.zip" >> SHA2-256SUMS
b5899f4f 362 echo "${{ needs.build_windows.outputs.sha256_win }} yt-dlp.exe" >> SHA2-256SUMS
363 echo "${{ needs.build_windows.outputs.sha256_py2exe }} yt-dlp_min.exe" >> SHA2-256SUMS
364 echo "${{ needs.build_windows32.outputs.sha256_win32 }} yt-dlp_x86.exe" >> SHA2-256SUMS
365 echo "${{ needs.build_windows.outputs.sha256_win_zip }} yt-dlp_win.zip" >> SHA2-256SUMS
366 echo "${{ needs.build_macos.outputs.sha256_macos }} yt-dlp_macos" >> SHA2-256SUMS
367 echo "${{ needs.build_macos.outputs.sha256_macos_zip }} yt-dlp_macos.zip" >> SHA2-256SUMS
368 echo "${{ needs.build_unix.outputs.sha512_bin }} yt-dlp" >> SHA2-512SUMS
369 echo "${{ needs.build_unix.outputs.sha512_tar }} yt-dlp.tar.gz" >> SHA2-512SUMS
e4afcfde 370 echo "${{ needs.build_unix.outputs.sha512_linux }} yt-dlp_linux" >> SHA2-512SUMS
371 echo "${{ needs.build_unix.outputs.sha512_linux_zip }} yt-dlp_linux.zip" >> SHA2-512SUMS
b5899f4f 372 echo "${{ needs.build_windows.outputs.sha512_win }} yt-dlp.exe" >> SHA2-512SUMS
373 echo "${{ needs.build_windows.outputs.sha512_py2exe }} yt-dlp_min.exe" >> SHA2-512SUMS
374 echo "${{ needs.build_windows32.outputs.sha512_win32 }} yt-dlp_x86.exe" >> SHA2-512SUMS
375 echo "${{ needs.build_windows.outputs.sha512_win_zip }} yt-dlp_win.zip" >> SHA2-512SUMS
376 echo "${{ needs.build_macos.outputs.sha512_macos }} yt-dlp_macos" >> SHA2-512SUMS
377 echo "${{ needs.build_macos.outputs.sha512_macos_zip }} yt-dlp_macos.zip" >> SHA2-512SUMS
378
379 - name: Upload SHA2-256SUMS file
da6403d3
TOH
380 uses: actions/upload-release-asset@v1
381 env:
382 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
383 with:
b5899f4f 384 upload_url: ${{ needs.create_release.outputs.upload_url }}
da6403d3
TOH
385 asset_path: ./SHA2-256SUMS
386 asset_name: SHA2-256SUMS
387 asset_content_type: text/plain
b5899f4f 388 - name: Upload SHA2-512SUMS file
beb982be
NA
389 uses: actions/upload-release-asset@v1
390 env:
391 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
392 with:
b5899f4f 393 upload_url: ${{ needs.create_release.outputs.upload_url }}
beb982be
NA
394 asset_path: ./SHA2-512SUMS
395 asset_name: SHA2-512SUMS
396 asset_content_type: text/plain