1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-03 04:23:59 +03:00
Files
YoutubePlaylistSync/.github/workflows/update-yt-dlp.yml
T
dependabot[bot] e97c419b47 chore(deps): bump actions/checkout from 6 to 7 (#17)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-20 23:23:48 +03:00

96 lines
3.0 KiB
YAML

name: update yt-dlp
on:
schedule:
- cron: "0 10 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: refresh-yt-dlp-pr
cancel-in-progress: true
jobs:
refresh:
name: Update yt-dlp dependency
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Check and bump yt-dlp
id: detect
shell: bash
run: |
set -euo pipefail
python - <<'PY' >> "$GITHUB_OUTPUT"
from __future__ import annotations
import json
import re
from pathlib import Path
from urllib.request import urlopen
def version_tuple(text: str) -> tuple[int, ...]:
parts = re.findall(r"\d+", text)
return tuple(int(p) for p in parts)
pyproject = Path("pyproject.toml")
text = pyproject.read_text(encoding="utf-8")
dep_match = re.search(r'^\s*"yt-dlp>=(?P<version>[^"]+)"\s*,?\s*$', text, re.MULTILINE)
if not dep_match:
raise SystemExit("Could not find yt-dlp dependency in pyproject.toml")
dep_version = dep_match.group("version")
latest_payload = urlopen("https://pypi.org/pypi/yt-dlp/json", timeout=30)
latest_version = json.load(latest_payload)["info"]["version"]
needs_update = version_tuple(latest_version) > version_tuple(dep_version)
print(f"needs_update={'true' if needs_update else 'false'}")
print(f"latest_yt_dlp={latest_version}")
print(f"current_yt_dlp={dep_version}")
if needs_update:
text = re.sub(
r'(^\s*"yt-dlp>=)[^"]+(")',
rf'\g<1>{latest_version}\2',
text,
flags=re.MULTILINE,
)
pyproject.write_text(text, encoding="utf-8")
PY
- name: Create or update pull request
if: steps.detect.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@v8
with:
# Use a non-GITHUB_TOKEN credential so the resulting PR triggers CI workflows.
# Configure secrets.PR_WORKFLOW_TOKEN with contents:write and pull-requests:write.
token: ${{ secrets.PR_WORKFLOW_TOKEN || github.token }}
branch: chore/refresh-yt-dlp
commit-message: "chore: bump yt-dlp to ${{ steps.detect.outputs.latest_yt_dlp }}"
title: "chore: bump yt-dlp to ${{ steps.detect.outputs.latest_yt_dlp }}"
body: |
Automated yt-dlp dependency refresh.
- Current version: `${{ steps.detect.outputs.current_yt_dlp }}`
- Latest version: `${{ steps.detect.outputs.latest_yt_dlp }}`
labels: deps
delete-branch: false
add-paths: |
pyproject.toml