]> jfr.im git - yt-dlp.git/blame - .github/workflows/publish.yml
[devscripts] `make_changelog`: Various improvements
[yt-dlp.git] / .github / workflows / publish.yml
CommitLineData
29cb20bd
SS
1name: Publish
2on:
3 workflow_call:
4 inputs:
c4efa0ae 5 channel:
6 default: stable
7 required: true
8 type: string
29cb20bd
SS
9 version:
10 required: true
11 type: string
12 target_commitish:
13 required: true
14 type: string
c4efa0ae 15 prerelease:
16 default: false
17 required: true
18 type: boolean
29cb20bd
SS
19 secrets:
20 ARCHIVE_REPO_TOKEN:
21 required: false
22
23permissions:
24 contents: write
25
26jobs:
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: |
c4efa0ae 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
29cb20bd
SS
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 ---
23c39a4b 57 $(python ./devscripts/make_changelog.py -vv --collapsible)
29cb20bd 58 EOF
c4efa0ae 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
29cb20bd
SS
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: |
c4efa0ae 69 inputs.channel == 'nightly' && env.GH_TOKEN != '' && env.GH_REPO != ''
29cb20bd
SS
70 run: |
71 gh release create \
72 --notes-file ARCHIVE_NOTES \
08ff6d59 73 --title "yt-dlp nightly ${{ inputs.version }}" \
29cb20bd
SS
74 ${{ inputs.version }} \
75 artifact/*
76
77 - name: Prune old nightly release
c4efa0ae 78 if: inputs.channel == 'nightly' && !vars.ARCHIVE_REPO
29cb20bd
SS
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
c4efa0ae 86 - name: Publish release${{ inputs.channel == 'nightly' && ' (nightly)' || '' }}
29cb20bd
SS
87 env:
88 GH_TOKEN: ${{ github.token }}
c4efa0ae 89 if: (inputs.channel == 'nightly' && !vars.ARCHIVE_REPO) || inputs.channel != 'nightly'
29cb20bd
SS
90 run: |
91 gh release create \
c4efa0ae 92 --notes-file ${{ inputs.channel == 'nightly' && 'NIGHTLY_NOTES' || 'RELEASE_NOTES' }} \
29cb20bd 93 --target ${{ inputs.target_commitish }} \
c4efa0ae 94 --title "yt-dlp ${{ inputs.channel == 'nightly' && 'nightly ' || '' }}${{ inputs.version }}" \
95 ${{ inputs.prerelease && '--prerelease' || '' }} \
96 ${{ inputs.channel == 'nightly' && '"nightly"' || inputs.version }} \
29cb20bd 97 artifact/*