build.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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_static:
  16. default: true
  17. type: boolean
  18. linux_arm:
  19. default: true
  20. type: boolean
  21. macos:
  22. default: true
  23. type: boolean
  24. macos_legacy:
  25. default: true
  26. type: boolean
  27. windows:
  28. default: true
  29. type: boolean
  30. windows32:
  31. default: true
  32. type: boolean
  33. origin:
  34. required: false
  35. default: ''
  36. type: string
  37. secrets:
  38. GPG_SIGNING_KEY:
  39. required: false
  40. workflow_dispatch:
  41. inputs:
  42. version:
  43. description: |
  44. VERSION: yyyy.mm.dd[.rev] or rev
  45. required: true
  46. type: string
  47. channel:
  48. description: |
  49. SOURCE of this build's updates: stable/nightly/master/<repo>
  50. required: true
  51. default: stable
  52. type: string
  53. unix:
  54. description: yt-dlp, yt-dlp.tar.gz
  55. default: true
  56. type: boolean
  57. linux_static:
  58. description: yt-dlp_linux
  59. default: true
  60. type: boolean
  61. linux_arm:
  62. description: yt-dlp_linux_aarch64, yt-dlp_linux_armv7l
  63. default: true
  64. type: boolean
  65. macos:
  66. description: yt-dlp_macos, yt-dlp_macos.zip
  67. default: true
  68. type: boolean
  69. macos_legacy:
  70. description: yt-dlp_macos_legacy
  71. default: true
  72. type: boolean
  73. windows:
  74. description: yt-dlp.exe, yt-dlp_min.exe, yt-dlp_win.zip
  75. default: true
  76. type: boolean
  77. windows32:
  78. description: yt-dlp_x86.exe
  79. default: true
  80. type: boolean
  81. origin:
  82. description: Origin
  83. required: false
  84. default: 'current repo'
  85. type: choice
  86. options:
  87. - 'current repo'
  88. permissions:
  89. contents: read
  90. jobs:
  91. process:
  92. runs-on: ubuntu-latest
  93. outputs:
  94. origin: ${{ steps.process_origin.outputs.origin }}
  95. steps:
  96. - name: Process origin
  97. id: process_origin
  98. run: |
  99. echo "origin=${{ inputs.origin == 'current repo' && github.repository || inputs.origin }}" | tee "$GITHUB_OUTPUT"
  100. unix:
  101. needs: process
  102. if: inputs.unix
  103. runs-on: ubuntu-latest
  104. steps:
  105. - uses: actions/checkout@v4
  106. with:
  107. fetch-depth: 0 # Needed for changelog
  108. - uses: actions/setup-python@v5
  109. with:
  110. python-version: "3.10"
  111. - name: Install Requirements
  112. run: |
  113. sudo apt -y install zip pandoc man sed
  114. - name: Prepare
  115. run: |
  116. python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  117. python devscripts/update_changelog.py -vv
  118. python devscripts/make_lazy_extractors.py
  119. - name: Build Unix platform-independent binary
  120. run: |
  121. make all tar
  122. - name: Verify --update-to
  123. if: vars.UPDATE_TO_VERIFICATION
  124. run: |
  125. chmod +x ./yt-dlp
  126. cp ./yt-dlp ./yt-dlp_downgraded
  127. version="$(./yt-dlp --version)"
  128. ./yt-dlp_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
  129. downgraded_version="$(./yt-dlp_downgraded --version)"
  130. [[ "$version" != "$downgraded_version" ]]
  131. - name: Upload artifacts
  132. uses: actions/upload-artifact@v4
  133. with:
  134. name: build-bin-${{ github.job }}
  135. path: |
  136. yt-dlp
  137. yt-dlp.tar.gz
  138. compression-level: 0
  139. linux_static:
  140. needs: process
  141. if: inputs.linux_static
  142. runs-on: ubuntu-latest
  143. steps:
  144. - uses: actions/checkout@v4
  145. - name: Build static executable
  146. env:
  147. channel: ${{ inputs.channel }}
  148. origin: ${{ needs.process.outputs.origin }}
  149. version: ${{ inputs.version }}
  150. run: |
  151. mkdir ~/build
  152. cd bundle/docker
  153. docker compose up --build static
  154. sudo chown "${USER}:docker" ~/build/yt-dlp_linux
  155. - name: Verify --update-to
  156. if: vars.UPDATE_TO_VERIFICATION
  157. run: |
  158. chmod +x ~/build/yt-dlp_linux
  159. cp ~/build/yt-dlp_linux ~/build/yt-dlp_linux_downgraded
  160. version="$(~/build/yt-dlp_linux --version)"
  161. ~/build/yt-dlp_linux_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
  162. downgraded_version="$(~/build/yt-dlp_linux_downgraded --version)"
  163. [[ "$version" != "$downgraded_version" ]]
  164. - name: Upload artifacts
  165. uses: actions/upload-artifact@v4
  166. with:
  167. name: build-bin-${{ github.job }}
  168. path: |
  169. ~/build/yt-dlp_linux
  170. compression-level: 0
  171. linux_arm:
  172. needs: process
  173. if: inputs.linux_arm
  174. permissions:
  175. contents: read
  176. packages: write # for creating cache
  177. runs-on: ubuntu-latest
  178. strategy:
  179. matrix:
  180. architecture:
  181. - armv7
  182. - aarch64
  183. steps:
  184. - uses: actions/checkout@v4
  185. with:
  186. path: ./repo
  187. - name: Virtualized Install, Prepare & Build
  188. uses: yt-dlp/run-on-arch-action@v2
  189. with:
  190. # Ref: https://github.com/uraimo/run-on-arch-action/issues/55
  191. env: |
  192. GITHUB_WORKFLOW: build
  193. githubToken: ${{ github.token }} # To cache image
  194. arch: ${{ matrix.architecture }}
  195. distro: ubuntu18.04 # Standalone executable should be built on minimum supported OS
  196. dockerRunArgs: --volume "${PWD}/repo:/repo"
  197. install: | # Installing Python 3.10 from the Deadsnakes repo raises errors
  198. apt update
  199. apt -y install zlib1g-dev libffi-dev python3.8 python3.8-dev python3.8-distutils python3-pip
  200. python3.8 -m pip install -U pip setuptools wheel
  201. # Cannot access any files from the repo directory at this stage
  202. python3.8 -m pip install -U Pyinstaller mutagen pycryptodomex websockets brotli certifi secretstorage cffi
  203. run: |
  204. cd repo
  205. python3.8 devscripts/install_deps.py -o --include build
  206. python3.8 devscripts/install_deps.py --include pyinstaller --include secretstorage # Cached version may be out of date
  207. python3.8 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  208. python3.8 devscripts/make_lazy_extractors.py
  209. python3.8 -m bundle.pyinstaller
  210. if ${{ vars.UPDATE_TO_VERIFICATION && 'true' || 'false' }}; then
  211. arch="${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}"
  212. chmod +x ./dist/yt-dlp_linux_${arch}
  213. cp ./dist/yt-dlp_linux_${arch} ./dist/yt-dlp_linux_${arch}_downgraded
  214. version="$(./dist/yt-dlp_linux_${arch} --version)"
  215. ./dist/yt-dlp_linux_${arch}_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
  216. downgraded_version="$(./dist/yt-dlp_linux_${arch}_downgraded --version)"
  217. [[ "$version" != "$downgraded_version" ]]
  218. fi
  219. - name: Upload artifacts
  220. uses: actions/upload-artifact@v4
  221. with:
  222. name: build-bin-linux_${{ matrix.architecture }}
  223. path: | # run-on-arch-action designates armv7l as armv7
  224. repo/dist/yt-dlp_linux_${{ (matrix.architecture == 'armv7' && 'armv7l') || matrix.architecture }}
  225. compression-level: 0
  226. macos:
  227. needs: process
  228. if: inputs.macos
  229. runs-on: macos-11
  230. steps:
  231. - uses: actions/checkout@v4
  232. # NB: Building universal2 does not work with python from actions/setup-python
  233. - name: Install Requirements
  234. run: |
  235. brew install coreutils
  236. python3 devscripts/install_deps.py --user -o --include build
  237. python3 devscripts/install_deps.py --print --include pyinstaller > requirements.txt
  238. # We need to ignore wheels otherwise we break universal2 builds
  239. python3 -m pip install -U --user --no-binary :all: -r requirements.txt
  240. # We need to fuse our own universal2 wheels for curl_cffi
  241. python3 -m pip install -U --user delocate
  242. mkdir curl_cffi_whls curl_cffi_universal2
  243. python3 devscripts/install_deps.py --print -o --include curl-cffi > requirements.txt
  244. for platform in "macosx_11_0_arm64" "macosx_11_0_x86_64"; do
  245. python3 -m pip download \
  246. --only-binary=:all: \
  247. --platform "${platform}" \
  248. --pre -d curl_cffi_whls \
  249. -r requirements.txt
  250. done
  251. python3 -m delocate.cmd.delocate_fuse curl_cffi_whls/curl_cffi*.whl -w curl_cffi_universal2
  252. python3 -m delocate.cmd.delocate_fuse curl_cffi_whls/cffi*.whl -w curl_cffi_universal2
  253. cd curl_cffi_universal2
  254. for wheel in *cffi*.whl; do mv -n -- "${wheel}" "${wheel/x86_64/universal2}"; done
  255. python3 -m pip install -U --user *cffi*.whl
  256. - name: Prepare
  257. run: |
  258. python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  259. python3 devscripts/make_lazy_extractors.py
  260. - name: Build
  261. run: |
  262. python3 -m bundle.pyinstaller --target-architecture universal2 --onedir
  263. (cd ./dist/yt-dlp_macos && zip -r ../yt-dlp_macos.zip .)
  264. python3 -m bundle.pyinstaller --target-architecture universal2
  265. - name: Verify --update-to
  266. if: vars.UPDATE_TO_VERIFICATION
  267. run: |
  268. chmod +x ./dist/yt-dlp_macos
  269. cp ./dist/yt-dlp_macos ./dist/yt-dlp_macos_downgraded
  270. version="$(./dist/yt-dlp_macos --version)"
  271. ./dist/yt-dlp_macos_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
  272. downgraded_version="$(./dist/yt-dlp_macos_downgraded --version)"
  273. [[ "$version" != "$downgraded_version" ]]
  274. - name: Upload artifacts
  275. uses: actions/upload-artifact@v4
  276. with:
  277. name: build-bin-${{ github.job }}
  278. path: |
  279. dist/yt-dlp_macos
  280. dist/yt-dlp_macos.zip
  281. compression-level: 0
  282. macos_legacy:
  283. needs: process
  284. if: inputs.macos_legacy
  285. runs-on: macos-12
  286. steps:
  287. - uses: actions/checkout@v4
  288. - name: Install Python
  289. # We need the official Python, because the GA ones only support newer macOS versions
  290. env:
  291. PYTHON_VERSION: 3.10.5
  292. MACOSX_DEPLOYMENT_TARGET: 10.9 # Used up by the Python build tools
  293. run: |
  294. # Hack to get the latest patch version. Uncomment if needed
  295. #brew install python@3.10
  296. #export PYTHON_VERSION=$( $(brew --prefix)/opt/python@3.10/bin/python3 --version | cut -d ' ' -f 2 )
  297. curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macos11.pkg -o "python.pkg"
  298. sudo installer -pkg python.pkg -target /
  299. python3 --version
  300. - name: Install Requirements
  301. run: |
  302. brew install coreutils
  303. python3 devscripts/install_deps.py --user -o --include build
  304. python3 devscripts/install_deps.py --user --include pyinstaller
  305. - name: Prepare
  306. run: |
  307. python3 devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  308. python3 devscripts/make_lazy_extractors.py
  309. - name: Build
  310. run: |
  311. python3 -m bundle.pyinstaller
  312. mv dist/yt-dlp_macos dist/yt-dlp_macos_legacy
  313. - name: Verify --update-to
  314. if: vars.UPDATE_TO_VERIFICATION
  315. run: |
  316. chmod +x ./dist/yt-dlp_macos_legacy
  317. cp ./dist/yt-dlp_macos_legacy ./dist/yt-dlp_macos_legacy_downgraded
  318. version="$(./dist/yt-dlp_macos_legacy --version)"
  319. ./dist/yt-dlp_macos_legacy_downgraded -v --update-to yt-dlp/yt-dlp@2023.03.04
  320. downgraded_version="$(./dist/yt-dlp_macos_legacy_downgraded --version)"
  321. [[ "$version" != "$downgraded_version" ]]
  322. - name: Upload artifacts
  323. uses: actions/upload-artifact@v4
  324. with:
  325. name: build-bin-${{ github.job }}
  326. path: |
  327. dist/yt-dlp_macos_legacy
  328. compression-level: 0
  329. windows:
  330. needs: process
  331. if: inputs.windows
  332. runs-on: windows-latest
  333. steps:
  334. - uses: actions/checkout@v4
  335. - uses: actions/setup-python@v5
  336. with: # 3.8 is used for Win7 support
  337. python-version: "3.8"
  338. - name: Install Requirements
  339. run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
  340. python devscripts/install_deps.py -o --include build
  341. python devscripts/install_deps.py --include py2exe --include curl-cffi
  342. python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.8.0-py3-none-any.whl"
  343. - name: Prepare
  344. run: |
  345. python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  346. python devscripts/make_lazy_extractors.py
  347. - name: Build
  348. run: |
  349. python -m bundle.py2exe
  350. Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
  351. python -m bundle.pyinstaller
  352. python -m bundle.pyinstaller --onedir
  353. Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
  354. - name: Verify --update-to
  355. if: vars.UPDATE_TO_VERIFICATION
  356. run: |
  357. foreach ($name in @("yt-dlp","yt-dlp_min")) {
  358. Copy-Item "./dist/${name}.exe" "./dist/${name}_downgraded.exe"
  359. $version = & "./dist/${name}.exe" --version
  360. & "./dist/${name}_downgraded.exe" -v --update-to yt-dlp/yt-dlp@2023.03.04
  361. $downgraded_version = & "./dist/${name}_downgraded.exe" --version
  362. if ($version -eq $downgraded_version) {
  363. exit 1
  364. }
  365. }
  366. - name: Upload artifacts
  367. uses: actions/upload-artifact@v4
  368. with:
  369. name: build-bin-${{ github.job }}
  370. path: |
  371. dist/yt-dlp.exe
  372. dist/yt-dlp_min.exe
  373. dist/yt-dlp_win.zip
  374. compression-level: 0
  375. windows32:
  376. needs: process
  377. if: inputs.windows32
  378. runs-on: windows-latest
  379. steps:
  380. - uses: actions/checkout@v4
  381. - uses: actions/setup-python@v5
  382. with:
  383. python-version: "3.8"
  384. architecture: "x86"
  385. - name: Install Requirements
  386. run: |
  387. python devscripts/install_deps.py -o --include build
  388. python devscripts/install_deps.py
  389. python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/i686/pyinstaller-5.8.0-py3-none-any.whl"
  390. - name: Prepare
  391. run: |
  392. python devscripts/update-version.py -c "${{ inputs.channel }}" -r "${{ needs.process.outputs.origin }}" "${{ inputs.version }}"
  393. python devscripts/make_lazy_extractors.py
  394. - name: Build
  395. run: |
  396. python -m bundle.pyinstaller
  397. - name: Verify --update-to
  398. if: vars.UPDATE_TO_VERIFICATION
  399. run: |
  400. foreach ($name in @("yt-dlp_x86")) {
  401. Copy-Item "./dist/${name}.exe" "./dist/${name}_downgraded.exe"
  402. $version = & "./dist/${name}.exe" --version
  403. & "./dist/${name}_downgraded.exe" -v --update-to yt-dlp/yt-dlp@2023.03.04
  404. $downgraded_version = & "./dist/${name}_downgraded.exe" --version
  405. if ($version -eq $downgraded_version) {
  406. exit 1
  407. }
  408. }
  409. - name: Upload artifacts
  410. uses: actions/upload-artifact@v4
  411. with:
  412. name: build-bin-${{ github.job }}
  413. path: |
  414. dist/yt-dlp_x86.exe
  415. compression-level: 0
  416. meta_files:
  417. if: always() && !cancelled()
  418. needs:
  419. - process
  420. - unix
  421. - linux_static
  422. - linux_arm
  423. - macos
  424. - macos_legacy
  425. - windows
  426. - windows32
  427. runs-on: ubuntu-latest
  428. steps:
  429. - uses: actions/download-artifact@v4
  430. with:
  431. path: artifact
  432. pattern: build-bin-*
  433. merge-multiple: true
  434. - name: Make SHA2-SUMS files
  435. run: |
  436. cd ./artifact/
  437. # make sure SHA sums are also printed to stdout
  438. sha256sum * | tee ../SHA2-256SUMS
  439. sha512sum * | tee ../SHA2-512SUMS
  440. - name: Make Update spec
  441. run: |
  442. cat >> _update_spec << EOF
  443. # This file is used for regulating self-update
  444. lock 2022.08.18.36 .+ Python 3\.6
  445. lock 2023.11.16 (?!win_x86_exe).+ Python 3\.7
  446. lock 2023.11.16 win_x86_exe .+ Windows-(?:Vista|2008Server)
  447. lockV2 yt-dlp/yt-dlp 2022.08.18.36 .+ Python 3\.6
  448. lockV2 yt-dlp/yt-dlp 2023.11.16 (?!win_x86_exe).+ Python 3\.7
  449. lockV2 yt-dlp/yt-dlp 2023.11.16 win_x86_exe .+ Windows-(?:Vista|2008Server)
  450. lockV2 yt-dlp/yt-dlp-nightly-builds 2023.11.15.232826 (?!win_x86_exe).+ Python 3\.7
  451. lockV2 yt-dlp/yt-dlp-nightly-builds 2023.11.15.232826 win_x86_exe .+ Windows-(?:Vista|2008Server)
  452. lockV2 yt-dlp/yt-dlp-master-builds 2023.11.15.232812 (?!win_x86_exe).+ Python 3\.7
  453. lockV2 yt-dlp/yt-dlp-master-builds 2023.11.15.232812 win_x86_exe .+ Windows-(?:Vista|2008Server)
  454. EOF
  455. - name: Sign checksum files
  456. env:
  457. GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
  458. if: env.GPG_SIGNING_KEY != ''
  459. run: |
  460. gpg --batch --import <<< "${{ secrets.GPG_SIGNING_KEY }}"
  461. for signfile in ./SHA*SUMS; do
  462. gpg --batch --detach-sign "$signfile"
  463. done
  464. - name: Upload artifacts
  465. uses: actions/upload-artifact@v4
  466. with:
  467. name: build-${{ github.job }}
  468. path: |
  469. _update_spec
  470. SHA*SUMS*
  471. compression-level: 0
  472. overwrite: true