A feature-rich command-line audio/video downloader
[build] Various build workflow improvements
bashonlyc4efa0aefec8
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex bec0576d1e..d038e693d9 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -41,7 +41,7 @@ on:required: truetype: stringchannel:- description: Update channel (stable/nightly)+ description: Update channel (stable/nightly/...)required: truedefault: stabletype: string@@ -316,7 +316,7 @@ jobs:dist/yt-dlp_x86.exemeta_files:- if: inputs.meta_files && always()+ if: inputs.meta_files && always() && !cancelled()needs:- unix- linux_armdiff --git a/.github/workflows/publish.yml b/.github/workflows/publish.ymlindex 8a1bd9a010..3ca5c69924 100644--- a/.github/workflows/publish.yml+++ b/.github/workflows/publish.yml@@ -2,16 +2,20 @@ name: Publishon:workflow_call:inputs:- nightly:- default: false- required: false- type: boolean+ channel:+ default: stable+ required: true+ type: stringversion:required: truetype: stringtarget_commitish:required: truetype: string+ prerelease:+ default: false+ required: true+ type: booleansecrets:ARCHIVE_REPO_TOKEN:required: false@@ -34,6 +38,19 @@ jobs:- name: Generate release notesrun: |+ printf '%s' \+ '[]' \+ '(https://github.com/yt-dlp/yt-dlp#installation "Installation instructions") ' \+ '[]' \+ '(https://github.com/yt-dlp/yt-dlp/tree/2023.03.04#readme "Documentation") ' \+ '[]' \+ '(https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators "Donate") ' \+ '[]' \+ '(https://discord.gg/H5MNcFW63r "Discord") ' \+ ${{ inputs.channel != 'nightly' && '"[]" \+ "(https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/latest \"Nightly builds\")"' || '' }} \+ > ./RELEASE_NOTES+ printf '\n\n' >> ./RELEASE_NOTEScat >> ./RELEASE_NOTES << EOF#### A description of the various files are in the [README](https://github.com/yt-dlp/yt-dlp#release-files)---@@ -41,9 +58,9 @@ jobs:$(python ./devscripts/make_changelog.py -vv)</details>EOF- echo "**This is an automated nightly pre-release build**" >> ./PRERELEASE_NOTES- cat ./RELEASE_NOTES >> ./PRERELEASE_NOTES- echo "Generated from: https://github.com/${{ github.repository }}/commit/${{ inputs.target_commitish }}" >> ./ARCHIVE_NOTES+ printf '%s\n\n' '**This is an automated nightly pre-release build**' >> ./NIGHTLY_NOTES+ cat ./RELEASE_NOTES >> ./NIGHTLY_NOTES+ printf '%s\n\n' 'Generated from: https://github.com/${{ github.repository }}/commit/${{ inputs.target_commitish }}' >> ./ARCHIVE_NOTEScat ./RELEASE_NOTES >> ./ARCHIVE_NOTES- name: Archive nightly release@@ -51,7 +68,7 @@ jobs:GH_TOKEN: ${{ secrets.ARCHIVE_REPO_TOKEN }}GH_REPO: ${{ vars.ARCHIVE_REPO }}if: |- inputs.nightly && env.GH_TOKEN != '' && env.GH_REPO != ''+ inputs.channel == 'nightly' && env.GH_TOKEN != '' && env.GH_REPO != ''run: |gh release create \--notes-file ARCHIVE_NOTES \@@ -60,7 +77,7 @@ jobs:artifact/*- name: Prune old nightly release- if: inputs.nightly && !vars.ARCHIVE_REPO+ if: inputs.channel == 'nightly' && !vars.ARCHIVE_REPOenv:GH_TOKEN: ${{ github.token }}run: |@@ -68,14 +85,15 @@ jobs:git tag --delete "nightly" || truesleep 5 # Enough time to cover deletion race condition- - name: Publish release${{ inputs.nightly && ' (nightly)' || '' }}+ - name: Publish release${{ inputs.channel == 'nightly' && ' (nightly)' || '' }}env:GH_TOKEN: ${{ github.token }}- if: (inputs.nightly && !vars.ARCHIVE_REPO) || !inputs.nightly+ if: (inputs.channel == 'nightly' && !vars.ARCHIVE_REPO) || inputs.channel != 'nightly'run: |gh release create \- --notes-file ${{ inputs.nightly && 'PRE' || '' }}RELEASE_NOTES \+ --notes-file ${{ inputs.channel == 'nightly' && 'NIGHTLY_NOTES' || 'RELEASE_NOTES' }} \--target ${{ inputs.target_commitish }} \- --title "yt-dlp ${{ inputs.nightly && 'nightly ' || '' }}${{ inputs.version }}" \- ${{ inputs.nightly && '--prerelease "nightly"' || inputs.version }} \+ --title "yt-dlp ${{ inputs.channel == 'nightly' && 'nightly ' || '' }}${{ inputs.version }}" \+ ${{ inputs.prerelease && '--prerelease' || '' }} \+ ${{ inputs.channel == 'nightly' && '"nightly"' || inputs.version }} \artifact/*diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.ymlindex d4f01ab649..543e2e6f78 100644--- a/.github/workflows/release-nightly.yml+++ b/.github/workflows/release-nightly.yml@@ -46,6 +46,7 @@ jobs:permissions:contents: writewith:- nightly: true+ channel: nightly+ prerelease: trueversion: ${{ needs.prepare.outputs.version }}target_commitish: ${{ github.sha }}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex e07fc0c077..ada508be82 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -1,5 +1,22 @@name: Release-on: workflow_dispatch+on:+ workflow_dispatch:+ inputs:+ version:+ description: Version tag (YYYY.MM.DD[.REV])+ required: false+ default: ''+ type: string+ channel:+ description: Update channel (stable/nightly/...)+ required: false+ default: ''+ type: string+ prerelease:+ description: Pre-release+ default: false+ type: boolean+permissions:contents: read@@ -9,8 +26,9 @@ jobs:contents: writeruns-on: ubuntu-latestoutputs:+ channel: ${{ steps.set_channel.outputs.channel }}version: ${{ steps.update_version.outputs.version }}- head_sha: ${{ steps.push_release.outputs.head_sha }}+ head_sha: ${{ steps.get_target.outputs.head_sha }}steps:- uses: actions/checkout@v3@@ -21,10 +39,18 @@ jobs:with:python-version: "3.10"+ - name: Set channel+ id: set_channel+ run: |+ CHANNEL="${{ github.repository == 'yt-dlp/yt-dlp' && 'stable' || github.repository }}"+ echo "channel=${{ inputs.channel || '$CHANNEL' }}" > "$GITHUB_OUTPUT"+- name: Update versionid: update_versionrun: |- python devscripts/update-version.py ${{ vars.PUSH_VERSION_COMMIT == '' && '"$(date -u +"%H%M%S")"' || '' }} | \+ REVISION="${{ vars.PUSH_VERSION_COMMIT == '' && '$(date -u +"%H%M%S")' || '' }}"+ REVISION="${{ inputs.prerelease && '$(date -u +"%H%M%S")' || '$REVISION' }}"+ python devscripts/update-version.py ${{ inputs.version || '$REVISION' }} | \grep -Po "version=\d+\.\d+\.\d+(\.\d+)?" >> "$GITHUB_OUTPUT"- name: Update documentation@@ -39,6 +65,7 @@ jobs:- name: Push to releaseid: push_release+ if: ${{ !inputs.prerelease }}run: |git config --global user.name github-actionsgit config --global user.email [email protected]@@ -46,14 +73,30 @@ jobs:git commit -m "Release ${{ steps.update_version.outputs.version }}" \-m "Created by: ${{ github.event.sender.login }}" -m ":ci skip all :ci run dl"git push origin --force ${{ github.event.ref }}:release++ - name: Get target commitish+ id: get_target+ run: |echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"- name: Update master- if: vars.PUSH_VERSION_COMMIT != ''+ if: vars.PUSH_VERSION_COMMIT != '' && !inputs.prereleaserun: git push origin ${{ github.event.ref }}- publish_pypi_homebrew:+ build:needs: prepare+ uses: ./.github/workflows/build.yml+ with:+ version: ${{ needs.prepare.outputs.version }}+ channel: ${{ needs.prepare.outputs.channel }}+ permissions:+ contents: read+ packages: write # For package cache+ secrets:+ GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}++ publish_pypi_homebrew:+ needs: [prepare, build]runs-on: ubuntu-lateststeps:@@ -77,7 +120,7 @@ jobs:env:TWINE_USERNAME: __token__TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}- if: env.TWINE_PASSWORD != ''+ if: env.TWINE_PASSWORD != '' && !inputs.prereleaserun: |rm -rf dist/*make pypi-files@@ -89,7 +132,7 @@ jobs:env:BREW_TOKEN: ${{ secrets.BREW_TOKEN }}PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}- if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != ''+ if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != '' && !inputs.prereleaseuses: actions/checkout@v3with:repository: yt-dlp/homebrew-taps@@ -100,7 +143,7 @@ jobs:env:BREW_TOKEN: ${{ secrets.BREW_TOKEN }}PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}- if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != ''+ if: env.BREW_TOKEN != '' && env.PYPI_TOKEN != '' && !inputs.prereleaserun: |python devscripts/update-formulae.py taps/Formula/yt-dlp.rb "${{ needs.prepare.outputs.version }}"git -C taps/ config user.name github-actions@@ -108,22 +151,13 @@ jobs:git -C taps/ commit -am 'yt-dlp: ${{ needs.prepare.outputs.version }}'git -C taps/ push- build:- needs: prepare- uses: ./.github/workflows/build.yml- with:- version: ${{ needs.prepare.outputs.version }}- permissions:- contents: read- packages: write # For package cache- secrets:- GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}-publish:needs: [prepare, build]uses: ./.github/workflows/publish.ymlpermissions:contents: writewith:+ channel: ${{ needs.prepare.outputs.channel }}+ prerelease: ${{ inputs.prerelease }}version: ${{ needs.prepare.outputs.version }}target_commitish: ${{ needs.prepare.outputs.head_sha }}diff --git a/devscripts/update-version.py b/devscripts/update-version.pyindex d888be8814..c873d10a5d 100644--- a/devscripts/update-version.py+++ b/devscripts/update-version.py@@ -51,7 +51,7 @@ CHANNEL = {channel!r}if __name__ == '__main__':parser = argparse.ArgumentParser(description='Update the version.py file')parser.add_argument(- '-c', '--channel', choices=['stable', 'nightly'], default='stable',+ '-c', '--channel', default='stable',help='Select update channel (default: %(default)s)')parser.add_argument('-o', '--output', default='yt_dlp/version.py',