build.yml 11 KB

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