release.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. name: Release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: Version tag (YYYY.MM.DD[.REV])
  7. required: false
  8. default: ''
  9. type: string
  10. channel:
  11. description: Update channel (stable/nightly/...)
  12. required: false
  13. default: ''
  14. type: string
  15. prerelease:
  16. description: Pre-release
  17. default: false
  18. type: boolean
  19. permissions:
  20. contents: read
  21. jobs:
  22. prepare:
  23. permissions:
  24. contents: write
  25. runs-on: ubuntu-latest
  26. outputs:
  27. channel: ${{ steps.set_channel.outputs.channel }}
  28. version: ${{ steps.update_version.outputs.version }}
  29. head_sha: ${{ steps.get_target.outputs.head_sha }}
  30. steps:
  31. - uses: actions/checkout@v3
  32. with:
  33. fetch-depth: 0
  34. - uses: actions/setup-python@v4
  35. with:
  36. python-version: "3.10"
  37. - name: Set channel
  38. id: set_channel
  39. run: |
  40. CHANNEL="${{ github.repository == 'yt-dlp/yt-dlp' && 'stable' || github.repository }}"
  41. echo "channel=${{ inputs.channel || '$CHANNEL' }}" > "$GITHUB_OUTPUT"
  42. - name: Update version
  43. id: update_version
  44. run: |
  45. REVISION="${{ vars.PUSH_VERSION_COMMIT == '' && '$(date -u +"%H%M%S")' || '' }}"
  46. REVISION="${{ inputs.prerelease && '$(date -u +"%H%M%S")' || '$REVISION' }}"
  47. python devscripts/update-version.py ${{ inputs.version || '$REVISION' }} | \
  48. grep -Po "version=\d+\.\d+\.\d+(\.\d+)?" >> "$GITHUB_OUTPUT"
  49. - name: Update documentation
  50. run: |
  51. make doc
  52. sed '/### /Q' Changelog.md >> ./CHANGELOG
  53. echo '### ${{ steps.update_version.outputs.version }}' >> ./CHANGELOG
  54. python ./devscripts/make_changelog.py -vv -c >> ./CHANGELOG
  55. echo >> ./CHANGELOG
  56. grep -Poz '(?s)### \d+\.\d+\.\d+.+' 'Changelog.md' | head -n -1 >> ./CHANGELOG
  57. cat ./CHANGELOG > Changelog.md
  58. - name: Push to release
  59. id: push_release
  60. if: ${{ !inputs.prerelease }}
  61. run: |
  62. git config --global user.name github-actions
  63. git config --global user.email github-actions@example.com
  64. git add -u
  65. git commit -m "Release ${{ steps.update_version.outputs.version }}" \
  66. -m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all :ci run dl"
  67. git push origin --force ${{ github.event.ref }}:release
  68. - name: Get target commitish
  69. id: get_target
  70. run: |
  71. echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
  72. - name: Update master
  73. if: vars.PUSH_VERSION_COMMIT != '' && !inputs.prerelease
  74. run: git push origin ${{ github.event.ref }}
  75. build:
  76. needs: prepare
  77. uses: ./.github/workflows/build.yml
  78. with:
  79. version: ${{ needs.prepare.outputs.version }}
  80. channel: ${{ needs.prepare.outputs.channel }}
  81. permissions:
  82. contents: read
  83. packages: write # For package cache
  84. secrets:
  85. GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
  86. publish_pypi_homebrew:
  87. needs: [prepare, build]
  88. runs-on: ubuntu-latest
  89. steps:
  90. - uses: actions/checkout@v3
  91. - uses: actions/setup-python@v4
  92. with:
  93. python-version: "3.10"
  94. - name: Install Requirements
  95. run: |
  96. sudo apt-get -y install pandoc man
  97. python -m pip install -U pip setuptools wheel twine
  98. python -m pip install -U -r requirements.txt
  99. - name: Prepare
  100. run: |
  101. python devscripts/update-version.py ${{ needs.prepare.outputs.version }}
  102. python devscripts/make_lazy_extractors.py
  103. - name: Build and publish on PyPI
  104. env:
  105. TWINE_USERNAME: __token__
  106. TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
  107. if: env.TWINE_PASSWORD != '' && !inputs.prerelease
  108. run: |
  109. rm -rf dist/*
  110. make pypi-files
  111. python devscripts/set-variant.py pip -M "You installed yt-dlp with pip or using the wheel from PyPi; Use that to update"
  112. python setup.py sdist bdist_wheel
  113. twine upload dist/*
  114. - name: Checkout Homebrew repository
  115. env:
  116. BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
  117. PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
  118. if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != '' && !inputs.prerelease
  119. uses: actions/checkout@v3
  120. with:
  121. repository: yt-dlp/homebrew-taps
  122. path: taps
  123. ssh-key: ${{ secrets.BREW_TOKEN }}
  124. - name: Update Homebrew Formulae
  125. env:
  126. BREW_TOKEN: ${{ secrets.BREW_TOKEN }}
  127. PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
  128. if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != '' && !inputs.prerelease
  129. run: |
  130. python devscripts/update-formulae.py taps/Formula/yt-dlp.rb "${{ needs.prepare.outputs.version }}"
  131. git -C taps/ config user.name github-actions
  132. git -C taps/ config user.email github-actions@example.com
  133. git -C taps/ commit -am 'yt-dlp: ${{ needs.prepare.outputs.version }}'
  134. git -C taps/ push
  135. publish:
  136. needs: [prepare, build]
  137. uses: ./.github/workflows/publish.yml
  138. permissions:
  139. contents: write
  140. with:
  141. channel: ${{ needs.prepare.outputs.channel }}
  142. prerelease: ${{ inputs.prerelease }}
  143. version: ${{ needs.prepare.outputs.version }}
  144. target_commitish: ${{ needs.prepare.outputs.head_sha }}