Add linting workflow for Python code using Ruff

This commit is contained in:
dark_zoul committed 2026-03-18 18:47:14 +02:00
1 parent 09a0b513d7
commit d2556185b8
1 file changed
+44 -41
+44 -41
View File
@@ -62,57 +62,58 @@ jobs:
shell: pwsh shell: pwsh
run: | run: |
$VERSION = "${{ steps.version.outputs.version }}" $VERSION = "${{ steps.version.outputs.version }}"
New-Item -ItemType Directory -Force -Path "dist/windows/bin" $WORKSPACE = "${{ github.workspace }}"
Copy-Item "yt-playlist-main.py" "dist/windows/" New-Item -ItemType Directory -Force -Path "$WORKSPACE/dist/windows/bin"
Copy-Item "$WORKSPACE/yt-playlist-main.py" "$WORKSPACE/dist/windows/"
# yt-dlp # yt-dlp
Invoke-WebRequest -Uri "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe" -OutFile "dist/windows/bin/yt-dlp.exe" 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 # FFmpeg
Invoke-WebRequest -Uri "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" -OutFile "dist/windows/ffmpeg.zip" Invoke-WebRequest -Uri "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" -OutFile "$WORKSPACE/dist/windows/ffmpeg.zip"
Expand-Archive "dist/windows/ffmpeg.zip" -DestinationPath "dist/windows/ffmpeg_temp" Expand-Archive "$WORKSPACE/dist/windows/ffmpeg.zip" -DestinationPath "$WORKSPACE/dist/windows/ffmpeg_temp"
$ffmpegExe = Get-ChildItem -Path "dist/windows/ffmpeg_temp" -Filter "ffmpeg.exe" -Recurse | Select-Object -First 1 $ffmpegExe = Get-ChildItem -Path "$WORKSPACE/dist/windows/ffmpeg_temp" -Filter "ffmpeg.exe" -Recurse | Select-Object -First 1
Move-Item $ffmpegExe.FullName "dist/windows/bin/ffmpeg.exe" Move-Item $ffmpegExe.FullName "$WORKSPACE/dist/windows/bin/ffmpeg.exe"
# aria2c (Windows Portable) # 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 "dist/windows/aria2c.zip" 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 "dist/windows/aria2c.zip" -DestinationPath "dist/windows/aria2_temp" Expand-Archive "$WORKSPACE/dist/windows/aria2c.zip" -DestinationPath "$WORKSPACE/dist/windows/aria2_temp"
Move-Item "dist/windows/aria2_temp/aria2-1.37.0-win-64bit-build1/aria2c.exe" "dist/windows/bin/aria2c.exe" 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 # Build .exe using PyInstaller
pip install pyinstaller pip install pyinstaller
pyinstaller --onefile --name "yt-playlist-downloader" --add-data "src;ytpld" yt-playlist-main.py pyinstaller --onefile --name "yt-playlist-downloader" --workpath "$WORKSPACE/build" --specpath "$WORKSPACE" --distpath "$WORKSPACE/dist" --add-data "$WORKSPACE/src;ytpld" "$WORKSPACE/yt-playlist-main.py"
Move-Item "dist/yt-playlist-downloader.exe" "dist/windows/yt-playlist-downloader.exe" Move-Item "$WORKSPACE/dist/yt-playlist-downloader.exe" "$WORKSPACE/dist/windows/yt-playlist-downloader.exe"
# Cleanup & Archive # Cleanup & Archive
Remove-Item -Recurse -Force "dist/windows/ffmpeg_temp", "dist/windows/aria2_temp", "dist/windows/*.zip" Remove-Item -Recurse -Force "$WORKSPACE/dist/windows/ffmpeg_temp", "$WORKSPACE/dist/windows/aria2_temp", "$WORKSPACE/dist/windows/*.zip"
Compress-Archive -Path "dist/windows/*" -DestinationPath "yt-playlist-windows-$VERSION.zip" Compress-Archive -Path "$WORKSPACE/dist/windows/*" -DestinationPath "$WORKSPACE/yt-playlist-windows-$VERSION.zip"
# --- LINUX BUILD --- # --- LINUX BUILD ---
- name: Build Linux Package - name: Build Linux Package
if: matrix.platform == 'linux' if: matrix.platform == 'linux'
run: | run: |
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
mkdir -p dist/linux/bin mkdir -p "$GITHUB_WORKSPACE/dist/linux/bin"
cp yt-playlist-main.py dist/linux/ cp "$GITHUB_WORKSPACE/yt-playlist-main.py" "$GITHUB_WORKSPACE/dist/linux/"
# yt-dlp # yt-dlp
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -o dist/linux/bin/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 dist/linux/bin/yt-dlp chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/yt-dlp"
# FFmpeg (static) # FFmpeg (static)
curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o ffmpeg.tar.xz curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o "$GITHUB_WORKSPACE/ffmpeg.tar.xz"
mkdir -p ffmpeg_temp mkdir -p "$GITHUB_WORKSPACE/ffmpeg_temp"
tar -xf ffmpeg.tar.xz -C ffmpeg_temp --strip-components=1 tar -xf "$GITHUB_WORKSPACE/ffmpeg.tar.xz" -C "$GITHUB_WORKSPACE/ffmpeg_temp" --strip-components=1
mv ffmpeg_temp/ffmpeg dist/linux/bin/ mv "$GITHUB_WORKSPACE/ffmpeg_temp/ffmpeg" "$GITHUB_WORKSPACE/dist/linux/bin/"
chmod +x dist/linux/bin/ffmpeg chmod +x "$GITHUB_WORKSPACE/dist/linux/bin/ffmpeg"
- name: Cache aria2c binary (Linux) - name: Cache aria2c binary (Linux)
if: matrix.platform == 'linux' if: matrix.platform == 'linux'
id: aria2-cache id: aria2-cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: dist/linux/bin/aria2c path: ${{ github.workspace }}/dist/linux/bin/aria2c
key: aria2c-linux-1.37.0 key: aria2c-linux-1.37.0
- name: Build aria2c (Linux) - name: Build aria2c (Linux)
@@ -149,15 +150,15 @@ jobs:
run: | run: |
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
# Archive # Archive
cd dist/linux && tar -czf ../../yt-playlist-linux-$VERSION.tar.gz * cd "$GITHUB_WORKSPACE/dist/linux" && tar -czf "$GITHUB_WORKSPACE/yt-playlist-linux-$VERSION.tar.gz" *
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
name: ${{ matrix.artifact_name }} name: ${{ matrix.artifact_name }}
path: | path: |
*.zip ${{ github.workspace }}/*.zip
*.tar.gz ${{ github.workspace }}/*.tar.gz
docker: docker:
needs: build needs: build
@@ -177,18 +178,18 @@ jobs:
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: linux-release name: linux-release
path: dist/linux-docker path: ${{ github.workspace }}/dist/linux-docker
- name: Prepare Docker build context - name: Prepare Docker build context
run: | run: |
cd dist/linux-docker cd "$GITHUB_WORKSPACE/dist/linux-docker"
tar -xzf yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz tar -xzf "$GITHUB_WORKSPACE/dist/linux-docker/yt-playlist-linux-${{ steps.version.outputs.version }}.tar.gz"
cp ../../Dockerfile . cp "$GITHUB_WORKSPACE/Dockerfile" .
cp ../../docker-entrypoint.sh . cp "$GITHUB_WORKSPACE/docker-entrypoint.sh" .
# Ensure ytpld package is present from src/ # Ensure ytpld package is present from src/
if [ ! -d "src" ]; then cp -r ../../src . ; fi if [ ! -d "src" ]; then cp -r "$GITHUB_WORKSPACE/src" . ; fi
# Ensure config directory is present # Ensure config directory is present
if [ ! -d "config" ]; then cp -r ../../config . ; fi if [ ! -d "config" ]; then cp -r "$GITHUB_WORKSPACE/config" . ; fi
- name: Set docker image names - name: Set docker image names
run: | run: |
@@ -199,19 +200,19 @@ jobs:
- name: Build Docker image - name: Build Docker image
run: | run: |
docker build . -t $RELEASE_IMAGE -t $LATEST_IMAGE docker build . -t $RELEASE_IMAGE -t $LATEST_IMAGE
working-directory: dist/linux-docker working-directory: ${{ github.workspace }}/dist/linux-docker
- name: Save Docker images - name: Save Docker images
run: | run: |
docker save -o docker-image.tar $RELEASE_IMAGE docker save -o docker-image.tar $RELEASE_IMAGE
docker save -o docker-image-latest.tar $LATEST_IMAGE docker save -o docker-image-latest.tar $LATEST_IMAGE
working-directory: dist/linux-docker working-directory: ${{ github.workspace }}/dist/linux-docker
- name: Upload Docker artifacts - name: Upload Docker artifacts
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
name: docker-images name: docker-images
path: dist/linux-docker/docker-image*.tar path: ${{ github.workspace }}/dist/linux-docker/docker-image*.tar
release: release:
needs: [build, docker] needs: [build, docker]
@@ -220,6 +221,8 @@ jobs:
steps: steps:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
- name: Get version - name: Get version
id: version id: version
@@ -238,9 +241,9 @@ jobs:
- name: Push Docker images - name: Push Docker images
run: | run: |
docker load -i docker-images/docker-image.tar docker load -i "${{ github.workspace }}/artifacts/docker-images/docker-image.tar"
docker push ghcr.io/${GITHUB_ACTOR}/ytpld:${{ steps.version.outputs.version }} docker push ghcr.io/${GITHUB_ACTOR}/ytpld:${{ steps.version.outputs.version }}
docker load -i docker-images/docker-image-latest.tar docker load -i "${{ github.workspace }}/artifacts/docker-images/docker-image-latest.tar"
docker push ghcr.io/${GITHUB_ACTOR}/ytpld:latest docker push ghcr.io/${GITHUB_ACTOR}/ytpld:latest
- name: Create Release - name: Create Release
@@ -248,5 +251,5 @@ jobs:
with: with:
tag_name: ${{ github.event.inputs.tag }} tag_name: ${{ github.event.inputs.tag }}
files: | files: |
**/*.zip ${{ github.workspace }}/artifacts/**/*.zip
**/*.tar.gz ${{ github.workspace }}/artifacts/**/*.tar.gz