Refresh yt-dlp #162
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Refresh yt-dlp | |
| on: | |
| schedule: | |
| # Check daily at 06:00 UTC for new yt-dlp versions | |
| - cron: "0 6 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| force_rebuild: | |
| description: "Force rebuild even if versions match" | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: egalitarianmonkey/hometube | |
| BASE_IMAGE: jauderho/yt-dlp:latest | |
| jobs: | |
| check-versions: | |
| name: Compare yt-dlp versions | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should-build: ${{ steps.compare.outputs.should-build }} | |
| reason: ${{ steps.compare.outputs.reason }} | |
| latest-ytdlp: ${{ steps.latest.outputs.version }} | |
| current-ytdlp: ${{ steps.current.outputs.version }} | |
| app-version: ${{ steps.app.outputs.version }} | |
| tags: ${{ steps.tags.outputs.tags }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install crane | |
| run: | | |
| echo "📥 Installing crane..." | |
| curl -sL "https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz" | tar xz | |
| sudo mv crane /usr/local/bin/ | |
| crane version | |
| - name: Get app version | |
| id: app | |
| run: | | |
| version=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "✅ App version: $version" | |
| - name: Get latest yt-dlp version from jauderho/yt-dlp | |
| id: latest | |
| run: | | |
| echo "🔍 Checking latest yt-dlp version from jauderho/yt-dlp..." | |
| # Get version from label using crane (no pull needed) | |
| version=$(crane config ${{ env.BASE_IMAGE }} | jq -r '.config.Labels["org.opencontainers.image.version"] // empty') | |
| if [[ -z "$version" || "$version" == "null" ]]; then | |
| echo "❌ Could not get yt-dlp version from base image" | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "✅ Latest yt-dlp: $version" | |
| - name: Get current yt-dlp version from HomeTube | |
| id: current | |
| run: | | |
| echo "🔍 Checking current yt-dlp version in HomeTube..." | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" | |
| # Check if image exists | |
| if ! crane manifest "$IMAGE" >/dev/null 2>&1; then | |
| echo "📦 No existing HomeTube image" | |
| echo "version=" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| # Get version from io.hometube.ytdlp.version label | |
| version=$(crane config "$IMAGE" | jq -r '.config.Labels["io.hometube.ytdlp.version"] // empty') | |
| if [[ -n "$version" && "$version" != "null" ]]; then | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "✅ Current yt-dlp: $version" | |
| else | |
| echo "⚠️ No yt-dlp version label found" | |
| echo "version=" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Decide if rebuild needed | |
| id: compare | |
| run: | | |
| FORCE="${{ github.event.inputs.force_rebuild }}" | |
| CURRENT="${{ steps.current.outputs.version }}" | |
| LATEST="${{ steps.latest.outputs.version }}" | |
| echo "📊 Version comparison:" | |
| echo " Current: ${CURRENT:-none}" | |
| echo " Latest: $LATEST" | |
| echo " Force: $FORCE" | |
| if [[ "$FORCE" == "true" ]]; then | |
| echo "should-build=true" >> "$GITHUB_OUTPUT" | |
| echo "reason=Force rebuild requested" >> "$GITHUB_OUTPUT" | |
| echo "🔧 Force rebuild" | |
| elif [[ -z "$CURRENT" ]]; then | |
| echo "should-build=true" >> "$GITHUB_OUTPUT" | |
| echo "reason=No existing image" >> "$GITHUB_OUTPUT" | |
| echo "✅ Initial build needed" | |
| elif [[ "$CURRENT" != "$LATEST" ]]; then | |
| echo "should-build=true" >> "$GITHUB_OUTPUT" | |
| echo "reason=yt-dlp update: $CURRENT → $LATEST" >> "$GITHUB_OUTPUT" | |
| echo "✅ Update detected" | |
| else | |
| echo "should-build=false" >> "$GITHUB_OUTPUT" | |
| echo "reason=Versions match ($CURRENT)" >> "$GITHUB_OUTPUT" | |
| echo "⏭️ No update needed" | |
| fi | |
| - name: Generate tags | |
| if: steps.compare.outputs.should-build == 'true' | |
| id: tags | |
| run: | | |
| APP="${{ steps.app.outputs.version }}" | |
| YTDLP="${{ steps.latest.outputs.version }}" | |
| BASE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | |
| TAGS=$(cat <<EOF | |
| ${BASE}:latest | |
| ${BASE}:v${APP} | |
| ${BASE}:yt-dlp-${YTDLP} | |
| ${BASE}:v${APP}-yt-dlp-${YTDLP} | |
| EOF | |
| ) | |
| echo "tags<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$TAGS" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| echo "🏷️ Tags:" | |
| echo "$TAGS" | sed 's/^/ /' | |
| build: | |
| name: Build and push image | |
| needs: check-versions | |
| if: needs.check-versions.outputs.should-build == 'true' | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| uses: ./.github/workflows/build-image.yml | |
| with: | |
| platforms: "linux/amd64,linux/arm64" | |
| push: true | |
| tags: ${{ needs.check-versions.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.version=v${{ needs.check-versions.outputs.app-version }} | |
| io.hometube.app.version=${{ needs.check-versions.outputs.app-version }} | |
| cache-key: "refresh" | |
| summary: | |
| name: Summary | |
| needs: [check-versions, build] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create summary | |
| run: | | |
| cat >> $GITHUB_STEP_SUMMARY << 'EOF' | |
| # 🔄 yt-dlp Version Check | |
| **Status:** ${{ needs.check-versions.outputs.should-build == 'true' && '✅ Built' || '⏭️ Skipped' }} | |
| **Reason:** ${{ needs.check-versions.outputs.reason }} | |
| | Version | Current | Latest | | |
| |---------|---------|--------| | |
| | **App** | v${{ needs.check-versions.outputs.app-version }} | - | | |
| | **yt-dlp** | ${{ needs.check-versions.outputs.current-ytdlp || 'none' }} | ${{ needs.check-versions.outputs.latest-ytdlp }} | | |
| ${{ needs.check-versions.outputs.should-build == 'true' && format('**Image:** `{0}/{1}:latest`', env.REGISTRY, env.IMAGE_NAME) || '' }} | |
| --- | |
| *Powered by crane 🏗️* | |
| EOF |