1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-04 04:53:58 +03:00
Files
YoutubePlaylistSync/.github/workflows/build_v2.yml
T
dependabot[bot] 93522423ae Bump softprops/action-gh-release from 2 to 3
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2 to 3.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2...v3)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-18 17:12:33 +00:00

263 lines
9.9 KiB
YAML

name: Build Release V2
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g., v0.1.0)"
required: true
default: "v0.1.0"
type: string
permissions:
contents: write
packages: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Run tests
env:
PYTHONPATH: ${{ github.workspace }}
run: pytest
build:
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- platform: windows
os: windows-latest
artifact_name: windows-release
- platform: linux
os: ubuntu-latest
artifact_name: linux-release
steps:
- uses: actions/checkout@v6
- name: Get version
id: version
shell: bash
run: |
TAG="${{ github.event.inputs.tag || inputs.tag }}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
# --- WINDOWS BUILD ---
- name: Build Windows Package
if: matrix.platform == 'windows'
shell: pwsh
run: |
$VERSION = "${{ steps.version.outputs.version }}"
$WORKSPACE = "${{ github.workspace }}"
New-Item -ItemType Directory -Force -Path "$WORKSPACE/dist/windows/bin"
# yt-dlp
Invoke-WebRequest -Uri "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe" -OutFile "$WORKSPACE/dist/windows/bin/yt-dlp.exe"
# FFmpeg
Invoke-WebRequest -Uri "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" -OutFile "$WORKSPACE/dist/windows/ffmpeg.zip"
Expand-Archive "$WORKSPACE/dist/windows/ffmpeg.zip" -DestinationPath "$WORKSPACE/dist/windows/ffmpeg_temp"
$ffmpegExe = Get-ChildItem -Path "$WORKSPACE/dist/windows/ffmpeg_temp" -Filter "ffmpeg.exe" -Recurse | Select-Object -First 1
Move-Item $ffmpegExe.FullName "$WORKSPACE/dist/windows/bin/ffmpeg.exe"
# aria2c (Windows Portable)
Invoke-WebRequest -Uri "https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip" -OutFile "$WORKSPACE/dist/windows/aria2c.zip"
Expand-Archive "$WORKSPACE/dist/windows/aria2c.zip" -DestinationPath "$WORKSPACE/dist/windows/aria2_temp"
Move-Item "$WORKSPACE/dist/windows/aria2_temp/aria2-1.37.0-win-64bit-build1/aria2c.exe" "$WORKSPACE/dist/windows/bin/aria2c.exe"
# Build .exe using PyInstaller
# Use --add-data to include the src folder so internal imports (like 'import cli') work
pip install pyinstaller
pyinstaller --onefile --name "yt-playlist-downloader" --workpath "$WORKSPACE/build" --specpath "$WORKSPACE" --distpath "$WORKSPACE/dist" --add-data "$WORKSPACE/src;src" "$WORKSPACE/yt-playlist-main.py"
Move-Item "$WORKSPACE/dist/yt-playlist-downloader.exe" "$WORKSPACE/dist/windows/yt-playlist-downloader.exe"
# Cleanup & Archive
Remove-Item -Recurse -Force "$WORKSPACE/dist/windows/ffmpeg_temp", "$WORKSPACE/dist/windows/aria2_temp", "$WORKSPACE/dist/windows/*.zip"
Compress-Archive -Path "$WORKSPACE/dist/windows/*" -DestinationPath "$WORKSPACE/yt-playlist-windows-$VERSION.zip"
# --- LINUX BUILD ---
- name: Build Linux Package
if: matrix.platform == 'linux'
run: |
VERSION="${{ steps.version.outputs.version }}"
mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin"
cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/linux/"
cp -r "$GITHUB_WORKSPACE/src" "$GITHUB_WORKSPACE/dist/linux/"
# yt-dlp
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -o "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp"
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp"
# FFmpeg (static)
curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o "$GITHUB_WORKSPACE/ffmpeg.tar.xz"
mkdir -p "$GITHUB_WORKSPACE/ffmpeg_temp"
tar -xf "$GITHUB_WORKSPACE/ffmpeg.tar.xz" -C "$GITHUB_WORKSPACE/ffmpeg_temp" --strip-components=1
mv "$GITHUB_WORKSPACE/ffmpeg_temp/ffmpeg" "$GITHUB_WORKSPACE/dist/linux/bin/"
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg"
- name: Cache aria2c binary (Linux)
if: matrix.platform == 'linux'
id: aria2-cache
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/dist/linux/bin/aria2c
key: aria2c-linux-1.37.0
- name: Build aria2c (Linux)
if: matrix.platform == 'linux' && steps.aria2-cache.outputs.cache-hit != 'true'
run: |
set -e
sudo apt update && sudo apt install -y build-essential pkg-config libssl-dev zlib1g-dev wget
mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin"
cd "$GITHUB_WORKSPACE"
wget https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0.tar.gz
tar -xzf aria2-1.37.0.tar.gz
cd aria2-1.37.0
CFLAGS="-Os -s" LDFLAGS="-static" ./configure \
--enable-static --disable-shared \
--disable-libaria2 --without-ca-bundle \
--without-libnettle --without-libgcrypt \
--without-libssh2 --without-libexpat \
--without-libxml2 --without-libsqlite3 \
--with-openssl
make -j"$(nproc)"
strip src/aria2c
cp src/aria2c "$GITHUB_WORKSPACE/dist/linux/bin/aria2c"
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/aria2c"
cd "$GITHUB_WORKSPACE"
rm -rf aria2-1.37.0 aria2-1.37.0.tar.gz
- name: Archive Linux Package
if: matrix.platform == 'linux'
run: |
VERSION="${{ steps.version.outputs.version }}"
# Archive
cd "$GITHUB_WORKSPACE/dist/linux" && tar -czf "$GITHUB_WORKSPACE/yt-playlist-linux-$VERSION.tar.gz" *
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: |
${{ github.workspace }}/*.zip
${{ github.workspace }}/*.tar.gz
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Get version
id: version
shell: bash
run: |
TAG="${{ github.event.inputs.tag || inputs.tag }}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download Linux Artifact
uses: actions/download-artifact@v8
with:
name: linux-release
path: ${{ github.workspace }}/dist/linux-docker
- name: Prepare Docker build context
run: |
cd "$GITHUB_WORKSPACE/dist/linux-docker"
# Extract Linux artifact which now contains bin/, src/, and yt-playlist-main.py
tar -xzf "$GITHUB_WORKSPACE/dist/linux-docker/yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz"
# Copy Docker-specific files
cp "$GITHUB_WORKSPACE/Dockerfile" .
cp "$GITHUB_WORKSPACE/docker-entrypoint.sh" .
# Ensure config directory is present (not included in Linux zip by default)
if [ ! -d "config" ]; then cp -r "$GITHUB_WORKSPACE/config" . ; fi
# Debug: List context to verify paths match Dockerfile expectations
ls -R
- name: Set docker image names
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "RELEASE_IMAGE=ghcr.io/${GITHUB_ACTOR}/ytpld:${VERSION}" >> $GITHUB_ENV
echo "LATEST_IMAGE=ghcr.io/${GITHUB_ACTOR}/ytpld:latest" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build . -t $RELEASE_IMAGE -t $LATEST_IMAGE
working-directory: ${{ github.workspace }}/dist/linux-docker
- name: Save Docker images
run: |
docker save -o docker-image.tar $RELEASE_IMAGE
docker save -o docker-image-latest.tar $LATEST_IMAGE
working-directory: ${{ github.workspace }}/dist/linux-docker
- name: Upload Docker artifacts
uses: actions/upload-artifact@v7
with:
name: docker-images
path: ${{ github.workspace }}/dist/linux-docker/docker-image*.tar
release:
needs: [build, docker]
runs-on: ubuntu-latest
if: startsWith(github.event.inputs.tag, 'v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: ${{ github.workspace }}/artifacts
- name: Get version
id: version
shell: bash
run: |
TAG="${{ github.event.inputs.tag || inputs.tag }}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker images
run: |
docker load -i "${{ github.workspace }}/artifacts/docker-images/docker-image.tar"
docker push ghcr.io/${GITHUB_ACTOR}/ytpld:${{ steps.version.outputs.version }}
docker load -i "${{ github.workspace }}/artifacts/docker-images/docker-image-latest.tar"
docker push ghcr.io/${GITHUB_ACTOR}/ytpld:latest
- name: Create Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.event.inputs.tag }}
draft: true
files: |
${{ github.workspace }}/artifacts/**/*.zip
${{ github.workspace }}/artifacts/**/*.tar.gz