1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-03 12:34:00 +03:00
Files
YoutubePlaylistSync/.gitea/workflows/release.yml
T

159 lines
5.9 KiB
YAML

name: Build Release Packages
on:
push:
#branches:
#- main
tags:
- "v*.*.*"
jobs:
windows-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://gitea.com/actions/checkout@v5
- name: Set up Python
uses: https://gitea.com/actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install --upgrade pip
sudo apt update
sudo apt install -y unzip zip curl
- name: Extract tag name
run: |
REF="${GITEA_REF:-$GITHUB_REF}"
TAG="${REF#refs/tags/}"
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Prepare Windows package
run: |
set -e
WORKSPACE_ROOT="${GITEA_WORKSPACE:-$PWD}"
mkdir -p "$WORKSPACE_ROOT/dist/windows"
cp "$WORKSPACE_ROOT/yt-playlist-main.py" "$WORKSPACE_ROOT/dist/windows/"
cp "$WORKSPACE_ROOT/yt-playlist-config.json" "$WORKSPACE_ROOT/dist/windows/"
mkdir -p "$WORKSPACE_ROOT/dist/windows/bin"
# yt-dlp
curl -L -o "$WORKSPACE_ROOT/dist/windows/bin/yt-dlp.exe" https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe
# FFmpeg Windows static
curl -L -o "$WORKSPACE_ROOT/dist/windows/ffmpeg.zip" https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
unzip -q "$WORKSPACE_ROOT/dist/windows/ffmpeg.zip" -d "$WORKSPACE_ROOT/dist/windows/ffmpeg_temp"
mv $(find "$WORKSPACE_ROOT/dist/windows/ffmpeg_temp" -name ffmpeg.exe | head -n 1) "$WORKSPACE_ROOT/dist/windows/bin/ffmpeg.exe"
# aria2c Windows static
curl -L -o "$WORKSPACE_ROOT/dist/windows/aria2c.zip" https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip
unzip "$WORKSPACE_ROOT/dist/windows/aria2c.zip" -d "$WORKSPACE_ROOT/dist/windows/"
mv "$WORKSPACE_ROOT/dist/windows/aria2-1.37.0-win-64bit-build1/aria2c.exe" "$WORKSPACE_ROOT/dist/windows/bin/aria2c.exe"
# Remove temp files before zipping
rm -rf "$WORKSPACE_ROOT/dist/windows/ffmpeg_temp" "$WORKSPACE_ROOT/dist/windows/aria2-1.37.0-win-64bit-build1" "$WORKSPACE_ROOT/dist/windows/ffmpeg.zip" "$WORKSPACE_ROOT/dist/windows/aria2c.zip"
cd "$WORKSPACE_ROOT/dist/windows"
ZIP_NAME="yt-playlist-windows-${TAG}.zip"
zip -r "$WORKSPACE_ROOT/$ZIP_NAME" *
echo "ZIP_PATH=$WORKSPACE_ROOT/$ZIP_NAME" >> $GITHUB_ENV
- name: Upload Windows release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
files: ${{ env.ZIP_PATH }}
tag_name: ${{ env.TAG }}
name: ${{ env.TAG }}
linux-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://gitea.com/actions/checkout@v5
- name: Set up Python
uses: https://gitea.com/actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install --upgrade pip
sudo apt update
sudo apt install -y unzip zip curl wget build-essential \
pkg-config libssl-dev zlib1g-dev
- name: Extract tag name
run: |
REF="${GITEA_REF:-$GITHUB_REF}"
TAG="${REF#refs/tags/}"
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Prepare Linux package
run: |
set -e
WORKSPACE_ROOT="${GITEA_WORKSPACE:-$PWD}"
mkdir -p "$WORKSPACE_ROOT/dist/linux"
cp "$WORKSPACE_ROOT/yt-playlist-main.py" "$WORKSPACE_ROOT/dist/linux/"
cp "$WORKSPACE_ROOT/yt-playlist-config.json" "$WORKSPACE_ROOT/dist/linux/"
mkdir -p "$WORKSPACE_ROOT/dist/linux/bin"
# yt-dlp
curl -L -o "$WORKSPACE_ROOT/dist/linux/bin/yt-dlp" https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux
chmod +x "$WORKSPACE_ROOT/dist/linux/bin/yt-dlp"
# FFmpeg Linux static
curl -L -o "$WORKSPACE_ROOT/dist/linux/ffmpeg.tar.xz" https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
mkdir -p "$WORKSPACE_ROOT/dist/linux/ffmpeg_temp"
tar -xf "$WORKSPACE_ROOT/dist/linux/ffmpeg.tar.xz" -C "$WORKSPACE_ROOT/dist/linux/ffmpeg_temp" --strip-components=1
mv "$WORKSPACE_ROOT/dist/linux/ffmpeg_temp/ffmpeg" "$WORKSPACE_ROOT/dist/linux/bin/ffmpeg"
chmod +x "$WORKSPACE_ROOT/dist/linux/bin/ffmpeg"
# aria2c minimal fully static
mkdir -p "$WORKSPACE_ROOT/dist/linux/aria2c_build"
cd "$WORKSPACE_ROOT"
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 "$WORKSPACE_ROOT/dist/linux/bin/aria2c"
chmod +x "$WORKSPACE_ROOT/dist/linux/bin/aria2c"
# Cleanup
rm -rf "$WORKSPACE_ROOT/dist/linux/ffmpeg_temp" "$WORKSPACE_ROOT/dist/linux/aria2c_build" "$WORKSPACE_ROOT/dist/linux/ffmpeg.tar.xz" "$WORKSPACE_ROOT/aria2-1.37.0" "$WORKSPACE_ROOT/aria2-1.37.0.tar.gz"
# Zip everything
cd "$WORKSPACE_ROOT/dist/linux"
ZIP_NAME="yt-playlist-linux-${TAG}.zip"
zip -r "$WORKSPACE_ROOT/$ZIP_NAME" *
echo "ZIP_PATH=$WORKSPACE_ROOT/$ZIP_NAME" >> $GITHUB_ENV
- name: Upload Linux release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
files: ${{ env.ZIP_PATH }}
tag_name: ${{ env.TAG }}
name: ${{ env.TAG }}