]> jfr.im git - yt-dlp.git/blob - .github/workflows/publish.yml
[devscripts] `make_changelog`: Various improvements
[yt-dlp.git] / .github / workflows / publish.yml
1 name: Publish
2 on:
3 workflow_call:
4 inputs:
5 channel:
6 default: stable
7 required: true
8 type: string
9 version:
10 required: true
11 type: string
12 target_commitish:
13 required: true
14 type: string
15 prerelease:
16 default: false
17 required: true
18 type: boolean
19 secrets:
20 ARCHIVE_REPO_TOKEN:
21 required: false
22
23 permissions:
24 contents: write
25
26 jobs:
27 publish:
28 runs-on: ubuntu-latest
29
30 steps:
31 - uses: actions/checkout@v3
32 with:
33 fetch-depth: 0
34 - uses: actions/download-artifact@v3
35 - uses: actions/setup-python@v4
36 with:
37 python-version: "3.10"
38
39 - name: Generate release notes
40 run: |
41 printf '%s' \
42 '[![Installation](https://img.shields.io/badge/-Which%20file%20should%20I%20download%3F-white.svg?style=for-the-badge)]' \
43 '(https://github.com/yt-dlp/yt-dlp#installation "Installation instructions") ' \
44 '[![Documentation](https://img.shields.io/badge/-Docs-brightgreen.svg?style=for-the-badge&logo=GitBook&labelColor=555555)]' \
45 '(https://github.com/yt-dlp/yt-dlp/tree/2023.03.04#readme "Documentation") ' \
46 '[![Donate](https://img.shields.io/badge/_-Donate-red.svg?logo=githubsponsors&labelColor=555555&style=for-the-badge)]' \
47 '(https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators "Donate") ' \
48 '[![Discord](https://img.shields.io/discord/807245652072857610?color=blue&labelColor=555555&label=&logo=discord&style=for-the-badge)]' \
49 '(https://discord.gg/H5MNcFW63r "Discord") ' \
50 ${{ inputs.channel != 'nightly' && '"[![Nightly](https://img.shields.io/badge/Get%20nightly%20builds-purple.svg?style=for-the-badge)]" \
51 "(https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/latest \"Nightly builds\")"' || '' }} \
52 > ./RELEASE_NOTES
53 printf '\n\n' >> ./RELEASE_NOTES
54 cat >> ./RELEASE_NOTES << EOF
55 #### A description of the various files are in the [README](https://github.com/yt-dlp/yt-dlp#release-files)
56 ---
57 $(python ./devscripts/make_changelog.py -vv --collapsible)
58 EOF
59 printf '%s\n\n' '**This is an automated nightly pre-release build**' >> ./NIGHTLY_NOTES
60 cat ./RELEASE_NOTES >> ./NIGHTLY_NOTES
61 printf '%s\n\n' 'Generated from: https://github.com/${{ github.repository }}/commit/${{ inputs.target_commitish }}' >> ./ARCHIVE_NOTES
62 cat ./RELEASE_NOTES >> ./ARCHIVE_NOTES
63
64 - name: Archive nightly release
65 env:
66 GH_TOKEN: ${{ secrets.ARCHIVE_REPO_TOKEN }}
67 GH_REPO: ${{ vars.ARCHIVE_REPO }}
68 if: |
69 inputs.channel == 'nightly' && env.GH_TOKEN != '' && env.GH_REPO != ''
70 run: |
71 gh release create \
72 --notes-file ARCHIVE_NOTES \
73 --title "yt-dlp nightly ${{ inputs.version }}" \
74 ${{ inputs.version }} \
75 artifact/*
76
77 - name: Prune old nightly release
78 if: inputs.channel == 'nightly' && !vars.ARCHIVE_REPO
79 env:
80 GH_TOKEN: ${{ github.token }}
81 run: |
82 gh release delete --yes --cleanup-tag "nightly" || true
83 git tag --delete "nightly" || true
84 sleep 5 # Enough time to cover deletion race condition
85
86 - name: Publish release${{ inputs.channel == 'nightly' && ' (nightly)' || '' }}
87 env:
88 GH_TOKEN: ${{ github.token }}
89 if: (inputs.channel == 'nightly' && !vars.ARCHIVE_REPO) || inputs.channel != 'nightly'
90 run: |
91 gh release create \
92 --notes-file ${{ inputs.channel == 'nightly' && 'NIGHTLY_NOTES' || 'RELEASE_NOTES' }} \
93 --target ${{ inputs.target_commitish }} \
94 --title "yt-dlp ${{ inputs.channel == 'nightly' && 'nightly ' || '' }}${{ inputs.version }}" \
95 ${{ inputs.prerelease && '--prerelease' || '' }} \
96 ${{ inputs.channel == 'nightly' && '"nightly"' || inputs.version }} \
97 artifact/*