]> jfr.im git - yt-dlp.git/blob - .github/workflows/build.yml
[Build] Update pyinstaller
[yt-dlp.git] / .github / workflows / build.yml
1 name: Build
2 on: workflow_dispatch
3
4 jobs:
5 prepare:
6 runs-on: ubuntu-latest
7 outputs:
8 version_suffix: ${{ steps.version_suffix.outputs.version_suffix }}
9 ytdlp_version: ${{ steps.bump_version.outputs.ytdlp_version }}
10 head_sha: ${{ steps.push_release.outputs.head_sha }}
11 steps:
12 - uses: actions/checkout@v3
13 with:
14 fetch-depth: 0
15 - uses: actions/setup-python@v4
16 with:
17 python-version: '3.10'
18
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")
25 - name: Bump version
26 id: bump_version
27 run: |
28 python devscripts/update-version.py ${{ steps.version_suffix.outputs.version_suffix }}
29 make issuetemplates
30
31 - name: Push to release
32 id: push_release
33 run: |
34 git config --global user.name github-actions
35 git config --global user.email github-actions@example.com
36 git add -u
37 git commit -m "[version] update" -m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all :ci run dl"
38 git push origin --force ${{ github.event.ref }}:release
39 echo ::set-output name=head_sha::$(git rev-parse HEAD)
40 - name: Update master
41 env:
42 PUSH_VERSION_COMMIT: ${{ secrets.PUSH_VERSION_COMMIT }}
43 if: "env.PUSH_VERSION_COMMIT != ''"
44 run: git push origin ${{ github.event.ref }}
45
46
47 build_unix:
48 needs: prepare
49 runs-on: ubuntu-18.04 # Standalone executable should be built on minimum supported OS
50
51 steps:
52 - uses: actions/checkout@v3
53 - uses: actions/setup-python@v4
54 with:
55 python-version: '3.10'
56 - name: Install Requirements
57 run: |
58 sudo apt-get -y install zip pandoc man
59 python -m pip install --upgrade pip setuptools wheel twine
60 python -m pip install Pyinstaller -r requirements.txt
61
62 - name: Prepare
63 run: |
64 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
65 python devscripts/make_lazy_extractors.py
66 - name: Build Unix executables
67 run: |
68 make all tar
69 python pyinst.py --onedir
70 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
71 python pyinst.py
72 - name: Get SHA2-SUMS
73 id: get_sha
74 run: |
75
76 - name: Upload artifacts
77 uses: actions/upload-artifact@v3
78 with:
79 path: |
80 yt-dlp
81 yt-dlp.tar.gz
82 dist/yt-dlp_linux
83 dist/yt-dlp_linux.zip
84
85 - name: Build and publish on PyPi
86 env:
87 TWINE_USERNAME: __token__
88 TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
89 if: "env.TWINE_PASSWORD != ''"
90 run: |
91 rm -rf dist/*
92 python devscripts/set-variant.py pip -M "You installed yt-dlp with pip or using the wheel from PyPi; Use that to update"
93 python setup.py sdist bdist_wheel
94 twine upload dist/*
95
96 - name: Install SSH private key for Homebrew
97 env:
98 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
99 if: "env.BREW_TOKEN != ''"
100 uses: yt-dlp/ssh-agent@v0.5.3
101 with:
102 ssh-private-key: ${{ env.BREW_TOKEN }}
103 - name: Update Homebrew Formulae
104 env:
105 BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
106 if: "env.BREW_TOKEN != ''"
107 run: |
108 git clone git@github.com:yt-dlp/homebrew-taps taps/
109 python devscripts/update-formulae.py taps/Formula/yt-dlp.rb "${{ needs.prepare.outputs.ytdlp_version }}"
110 git -C taps/ config user.name github-actions
111 git -C taps/ config user.email github-actions@example.com
112 git -C taps/ commit -am 'yt-dlp: ${{ needs.prepare.outputs.ytdlp_version }}'
113 git -C taps/ push
114
115
116 build_macos:
117 runs-on: macos-11
118 needs: prepare
119
120 steps:
121 - uses: actions/checkout@v3
122 # NB: In order to create a universal2 application, the version of python3 in /usr/bin has to be used
123 - name: Install Requirements
124 run: |
125 brew install coreutils
126 /usr/bin/python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
127
128 - name: Prepare
129 run: |
130 /usr/bin/python3 devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
131 /usr/bin/python3 devscripts/make_lazy_extractors.py
132 - name: Build
133 run: |
134 /usr/bin/python3 pyinst.py --target-architecture universal2 --onedir
135 (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
136 /usr/bin/python3 pyinst.py --target-architecture universal2
137
138 - name: Upload artifacts
139 uses: actions/upload-artifact@v3
140 with:
141 path: |
142 dist/yt-dlp_macos
143 dist/yt-dlp_macos.zip
144
145
146 build_macos_legacy:
147 runs-on: macos-latest
148 needs: prepare
149
150 steps:
151 - uses: actions/checkout@v3
152 - name: Install Python
153 # We need the official Python, because the GA ones only support newer macOS versions
154 env:
155 PYTHON_VERSION: 3.10.5
156 MACOSX_DEPLOYMENT_TARGET: 10.9 # Used up by the Python build tools
157 run: |
158 # Hack to get the latest patch version. Uncomment if needed
159 #brew install python@3.10
160 #export PYTHON_VERSION=$( $(brew --prefix)/opt/python@3.10/bin/python3 --version | cut -d ' ' -f 2 )
161 curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg -o "python.pkg"
162 sudo installer -pkg python.pkg -target /
163 python3 --version
164 - name: Install Requirements
165 run: |
166 brew install coreutils
167 python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
168
169 - name: Prepare
170 run: |
171 python3 devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
172 python3 devscripts/make_lazy_extractors.py
173 - name: Build
174 run: |
175 python3 pyinst.py
176 mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
177
178 - name: Upload artifacts
179 uses: actions/upload-artifact@v3
180 with:
181 path: |
182 dist/yt-dlp_macos_legacy
183
184
185 build_windows:
186 runs-on: windows-latest
187 needs: prepare
188
189 steps:
190 - uses: actions/checkout@v3
191 - uses: actions/setup-python@v4
192 with: # 3.8 is used for Win7 support
193 python-version: '3.8'
194 - name: Install Requirements
195 run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
196 python -m pip install --upgrade pip setuptools wheel py2exe
197 pip install "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.3-py3-none-any.whl" -r requirements.txt
198
199 - name: Prepare
200 run: |
201 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
202 python devscripts/make_lazy_extractors.py
203 - name: Build
204 run: |
205 python setup.py py2exe
206 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
207 python pyinst.py
208 python pyinst.py --onedir
209 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
210
211 - name: Upload artifacts
212 uses: actions/upload-artifact@v3
213 with:
214 path: |
215 dist/yt-dlp.exe
216 dist/yt-dlp_min.exe
217 dist/yt-dlp_win.zip
218
219
220 build_windows32:
221 runs-on: windows-latest
222 needs: prepare
223
224 steps:
225 - uses: actions/checkout@v3
226 - uses: actions/setup-python@v4
227 with: # 3.7 is used for Vista support. See https://github.com/yt-dlp/yt-dlp/issues/390
228 python-version: '3.7'
229 architecture: 'x86'
230 - name: Install Requirements
231 run: |
232 python -m pip install --upgrade pip setuptools wheel
233 pip install "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-5.3-py3-none-any.whl" -r requirements.txt
234
235 - name: Prepare
236 run: |
237 python devscripts/update-version.py ${{ needs.prepare.outputs.version_suffix }}
238 python devscripts/make_lazy_extractors.py
239 - name: Build
240 run: |
241 python pyinst.py
242
243 - name: Upload artifacts
244 uses: actions/upload-artifact@v3
245 with:
246 path: |
247 dist/yt-dlp_x86.exe
248
249
250 publish_release:
251 runs-on: ubuntu-latest
252 needs: [prepare, build_unix, build_windows, build_windows32, build_macos, build_macos_legacy]
253
254 steps:
255 - uses: actions/checkout@v3
256 - uses: actions/download-artifact@v3
257
258 - name: Get Changelog
259 run: |
260 changelog=$(grep -oPz '(?s)(?<=### ${{ needs.prepare.outputs.ytdlp_version }}\n{2}).+?(?=\n{2,3}###)' Changelog.md) || true
261 echo "changelog<<EOF" >> $GITHUB_ENV
262 echo "$changelog" >> $GITHUB_ENV
263 echo "EOF" >> $GITHUB_ENV
264 - name: Make Update spec
265 run: |
266 echo "# This file is used for regulating self-update" >> _update_spec
267 echo "lock 2022.07.18 .+ Python 3.6" >> _update_spec
268 - name: Make SHA2-SUMS files
269 run: |
270 sha256sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-256SUMS
271 sha256sum artifact/yt-dlp.tar.gz | awk '{print $1 " yt-dlp.tar.gz"}' >> SHA2-256SUMS
272 sha256sum artifact/yt-dlp.exe | awk '{print $1 " yt-dlp.exe"}' >> SHA2-256SUMS
273 sha256sum artifact/yt-dlp_win.zip | awk '{print $1 " yt-dlp_win.zip"}' >> SHA2-256SUMS
274 sha256sum artifact/yt-dlp_min.exe | awk '{print $1 " yt-dlp_min.exe"}' >> SHA2-256SUMS
275 sha256sum artifact/yt-dlp_x86.exe | awk '{print $1 " yt-dlp_x86.exe"}' >> SHA2-256SUMS
276 sha256sum artifact/yt-dlp_macos | awk '{print $1 " yt-dlp_macos"}' >> SHA2-256SUMS
277 sha256sum artifact/yt-dlp_macos.zip | awk '{print $1 " yt-dlp_macos.zip"}' >> SHA2-256SUMS
278 sha256sum artifact/yt-dlp_macos_legacy | awk '{print $1 " yt-dlp_macos_legacy"}' >> SHA2-256SUMS
279 sha256sum artifact/dist/yt-dlp_linux | awk '{print $1 " yt-dlp_linux"}' >> SHA2-256SUMS
280 sha256sum artifact/dist/yt-dlp_linux.zip | awk '{print $1 " yt-dlp_linux.zip"}' >> SHA2-256SUMS
281 sha512sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-512SUMS
282 sha512sum artifact/yt-dlp.tar.gz | awk '{print $1 " yt-dlp.tar.gz"}' >> SHA2-512SUMS
283 sha512sum artifact/yt-dlp.exe | awk '{print $1 " yt-dlp.exe"}' >> SHA2-512SUMS
284 sha512sum artifact/yt-dlp_win.zip | awk '{print $1 " yt-dlp_win.zip"}' >> SHA2-512SUMS
285 sha512sum artifact/yt-dlp_min.exe | awk '{print $1 " yt-dlp_min.exe"}' >> SHA2-512SUMS
286 sha512sum artifact/yt-dlp_x86.exe | awk '{print $1 " yt-dlp_x86.exe"}' >> SHA2-512SUMS
287 sha512sum artifact/yt-dlp_macos | awk '{print $1 " yt-dlp_macos"}' >> SHA2-512SUMS
288 sha512sum artifact/yt-dlp_macos.zip | awk '{print $1 " yt-dlp_macos.zip"}' >> SHA2-512SUMS
289 sha512sum artifact/yt-dlp_macos_legacy | awk '{print $1 " yt-dlp_macos_legacy"}' >> SHA2-512SUMS
290 sha512sum artifact/dist/yt-dlp_linux | awk '{print $1 " yt-dlp_linux"}' >> SHA2-512SUMS
291 sha512sum artifact/dist/yt-dlp_linux.zip | awk '{print $1 " yt-dlp_linux.zip"}' >> SHA2-512SUMS
292
293 - name: Publish Release
294 uses: yt-dlp/action-gh-release@v1
295 with:
296 tag_name: ${{ needs.prepare.outputs.ytdlp_version }}
297 name: yt-dlp ${{ needs.prepare.outputs.ytdlp_version }}
298 target_commitish: ${{ needs.prepare.outputs.head_sha }}
299 body: |
300 #### [A description of the various files]((https://github.com/yt-dlp/yt-dlp#release-files)) are in the README
301
302 ---
303 <details open><summary><h3>Changelog</summary>
304 <p>
305
306 ${{ env.changelog }}
307
308 </p>
309 </details>
310 files: |
311 SHA2-256SUMS
312 SHA2-512SUMS
313 artifact/yt-dlp
314 artifact/yt-dlp.tar.gz
315 artifact/yt-dlp.exe
316 artifact/yt-dlp_win.zip
317 artifact/yt-dlp_min.exe
318 artifact/yt-dlp_x86.exe
319 artifact/yt-dlp_macos
320 artifact/yt-dlp_macos.zip
321 artifact/yt-dlp_macos_legacy
322 artifact/dist/yt-dlp_linux
323 artifact/dist/yt-dlp_linux.zip
324 _update_spec