25 SOURCE of this release's updates:
26 channel, repo, tag, or channel/repo@tag
27 (default: <current_repo>)
33 TARGET to publish this release to:
34 channel, tag, or channel@tag
35 (default: <source> if writable else <current_repo>[@source_tag])
41 VERSION: yyyy.mm.dd[.rev] or rev
42 (default: auto-generated)
47 description: Pre-release
58 runs-on: ubuntu-latest
60 channel: ${{ steps.setup_variables.outputs.channel }}
61 version: ${{ steps.setup_variables.outputs.version }}
62 target_repo: ${{ steps.setup_variables.outputs.target_repo }}
63 target_repo_token: ${{ steps.setup_variables.outputs.target_repo_token }}
64 target_tag: ${{ steps.setup_variables.outputs.target_tag }}
65 pypi_project: ${{ steps.setup_variables.outputs.pypi_project }}
66 pypi_suffix: ${{ steps.setup_variables.outputs.pypi_suffix }}
67 head_sha: ${{ steps.get_target.outputs.head_sha }}
70 - uses: actions/checkout@v4
74 - uses: actions/setup-python@v5
76 python-version: "3.10"
78 - name: Process inputs
83 prerelease=${{ inputs.prerelease }}
84 source=${{ inputs.source }}
85 target=${{ inputs.target }}
86 version=${{ inputs.version }}
89 IFS='@' read -r source_repo source_tag <<<"${{ inputs.source }}"
90 IFS='@' read -r target_repo target_tag <<<"${{ inputs.target }}"
91 cat << EOF >> "$GITHUB_OUTPUT"
92 source_repo=${source_repo}
93 source_tag=${source_tag}
94 target_repo=${target_repo}
95 target_tag=${target_tag}
98 - name: Setup variables
101 source_repo: ${{ steps.process_inputs.outputs.source_repo }}
102 source_tag: ${{ steps.process_inputs.outputs.source_tag }}
103 target_repo: ${{ steps.process_inputs.outputs.target_repo }}
104 target_tag: ${{ steps.process_inputs.outputs.target_tag }}
106 # unholy bash monstrosity (sincere apologies)
108 if ${{ !secrets.ARCHIVE_REPO_TOKEN }}; then
109 echo "::error::Repository access secret ${target_repo_token^^} not found"
112 target_repo_token=ARCHIVE_REPO_TOKEN
117 [[ "${source_repo}" == 'stable' ]] && source_repo='yt-dlp/yt-dlp'
118 if [[ -z "${source_repo}" ]]; then
119 source_repo='${{ github.repository }}'
120 elif [[ '${{ vars[format('{0}_archive_repo', env.source_repo)] }}' ]]; then
122 source_channel='${{ vars[format('{0}_archive_repo', env.source_repo)] }}'
123 elif [[ -z "${source_tag}" && "${source_repo}" != */* ]]; then
124 source_tag="${source_repo}"
125 source_repo='${{ github.repository }}'
127 resolved_source="${source_repo}"
128 if [[ "${source_tag}" ]]; then
129 resolved_source="${resolved_source}@${source_tag}"
130 elif [[ "${source_repo}" == 'yt-dlp/yt-dlp' ]]; then
131 resolved_source='stable'
134 revision="${{ (inputs.prerelease || !vars.PUSH_VERSION_COMMIT) && '$(date -u +"%H%M%S")' || '' }}"
136 python devscripts/update-version.py \
137 -c "${resolved_source}" -r "${{ github.repository }}" ${{ inputs.version || '$revision' }} | \
138 grep -Po "version=\K\d+\.\d+\.\d+(\.\d+)?")"
140 if [[ "${target_repo}" ]]; then
141 if [[ -z "${target_tag}" ]]; then
142 if [[ '${{ vars[format('{0}_archive_repo', env.target_repo)] }}' ]]; then
143 target_tag="${source_tag:-${version}}"
145 target_tag="${target_repo}"
146 target_repo='${{ github.repository }}'
149 if [[ "${target_repo}" != '${{ github.repository}}' ]]; then
150 target_repo='${{ vars[format('{0}_archive_repo', env.target_repo)] }}'
151 target_repo_token='${{ env.target_repo }}_archive_repo_token'
152 ${{ !!secrets[format('{0}_archive_repo_token', env.target_repo)] }} || fallback_token
153 pypi_project='${{ vars[format('{0}_pypi_project', env.target_repo)] }}'
154 pypi_suffix='${{ vars[format('{0}_pypi_suffix', env.target_repo)] }}'
157 target_tag="${source_tag:-${version}}"
158 if ((source_is_channel)); then
159 target_repo="${source_channel}"
160 target_repo_token='${{ env.source_repo }}_archive_repo_token'
161 ${{ !!secrets[format('{0}_archive_repo_token', env.source_repo)] }} || fallback_token
162 pypi_project='${{ vars[format('{0}_pypi_project', env.source_repo)] }}'
163 pypi_suffix='${{ vars[format('{0}_pypi_suffix', env.source_repo)] }}'
165 target_repo='${{ github.repository }}'
169 if [[ "${target_repo}" == '${{ github.repository }}' ]] && ${{ !inputs.prerelease }}; then
170 pypi_project='${{ vars.PYPI_PROJECT }}'
173 echo "::group::Output variables"
174 cat << EOF | tee -a "$GITHUB_OUTPUT"
175 channel=${resolved_source}
177 target_repo=${target_repo}
178 target_repo_token=${target_repo_token}
179 target_tag=${target_tag}
180 pypi_project=${pypi_project}
181 pypi_suffix=${pypi_suffix}
185 - name: Update documentation
187 version: ${{ steps.setup_variables.outputs.version }}
188 target_repo: ${{ steps.setup_variables.outputs.target_repo }}
190 !inputs.prerelease && env.target_repo == github.repository
192 python devscripts/update_changelog.py -vv
195 - name: Push to release
198 version: ${{ steps.setup_variables.outputs.version }}
199 target_repo: ${{ steps.setup_variables.outputs.target_repo }}
201 !inputs.prerelease && env.target_repo == github.repository
203 git config --global user.name "github-actions[bot]"
204 git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
206 git commit -m "Release ${{ env.version }}" \
207 -m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all"
208 git push origin --force ${{ github.event.ref }}:release
210 - name: Get target commitish
213 echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
215 - name: Update master
217 target_repo: ${{ steps.setup_variables.outputs.target_repo }}
219 vars.PUSH_VERSION_COMMIT != '' && !inputs.prerelease && env.target_repo == github.repository
220 run: git push origin ${{ github.event.ref }}
224 uses: ./.github/workflows/build.yml
226 version: ${{ needs.prepare.outputs.version }}
227 channel: ${{ needs.prepare.outputs.channel }}
228 origin: ${{ needs.prepare.outputs.target_repo }}
231 packages: write # For package cache
232 actions: write # For cleaning up cache
234 GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
237 needs: [prepare, build]
238 if: ${{ needs.prepare.outputs.pypi_project }}
239 runs-on: ubuntu-latest
241 id-token: write # mandatory for trusted publishing
244 - uses: actions/checkout@v4
247 - uses: actions/setup-python@v5
249 python-version: "3.10"
251 - name: Install Requirements
253 sudo apt -y install pandoc man
254 python devscripts/install_deps.py -o --include build
258 version: ${{ needs.prepare.outputs.version }}
259 suffix: ${{ needs.prepare.outputs.pypi_suffix }}
260 channel: ${{ needs.prepare.outputs.channel }}
261 target_repo: ${{ needs.prepare.outputs.target_repo }}
262 pypi_project: ${{ needs.prepare.outputs.pypi_project }}
264 python devscripts/update-version.py -c "${{ env.channel }}" -r "${{ env.target_repo }}" -s "${{ env.suffix }}" "${{ env.version }}"
265 python devscripts/update_changelog.py -vv
266 python devscripts/make_lazy_extractors.py
267 sed -i -E '0,/(name = ")[^"]+(")/s//\1${{ env.pypi_project }}\2/' pyproject.toml
274 'Official repository: <https://github.com/yt-dlp/yt-dlp>' \
275 '**PS**: Some links in this document will not work since this is a copy of the README.md from Github' > ./README.md.new
276 cat ./README.md >> ./README.md.new && mv -f ./README.md.new ./README.md
277 python devscripts/set-variant.py pip -M "You installed yt-dlp with pip or using the wheel from PyPi; Use that to update"
279 python -m build --no-isolation .
281 - name: Publish to PyPI
282 uses: pypa/gh-action-pypi-publish@release/v1
287 needs: [prepare, build]
290 runs-on: ubuntu-latest
293 - uses: actions/checkout@v4
296 - uses: actions/download-artifact@v4
301 - uses: actions/setup-python@v5
303 python-version: "3.10"
305 - name: Generate release notes
307 head_sha: ${{ needs.prepare.outputs.head_sha }}
308 target_repo: ${{ needs.prepare.outputs.target_repo }}
309 target_tag: ${{ needs.prepare.outputs.target_tag }}
312 '[![Installation](https://img.shields.io/badge/-Which%20file%20to%20download%3F-white.svg?style=for-the-badge)]' \
313 '(https://github.com/${{ github.repository }}#installation "Installation instructions") ' \
314 '[![Discord](https://img.shields.io/discord/807245652072857610?color=blue&labelColor=555555&label=&logo=discord&style=for-the-badge)]' \
315 '(https://discord.gg/H5MNcFW63r "Discord") ' \
316 '[![Donate](https://img.shields.io/badge/_-Donate-red.svg?logo=githubsponsors&labelColor=555555&style=for-the-badge)]' \
317 '(https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators "Donate") ' \
318 '[![Documentation](https://img.shields.io/badge/-Docs-brightgreen.svg?style=for-the-badge&logo=GitBook&labelColor=555555)]' \
319 '(https://github.com/${{ github.repository }}' \
320 '${{ env.target_repo == github.repository && format('/tree/{0}', env.target_tag) || '' }}#readme "Documentation") ' \
321 ${{ env.target_repo == 'yt-dlp/yt-dlp' && '\
322 "[![Nightly](https://img.shields.io/badge/Nightly%20builds-purple.svg?style=for-the-badge)]" \
323 "(https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/latest \"Nightly builds\") " \
324 "[![Master](https://img.shields.io/badge/Master%20builds-lightblue.svg?style=for-the-badge)]" \
325 "(https://github.com/yt-dlp/yt-dlp-master-builds/releases/latest \"Master builds\")"' || '' }} > ./RELEASE_NOTES
326 printf '\n\n' >> ./RELEASE_NOTES
327 cat >> ./RELEASE_NOTES << EOF
328 #### A description of the various files is in the [README](https://github.com/${{ github.repository }}#release-files)
330 $(python ./devscripts/make_changelog.py -vv --collapsible)
332 printf '%s\n\n' '**This is a pre-release build**' >> ./PRERELEASE_NOTES
333 cat ./RELEASE_NOTES >> ./PRERELEASE_NOTES
334 printf '%s\n\n' 'Generated from: https://github.com/${{ github.repository }}/commit/${{ env.head_sha }}' >> ./ARCHIVE_NOTES
335 cat ./RELEASE_NOTES >> ./ARCHIVE_NOTES
337 - name: Publish to archive repo
339 GH_TOKEN: ${{ secrets[needs.prepare.outputs.target_repo_token] }}
340 GH_REPO: ${{ needs.prepare.outputs.target_repo }}
341 version: ${{ needs.prepare.outputs.version }}
342 channel: ${{ needs.prepare.outputs.channel }}
344 inputs.prerelease && env.GH_TOKEN != '' && env.GH_REPO != '' && env.GH_REPO != github.repository
346 title="${{ startswith(env.GH_REPO, 'yt-dlp/') && 'yt-dlp ' || '' }}${{ env.channel }}"
348 --notes-file ARCHIVE_NOTES \
349 --title "${title} ${{ env.version }}" \
353 - name: Prune old release
355 GH_TOKEN: ${{ github.token }}
356 version: ${{ needs.prepare.outputs.version }}
357 target_repo: ${{ needs.prepare.outputs.target_repo }}
358 target_tag: ${{ needs.prepare.outputs.target_tag }}
360 env.target_repo == github.repository && env.target_tag != env.version
362 gh release delete --yes --cleanup-tag "${{ env.target_tag }}" || true
363 git tag --delete "${{ env.target_tag }}" || true
364 sleep 5 # Enough time to cover deletion race condition
366 - name: Publish release
368 GH_TOKEN: ${{ github.token }}
369 version: ${{ needs.prepare.outputs.version }}
370 target_repo: ${{ needs.prepare.outputs.target_repo }}
371 target_tag: ${{ needs.prepare.outputs.target_tag }}
372 head_sha: ${{ needs.prepare.outputs.head_sha }}
374 env.target_repo == github.repository
376 title="${{ github.repository == 'yt-dlp/yt-dlp' && 'yt-dlp ' || '' }}"
377 title+="${{ env.target_tag != env.version && format('{0} ', env.target_tag) || '' }}"
379 --notes-file ${{ inputs.prerelease && 'PRERELEASE_NOTES' || 'RELEASE_NOTES' }} \
380 --target ${{ env.head_sha }} \
381 --title "${title}${{ env.version }}" \
382 ${{ inputs.prerelease && '--prerelease' || '' }} \
383 ${{ env.target_tag }} \