mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-07-03 04:23:59 +03:00
93 lines
2.7 KiB
YAML
93 lines
2.7 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@v6
|
|
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:
|
|
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
|