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