]> jfr.im git - yt-dlp.git/blob - .github/workflows/build.yml
[build] Automated builds and nightly releases (#6220)
[yt-dlp.git] / .github / workflows / build.yml
1 name: Build Artifacts
2 on:
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
33
34 workflow_dispatch:
35 inputs:
36 version:
37 description: Version tag (YYYY.MM.DD[.REV])
38 required: true
39 type: string
40 channel:
41 description: Update channel (stable/nightly)
42 required: true
43 default: stable
44 type: string
45 unix:
46 description: yt-dlp, yt-dlp.tar.gz, yt-dlp_linux, yt-dlp_linux.zip
47 default: true
48 type: boolean
49 linux_arm:
50 description: yt-dlp_linux_aarch64, yt-dlp_linux_armv7l
51 default: true
52 type: boolean
53 macos:
54 description: yt-dlp_macos, yt-dlp_macos.zip
55 default: true
56 type: boolean
57 macos_legacy:
58 description: yt-dlp_macos_legacy
59 default: true
60 type: boolean
61 windows:
62 description: yt-dlp.exe, yt-dlp_min.exe, yt-dlp_win.zip
63 default: true
64 type: boolean
65 windows32:
66 description: yt-dlp_x86.exe
67 default: true
68 type: boolean
69 meta_files:
70 description: SHA2-256SUMS, SHA2-512SUMS, _update_spec
71 default: true
72 type: boolean
73
74 permissions:
75 contents: read
76
77 jobs:
78 unix:
79 if: inputs.unix
80 runs-on: ubuntu-latest
81 steps:
82 - uses: actions/checkout@v3
83 - uses: actions/setup-python@v4
84 with:
85 python-version: "3.10"
86 - uses: conda-incubator/setup-miniconda@v2
87 with:
88 miniforge-variant: Mambaforge
89 use-mamba: true
90 channels: conda-forge
91 auto-update-conda: true
92 activate-environment: ""
93 auto-activate-base: false
94 - name: Install Requirements
95 run: |
96 sudo apt-get -y install zip pandoc man sed
97 python -m pip install -U pip setuptools wheel
98 python -m pip install -U Pyinstaller -r requirements.txt
99 reqs=$(mktemp)
100 echo -e 'python=3.10.*\npyinstaller' >$reqs
101 sed 's/^brotli.*/brotli-python/' <requirements.txt >>$reqs
102 mamba create -n build --file $reqs
103
104 - name: Prepare
105 run: |
106 python devscripts/update-version.py -c ${{ inputs.channel }} ${{ inputs.version }}
107 python devscripts/make_lazy_extractors.py
108 - name: Build Unix platform-independent binary
109 run: |
110 make all tar
111 - name: Build Unix standalone binary
112 shell: bash -l {0}
113 run: |
114 unset LD_LIBRARY_PATH # Harmful; set by setup-python
115 conda activate build
116 python pyinst.py --onedir
117 (cd ./dist/yt-dlp_linux && zip -r ../yt-dlp_linux.zip .)
118 python pyinst.py
119 mv ./dist/yt-dlp_linux ./yt-dlp_linux
120 mv ./dist/yt-dlp_linux.zip ./yt-dlp_linux.zip
121
122 - name: Upload artifacts
123 uses: actions/upload-artifact@v3
124 with:
125 path: |
126 yt-dlp
127 yt-dlp.tar.gz
128 yt-dlp_linux
129 yt-dlp_linux.zip
130
131 linux_arm:
132 if: inputs.linux_arm
133 permissions:
134 contents: read
135 packages: write # for creating cache
136 runs-on: ubuntu-latest
137 strategy:
138 matrix:
139 architecture:
140 - armv7
141 - aarch64
142
143 steps:
144 - uses: actions/checkout@v3
145 with:
146 path: ./repo
147 - name: Virtualized Install, Prepare & Build
148 uses: yt-dlp/run-on-arch-action@v2
149 with:
150 # Ref: https://github.com/uraimo/run-on-arch-action/issues/55
151 env: |
152 GITHUB_WORKFLOW: build
153 githubToken: ${{ github.token }} # To cache image
154 arch: ${{ matrix.architecture }}
155 distro: ubuntu18.04 # Standalone executable should be built on minimum supported OS
156 dockerRunArgs: --volume "${PWD}/repo:/repo"
157 install: | # Installing Python 3.10 from the Deadsnakes repo raises errors
158 apt update
159 apt -y install zlib1g-dev python3.8 python3.8-dev python3.8-distutils python3-pip
160 python3.8 -m pip install -U pip setuptools wheel
161 # Cannot access requirements.txt from the repo directory at this stage
162 python3.8 -m pip install -U Pyinstaller mutagen pycryptodomex websockets brotli certifi
163
164 run: |
165 cd repo
166 python3.8 -m pip install -U Pyinstaller -r requirements.txt # Cached version may be out of date
167 python3.8 devscripts/update-version.py -c ${{ inputs.channel }} ${{ inputs.version }}
168 python3.8 devscripts/make_lazy_extractors.py
169 python3.8 pyinst.py
170
171 - name: Upload artifacts
172 uses: actions/upload-artifact@v3
173 with:
174 path: | # run-on-arch-action designates armv7l as armv7
175 repo/dist/yt-dlp_linux_${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}
176
177 macos:
178 if: inputs.macos
179 runs-on: macos-11
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 -c ${{ inputs.channel }} ${{ inputs.version }}
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 macos_legacy:
207 if: inputs.macos_legacy
208 runs-on: macos-latest
209
210 steps:
211 - uses: actions/checkout@v3
212 - name: Install Python
213 # We need the official Python, because the GA ones only support newer macOS versions
214 env:
215 PYTHON_VERSION: 3.10.5
216 MACOSX_DEPLOYMENT_TARGET: 10.9 # Used up by the Python build tools
217 run: |
218 # Hack to get the latest patch version. Uncomment if needed
219 #brew install python@3.10
220 #export PYTHON_VERSION=$( $(brew --prefix)/opt/python@3.10/bin/python3 --version | cut -d ' ' -f 2 )
221 curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg -o "python.pkg"
222 sudo installer -pkg python.pkg -target /
223 python3 --version
224 - name: Install Requirements
225 run: |
226 brew install coreutils
227 python3 -m pip install -U --user pip Pyinstaller -r requirements.txt
228
229 - name: Prepare
230 run: |
231 python3 devscripts/update-version.py -c ${{ inputs.channel }} ${{ inputs.version }}
232 python3 devscripts/make_lazy_extractors.py
233 - name: Build
234 run: |
235 python3 pyinst.py
236 mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
237
238 - name: Upload artifacts
239 uses: actions/upload-artifact@v3
240 with:
241 path: |
242 dist/yt-dlp_macos_legacy
243
244 windows:
245 if: inputs.windows
246 runs-on: windows-latest
247
248 steps:
249 - uses: actions/checkout@v3
250 - uses: actions/setup-python@v4
251 with: # 3.8 is used for Win7 support
252 python-version: "3.8"
253 - name: Install Requirements
254 run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
255 python -m pip install -U pip setuptools wheel py2exe
256 pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.8.0-py3-none-any.whl" -r requirements.txt
257
258 - name: Prepare
259 run: |
260 python devscripts/update-version.py -c ${{ inputs.channel }} ${{ inputs.version }}
261 python devscripts/make_lazy_extractors.py
262 - name: Build
263 run: |
264 python setup.py py2exe
265 Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
266 python pyinst.py
267 python pyinst.py --onedir
268 Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
269
270 - name: Upload artifacts
271 uses: actions/upload-artifact@v3
272 with:
273 path: |
274 dist/yt-dlp.exe
275 dist/yt-dlp_min.exe
276 dist/yt-dlp_win.zip
277
278 windows32:
279 if: inputs.windows32
280 runs-on: windows-latest
281
282 steps:
283 - uses: actions/checkout@v3
284 - uses: actions/setup-python@v4
285 with: # 3.7 is used for Vista support. See https://github.com/yt-dlp/yt-dlp/issues/390
286 python-version: "3.7"
287 architecture: "x86"
288 - name: Install Requirements
289 run: |
290 python -m pip install -U pip setuptools wheel
291 pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-5.8.0-py3-none-any.whl" -r requirements.txt
292
293 - name: Prepare
294 run: |
295 python devscripts/update-version.py -c ${{ inputs.channel }} ${{ inputs.version }}
296 python devscripts/make_lazy_extractors.py
297 - name: Build
298 run: |
299 python pyinst.py
300
301 - name: Upload artifacts
302 uses: actions/upload-artifact@v3
303 with:
304 path: |
305 dist/yt-dlp_x86.exe
306
307 meta_files:
308 if: inputs.meta_files && always()
309 needs:
310 - unix
311 - linux_arm
312 - macos
313 - macos_legacy
314 - windows
315 - windows32
316 runs-on: ubuntu-latest
317 steps:
318 - uses: actions/download-artifact@v3
319
320 - name: Make SHA2-SUMS files
321 run: |
322 cd ./artifact/
323 sha256sum * > ../SHA2-256SUMS
324 sha512sum * > ../SHA2-512SUMS
325
326 - name: Make Update spec
327 run: |
328 cat >> _update_spec << EOF
329 # This file is used for regulating self-update
330 lock 2022.08.18.36 .+ Python 3.6
331 EOF
332
333 - name: Upload artifacts
334 uses: actions/upload-artifact@v3
335 with:
336 path: |
337 SHA*SUMS*
338 _update_spec