release.yml 4.2 KB

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