1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-04 21:04:01 +03:00

AI: Refactor release workflow: streamline steps, remove unused sections, and enhance artifact handling

This commit is contained in:
2026-03-07 19:21:18 +02:00
parent 3958054f23
commit 4fc1f8999e
+28 -156
View File
@@ -1,9 +1,6 @@
name: Build Release Packages name: Build Release Packages
on: on:
#push:
#tags:
#- "v*.*.*"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
@@ -15,13 +12,10 @@ jobs:
build-windows-package: build-windows-package:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - uses: actions/checkout@v5
uses: actions/checkout@v5
- name: Install dependencies - name: Install dependencies
run: | run: sudo apt update && sudo apt install -y unzip zip curl
sudo apt update
sudo apt install -y unzip zip curl
- name: Get version from tag - name: Get version from tag
id: version id: version
@@ -41,34 +35,28 @@ jobs:
run: | run: |
set -e set -e
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
mkdir -p "$GITHUB_WORKSPACE/dist/windows" mkdir -p "$GITHUB_WORKSPACE/dist/windows/bin"
cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/windows/" cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/windows/"
mkdir -p "$GITHUB_WORKSPACE/dist/windows/bin"
# yt-dlp # yt-dlp
curl -fL \ curl -fL -H "User-Agent: github-actions" \
-H "User-Agent: github-actions" \
-o "$GITHUB_WORKSPACE/dist/windows/bin/yt-dlp.exe" \ -o "$GITHUB_WORKSPACE/dist/windows/bin/yt-dlp.exe" \
https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe
# FFmpeg Windows static # FFmpeg Windows static
curl -fL \ curl -fL -H "User-Agent: github-actions" \
-H "User-Agent: github-actions" \
-o "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" \ -o "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" \
https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
unzip -q "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" -d "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp" unzip -q "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" -d "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp"
mv $(find "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp" -name ffmpeg.exe | head -n 1) "$GITHUB_WORKSPACE/dist/windows/bin/ffmpeg.exe" mv $(find "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp" -name ffmpeg.exe | head -n 1) "$GITHUB_WORKSPACE/dist/windows/bin/ffmpeg.exe"
# aria2c Windows static # aria2c Windows static
curl -fL \ curl -fL -H "User-Agent: github-actions" \
-H "User-Agent: github-actions" \
-o "$GITHUB_WORKSPACE/dist/windows/aria2c.zip" \ -o "$GITHUB_WORKSPACE/dist/windows/aria2c.zip" \
https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip
unzip "$GITHUB_WORKSPACE/dist/windows/aria2c.zip" -d "$GITHUB_WORKSPACE/dist/windows/" unzip "$GITHUB_WORKSPACE/dist/windows/aria2c.zip" -d "$GITHUB_WORKSPACE/dist/windows/"
mv "$GITHUB_WORKSPACE/dist/windows/aria2-1.37.0-win-64bit-build1/aria2c.exe" "$GITHUB_WORKSPACE/dist/windows/bin/aria2c.exe" mv "$GITHUB_WORKSPACE/dist/windows/aria2-1.37.0-win-64bit-build1/aria2c.exe" "$GITHUB_WORKSPACE/dist/windows/bin/aria2c.exe"
# Remove temp files before zipping
rm -rf "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp" "$GITHUB_WORKSPACE/dist/windows/aria2-1.37.0-win-64bit-build1" "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" "$GITHUB_WORKSPACE/dist/windows/aria2c.zip" rm -rf "$GITHUB_WORKSPACE/dist/windows/ffmpeg_temp" "$GITHUB_WORKSPACE/dist/windows/aria2-1.37.0-win-64bit-build1" "$GITHUB_WORKSPACE/dist/windows/ffmpeg.zip" "$GITHUB_WORKSPACE/dist/windows/aria2c.zip"
# Create windows archive # Create windows archive
@@ -83,19 +71,10 @@ jobs:
name: windows-zip name: windows-zip
path: ${{ github.workspace }}/yt-playlist-windows-*.zip path: ${{ github.workspace }}/yt-playlist-windows-*.zip
build-linux-package: build-linux-package:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - uses: actions/checkout@v5
uses: actions/checkout@v5
- name: Get version from tag - name: Get version from tag
id: version id: version
@@ -114,30 +93,24 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt update sudo apt update
sudo apt install -y unzip zip curl wget build-essential \ sudo apt install -y unzip zip curl wget build-essential pkg-config libssl-dev zlib1g-dev
pkg-config libssl-dev zlib1g-dev
- name: Prepare workspace - name: Prepare workspace
run: | run: |
set -e set -e
mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin" mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin"
cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/linux/" cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/linux/"
- name: Download yt-dlp - name: Download yt-dlp
run: | run: |
curl -fL \ curl -fL -H "User-Agent: github-actions" \
-H "User-Agent: github-actions" \
-o "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp" \ -o "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp" \
https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp" chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp"
- name: Download FFmpeg static - name: Download FFmpeg static
run: | run: |
curl -fL \ curl -fL -H "User-Agent: github-actions" \
-H "User-Agent: github-actions" \
-o "$GITHUB_WORKSPACE/dist/linux/ffmpeg.tar.xz" \ -o "$GITHUB_WORKSPACE/dist/linux/ffmpeg.tar.xz" \
https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
mkdir -p "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp" mkdir -p "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp"
@@ -145,17 +118,10 @@ jobs:
mv "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp/ffmpeg" "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg" mv "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp/ffmpeg" "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg"
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg" chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg"
- name: Cache aria2c binary
uses: actions/cache@v3
with:
path: dist/linux/bin/aria2c
key: aria2c-latest
restore-keys: |
aria2c-
- name: Build aria2c if not cached - name: Build aria2c if not cached
run: | run: |
set -e set -e
mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin"
if [ ! -f "$GITHUB_WORKSPACE/dist/linux/bin/aria2c" ]; then if [ ! -f "$GITHUB_WORKSPACE/dist/linux/bin/aria2c" ]; then
mkdir -p "$GITHUB_WORKSPACE/dist/linux/aria2c_build" mkdir -p "$GITHUB_WORKSPACE/dist/linux/aria2c_build"
cd "$GITHUB_WORKSPACE" cd "$GITHUB_WORKSPACE"
@@ -173,21 +139,19 @@ jobs:
strip src/aria2c strip src/aria2c
cp src/aria2c "$GITHUB_WORKSPACE/dist/linux/bin/aria2c" cp src/aria2c "$GITHUB_WORKSPACE/dist/linux/bin/aria2c"
chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/aria2c" chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/aria2c"
# Cleanup build folders
rm -rf "$GITHUB_WORKSPACE/dist/linux/aria2c_build" "$GITHUB_WORKSPACE/aria2-1.37.0" "$GITHUB_WORKSPACE/aria2-1.37.0.tar.gz" rm -rf "$GITHUB_WORKSPACE/dist/linux/aria2c_build" "$GITHUB_WORKSPACE/aria2-1.37.0" "$GITHUB_WORKSPACE/aria2-1.37.0.tar.gz"
fi fi
- name: Cleanup FFmpeg temp - name: Cleanup FFmpeg temp
run: | run: rm -rf "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp" "$GITHUB_WORKSPACE/dist/linux/ffmpeg.tar.xz"
rm -rf "$GITHUB_WORKSPACE/dist/linux/ffmpeg_temp" "$GITHUB_WORKSPACE/dist/linux/ffmpeg.tar.xz"
- name: Archive Linux package - name: Archive Linux package
run: | run: |
set -e set -e
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
cd "$GITHUB_WORKSPACE/dist/linux" cd "$GITHUB_WORKSPACE/dist/linux"
ZIP_NAME="yt-playlist-linux-${VERSION}.tar.gz" TAR_NAME="yt-playlist-linux-${VERSION}.tar.gz"
tar -czf "$GITHUB_WORKSPACE/$ZIP_NAME" * tar -czf "$GITHUB_WORKSPACE/$TAR_NAME" *
- name: Upload Linux artifact - name: Upload Linux artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -198,11 +162,8 @@ jobs:
build-docker-image: build-docker-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build-linux-package] needs: [build-linux-package]
env:
IMAGE_NAME: youtubeplaylistdownloader
steps: steps:
- name: Checkout code - uses: actions/checkout@v5
uses: actions/checkout@v5
- name: Get version from tag - name: Get version from tag
id: version id: version
@@ -218,22 +179,24 @@ jobs:
VERSION="${VERSION#v}" VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set docker image names
run: |
echo "RELEASE_IMAGE=ghcr.io/${GITHUB_ACTOR}/youtubeplaylistdownloader:${{ steps.version.outputs.version }}" >> $GITHUB_ENV
echo "LATEST_IMAGE=ghcr.io/${GITHUB_ACTOR}/youtubeplaylistdownloader:latest" >> $GITHUB_ENV
- name: Download linux-zip artifact - name: Download linux-zip artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: linux-zip name: linux-zip
- name: Extract linux artifact - name: Extract linux artifact
run: | run: tar -xzf linux-zip/yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz -C .
set -e
tar -xzf linux-zip/yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz -C .
- name: Build Docker image with release tag - name: Build Docker image (release)
run: docker build ./ -t ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} run: docker build ./ -t $RELEASE_IMAGE
- name: Save Docker image as tar - name: Save Docker image as tar
run: | run: docker save -o docker-image.tar $RELEASE_IMAGE
docker save -o docker-image.tar ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
- name: Upload docker-image artifact - name: Upload docker-image artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -241,105 +204,14 @@ jobs:
name: docker-image name: docker-image
path: docker-image.tar path: docker-image.tar
- name: Build Docker image as latest (distinct digest) - name: Build Docker image (latest)
run: docker build ./ --label build_as_latest=true -t ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:latest run: docker build ./ --label build_as_latest=true -t $LATEST_IMAGE
- name: Save Docker image as tar - name: Save Docker image as tar (latest)
run: | run: docker save -o docker-image-latest.tar $LATEST_IMAGE
docker save -o docker-image-latest.tar ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:latest
- name: Upload docker-image-latest artifact - name: Upload docker-image-latest artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: docker-image-latest name: docker-image-latest
path: docker-image-latest.tar path: docker-image-latest.tar
release:
runs-on: ubuntu-latest
needs: [build-windows-package, build-linux-package, build-docker-image]
env:
IMAGE_NAME: youtubeplaylistdownloader
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Get version from tag
id: version
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.tag }}"
elif [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ github.ref_name }}"
fi
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Login to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load docker image from tar
run: |
set -e
docker load -i docker-image/docker-image.tar
- name: Push Docker image with release tag
run: docker push ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
- name: Load docker image from tar
run: |
set -e
docker load -i docker-image-latest/docker-image-latest.tar
- name: Push Docker image as latest
run: docker push ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}:latest
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ steps.version.outputs.version }}
draft: true
- name: Upload Windows release asset
uses: actions/upload-release-asset@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: windows-zip/yt-playlist-windows-${{ steps.version.outputs.version }}.zip
asset_name: yt-playlist-windows-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload Linux release asset
uses: actions/upload-release-asset@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: linux-zip/yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz
asset_name: yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz
asset_content_type: application/gzip
- name: Upload Docker image (release tag)
uses: actions/upload-release-asset@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: docker-image/docker-image.tar
asset_name: docker-image-${{ steps.version.outputs.version }}.tar
asset_content_type: application/x-tar
- name: Upload Docker image (latest)
uses: actions/upload-release-asset@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: docker-image-latest/docker-image-latest.tar
asset_name: docker-image-latest.tar
asset_content_type: application/x-tar