Merge branch 'beta'

This commit is contained in:
oop7
2026-01-06 16:14:15 +02:00
7 changed files with 218 additions and 115 deletions
+45 -80
View File
@@ -1,38 +1,40 @@
# YTSage CI/CD Workflow # YTSage CI/CD Workflow
This repository uses GitHub Actions to automatically build and release YTSage for multiple platforms when version tags are pushed. This repository uses GitHub Actions to automatically build and release YTSage for multiple platforms. The workflow is designed to be manually triggered, allowing for flexibility in building specific versions or platforms on demand.
## How It Works ## How It Works
### Trigger ### Trigger
The workflow is triggered when you push a git tag that starts with `v` (e.g., `v4.9.5`, `v4.9.5`). The workflows are triggered manually via the GitHub Actions "Workflow Dispatch" interface. This allows you to specify the version number explicitly (e.g., `1.0.0`) at runtime.
### Workflows
- **Create All Releases** (`release-all.yml`): The master workflow. Triggering this will automatically run the Windows, Linux, and macOS builds in parallel with the version you provide.
- **Platform Specific**: You can also trigger `Build Windows Release`, `Build Linux Release`, or `Build macOS Release` individually if you only need updates for one OS.
### Build Process ### Build Process
1. **Setup**: Uses Python 3.13.6 on all platforms 1. **Setup**: Uses Python 3.13 on all platforms
2. **Builds**: Creates platform-specific executables using cx_Freeze 2. **Builds**: Creates platform-specific executables using cx_Freeze
3. **Packages**: Generates native package formats for each platform 3. **Packages**: Generates native package formats for each platform
4. **Release**: Creates a draft GitHub release with all artifacts 4. **Release**: Creates or updates a draft GitHub release with the artifacts
## Usage ## Usage
### Creating a Release ### Creating a Full Release (Recommended)
1. **Update version** in your source code if needed 1. Go to the **Actions** tab in the GitHub repository.
2. **Commit your changes**: 2. Select **"Create All Releases"** from the left sidebar.
```bash 3. Click **Run workflow**.
git add . 4. Enter the **Version name** (e.g., `1.0.0`).
git commit -m "Release v4.9.5" > *Note: Do not include the 'v' prefix in the input field unless you want your filenames to be `v1.0.0`.*
``` 5. Click the green **Run workflow** button.
6. The system will trigger the Windows, Linux, and macOS jobs. Once complete, a draft release will be available in the Releases section.
3. **Create and push a tag**: ### Creating a Single Platform Build
```bash
git tag v4.9.5
git push origin v4.9.5
```
4. **Watch the action**: Go to Actions tab in GitHub to monitor progress 1. Go to the **Actions** tab.
2. Select the specific workflow (e.g., **"Build Windows Release"**).
5. **Review draft release**: Once complete, check the Releases section for the draft 3. Click **Run workflow** and enter the version.
4. Only that specific platform's artifacts will be built and added to the release.
### Release Artifacts ### Release Artifacts
@@ -43,12 +45,12 @@ The workflow creates the following files based on the platform:
- `YTSage-v{version}-ffmpeg-portable.zip` - FFmpeg bundle portable - `YTSage-v{version}-ffmpeg-portable.zip` - FFmpeg bundle portable
#### Linux #### Linux
- `YTSage-v{version}-{arch}.AppImage` - AppImage portable - `YTSage-v{version}-{arch}.AppImage` - AppImage portable (x86_64, aarch64)
- `YTSage-v{version}-{arch}.rpm` - RPM package - `YTSage-v{version}-{arch}.rpm` - RPM package
- `YTSage-v{version}-{arch}.deb` - Debian package - `YTSage-v{version}-{arch}.deb` - Debian package
#### macOS #### macOS
- `YTSage-v{version}-{arch}.app.zip` - Zipped application bundle - `YTSage-v{version}-{arch}.app.zip` - Zipped application bundle (x64, arm64)
- `YTSage-v{version}-{arch}.dmg` - Disk image installer - `YTSage-v{version}-{arch}.dmg` - Disk image installer
## Workflow Features ## Workflow Features
@@ -58,82 +60,45 @@ The workflow creates the following files based on the platform:
- **Linux**: Uses Bash scripts with cx_Freeze, creates AppImage, RPM, and DEB - **Linux**: Uses Bash scripts with cx_Freeze, creates AppImage, RPM, and DEB
- **macOS**: Matrix build for both Intel (x64) and Apple Silicon (arm64) - **macOS**: Matrix build for both Intel (x64) and Apple Silicon (arm64)
### Automatic Version Detection ### Manual Versioning
- Extracts version from git tag (removes 'v' prefix) - Version is strictly controlled by the input you provide at runtime.
- Names all artifacts consistently across platforms - No longer dependent on git tags, reducing accidental releases.
### Caching ### Caching
- Python dependencies are cached to speed up builds - Python dependencies and virtual environments are cached to speed up builds.
- Virtual environment is cached between runs
### Error Handling ### Error Handling
- Comprehensive error checking at each step - Comprehensive error checking at each step.
- Detailed logging for troubleshooting - Artifact verification before upload.
- Artifact verification before upload
### Security ### Security
- Uses official GitHub Actions - Uses official GitHub Actions.
- No external dependencies - Secure token handling via `secrets: inherit` for the master workflow.
- Secure token handling
## Manual Intervention ## Manual Intervention
### After Workflow Completion ### After Workflow Completion
1. **Review the draft release** in GitHub 1. **Review the draft release** in GitHub.
2. **Test the artifacts** if needed 2. **Test the artifacts** if needed.
3. **Edit release notes** if desired 3. **Edit release notes** to add changelogs or descriptions.
4. **Publish the release** when ready 4. **Publish the release** when ready (change from Draft to Published).
### Troubleshooting
If the workflow fails:
1. Check the Actions logs for error details
2. Ensure all required files are present
3. Verify the tag format is correct (`v*`)
4. Check that dependencies are properly listed
## Configuration ## Configuration
### Modifying the Workflow ### Modifying the Workflow
The workflow files are located in `.github/workflows/`: The workflow files are located in `.github/workflows/`:
- `build-windows.yml` - Windows builds - `release-all.yml` - Master workflow that orchestrates the others
- `build-linux.yml` - Linux builds - `build-windows.yml` - Windows builds logic
- `build-macos.yml` - macOS builds - `build-linux.yml` - Linux builds logic
- `build-macos.yml` - macOS builds logic
### Key Configuration Options ### Key Configuration Options
- `PYTHON_VERSION`: Python version (currently 3.13.6) - `PYTHON_VERSION`: Python version (currently 3.13)
- Artifact naming patterns - `version` input: Defined as a required string in all workflows.
- Release note templates
- Build optimization settings
### Adding New Build Types
To add new platform packages:
1. Create or modify workflow files in `.github/workflows/`
2. Target the appropriate OS runner (windows-latest, ubuntu-latest, macos-latest)
3. Use cx_Freeze or PyInstaller for packaging
4. Package the build output in platform-native formats
5. Upload the artifacts and include them in the release
## Notes ## Notes
- All builds use cx_Freeze for packaging - All builds use cx_Freeze for packaging.
- FFmpeg binaries are bundled where needed - FFmpeg binaries are bundled where needed (Windows).
- Screenshots are removed from builds to reduce size - Screenshots are removed from builds to reduce size.
- Draft releases allow for review before publication - Draft releases allow for review before publication.
- macOS builds run on both Intel and Apple Silicon runners
## Example Tag Commands
```bash
# For a new release
git tag v4.8.1
git push origin v4.8.1
# For a patch release
git tag v4.8.1
git push origin v4.8.1
# To delete a tag (if needed)
git tag -d v4.8.1
git push origin :refs/tags/v4.8.1
```
+98 -11
View File
@@ -1,9 +1,18 @@
name: Build Linux Release name: Build Linux Release
on: on:
push: workflow_dispatch:
tags: inputs:
- 'v*' version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
workflow_call:
inputs:
version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
permissions: permissions:
contents: write contents: write
@@ -21,12 +30,11 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Extract version from tag - name: Get version
id: get_version id: get_version
shell: bash shell: bash
run: | run: |
tag="${GITHUB_REF_NAME}" version="${{ inputs.version || github.event.inputs.version }}"
version="${tag#v}"
echo "Extracted version: $version" echo "Extracted version: $version"
echo "VERSION=$version" >> "$GITHUB_OUTPUT" echo "VERSION=$version" >> "$GITHUB_OUTPUT"
@@ -372,6 +380,84 @@ jobs:
mv "$deb_out" artifacts/ mv "$deb_out" artifacts/
echo "Built native DEB: artifacts/$deb_out" echo "Built native DEB: artifacts/$deb_out"
- name: Build Flatpak Bundle
shell: bash
run: |
version="${{ steps.get_version.outputs.VERSION }}"
# Install flatpak-builder
sudo apt-get install -y flatpak-builder
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Define manifest ID
APP_ID="io.github.oop7.YTSage"
# Create manifest manually
cat > ytsage_flatpak.json <<EOF
{
"app-id": "$APP_ID",
"runtime": "org.kde.Platform",
"runtime-version": "6.6",
"sdk": "org.kde.Sdk",
"command": "ytsage",
"finish-args": [
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--socket=pulseaudio",
"--device=dri",
"--share=network",
"--filesystem=host",
"--env=YTDLP_APP_BIN_PATH=/var/data/yt-dlp"
],
"modules": [
{
"name": "ytsage",
"buildsystem": "simple",
"build-commands": [
"mkdir -p /app/bin /app/share/ytsage",
"cp -r dist/ytsage-v${version}-*/* /app/share/ytsage/",
"ln -s /app/share/ytsage/ytsage /app/bin/ytsage",
"install -D ytsage.desktop /app/share/applications/$APP_ID.desktop",
"install -D assets/branding/icons/icon.png /app/share/icons/hicolor/128x128/apps/$APP_ID.png"
],
"sources": [
{
"type": "dir",
"path": "."
}
]
}
]
}
EOF
# Build the Flatpak
# Note: In a real environment, building from source is preferred.
# Here we are "bundling" the already built binaries from the previous step (cx_Freeze) for simplicity in CI.
# This requires the 'dist/' folder to be populated by the previous 'Create cx_Freeze setup script' + build steps.
# Wait, the previous steps built into 'build/exe.linux-...' not 'dist/'. Let's find it.
build_dir=$(ls -d build/exe.* 2>/dev/null | head -n1)
if [ -z "$build_dir" ]; then
echo "Error: build/exe.* directory not found for Flatpak build" >&2
exit 1
fi
# Move build dir to a fixed location for the manifest source to catch
mkdir -p dist/ytsage-v${version}-flatpak
cp -r "$build_dir"/* "dist/ytsage-v${version}-flatpak/"
# Install runtime/sdk
flatpak install -y --user flathub org.kde.Platform//6.6 org.kde.Sdk//6.6
# Build
flatpak-builder --user --install-deps-from=flathub --repo=repo --force-clean build-flatpak ytsage_flatpak.json
# Bundle
flatpak build-bundle repo artifacts/YTSage-v${version}-x86_64.flatpak $APP_ID
echo "Built Flatpak: artifacts/YTSage-v${version}-x86_64.flatpak"
- name: Package and prepare release artifacts (.AppImage, .rpm, .deb) - name: Package and prepare release artifacts (.AppImage, .rpm, .deb)
shell: bash shell: bash
run: | run: |
@@ -399,24 +485,25 @@ jobs:
# DEB is already staged in artifacts by the native packaging step # DEB is already staged in artifacts by the native packaging step
ls -1 artifacts/*.deb 2>/dev/null || echo "Warning: No .deb found in artifacts/" ls -1 artifacts/*.deb 2>/dev/null || echo "Warning: No .deb found in artifacts/"
# Check for Flatpak
ls -1 artifacts/*.flatpak 2>/dev/null || echo "Warning: No .flatpak found in artifacts/"
echo "Final artifacts:" echo "Final artifacts:"
ls -lh artifacts || true ls -lh artifacts || true
- name: Create/Update draft release - name: Create/Update draft release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ github.ref_name }} tag_name: v${{ steps.get_version.outputs.VERSION }}
name: YTSage ${{ github.ref_name }} name: YTSage v${{ steps.get_version.outputs.VERSION }}
draft: true draft: true
prerelease: false prerelease: false
append_body: true append_body: true
fail_on_unmatched_files: false fail_on_unmatched_files: false
body: | body: |
# YTSage ${{ github.ref_name }} # YTSage v${{ steps.get_version.outputs.VERSION }}
**Release Date**: ${{ github.event.head_commit.timestamp }} **Release Date**: ${{ github.event.head_commit.timestamp }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}
files: | files: |
artifacts/* artifacts/*
env: env:
+17 -11
View File
@@ -1,9 +1,18 @@
name: Build macOS Release name: Build macOS Release
on: on:
push: workflow_dispatch:
tags: inputs:
- 'v*' version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
workflow_call:
inputs:
version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
permissions: permissions:
contents: write contents: write
@@ -21,12 +30,11 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Extract version from tag - name: Get version
id: get_version id: get_version
shell: bash shell: bash
run: | run: |
tag="${GITHUB_REF_NAME}" version="${{ inputs.version || github.event.inputs.version }}"
version="${tag#v}"
echo "Extracted version: $version" echo "Extracted version: $version"
echo "VERSION=$version" >> "$GITHUB_OUTPUT" echo "VERSION=$version" >> "$GITHUB_OUTPUT"
@@ -240,18 +248,16 @@ jobs:
- name: Create/Update draft release - name: Create/Update draft release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ github.ref_name }} tag_name: v${{ steps.get_version.outputs.VERSION }}
name: YTSage ${{ github.ref_name }} name: YTSage v${{ steps.get_version.outputs.VERSION }}
draft: true draft: true
prerelease: false prerelease: false
append_body: true append_body: true
fail_on_unmatched_files: false fail_on_unmatched_files: false
body: | body: |
# YTSage ${{ github.ref_name }} # YTSage v${{ steps.get_version.outputs.VERSION }}
**Release Date**: ${{ github.event.head_commit.timestamp }} **Release Date**: ${{ github.event.head_commit.timestamp }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}
files: | files: |
artifacts/* artifacts/*
env: env:
+17 -11
View File
@@ -1,9 +1,18 @@
name: Build Windows Release name: Build Windows Release
on: on:
push: workflow_dispatch:
tags: inputs:
- 'v*' version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
workflow_call:
inputs:
version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
permissions: permissions:
contents: write contents: write
@@ -21,12 +30,11 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Extract version from tag - name: Get version
id: get_version id: get_version
shell: powershell shell: powershell
run: | run: |
$tag = "${{ github.ref_name }}" $version = "${{ inputs.version || github.event.inputs.version }}"
$version = $tag -replace '^v', ''
Write-Host "Extracted version: $version" Write-Host "Extracted version: $version"
echo "VERSION=$version" >> $env:GITHUB_OUTPUT echo "VERSION=$version" >> $env:GITHUB_OUTPUT
@@ -298,16 +306,14 @@ jobs:
- name: Create draft release - name: Create draft release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ github.ref_name }} tag_name: v${{ steps.get_version.outputs.VERSION }}
name: YTSage ${{ github.ref_name }} name: YTSage v${{ steps.get_version.outputs.VERSION }}
draft: true draft: true
prerelease: false prerelease: false
body: | body: |
# YTSage ${{ github.ref_name }} # YTSage v${{ steps.get_version.outputs.VERSION }}
**Release Date**: ${{ github.event.head_commit.timestamp }} **Release Date**: ${{ github.event.head_commit.timestamp }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}
files: | files: |
artifacts/* artifacts/*
env: env:
+28
View File
@@ -0,0 +1,28 @@
name: Create All Releases
on:
workflow_dispatch:
inputs:
version:
description: 'Version name for the release (e.g., 1.0.0)'
required: true
type: string
jobs:
release-windows:
uses: ./.github/workflows/build-windows.yml
with:
version: ${{ inputs.version }}
secrets: inherit
release-linux:
uses: ./.github/workflows/build-linux.yml
with:
version: ${{ inputs.version }}
secrets: inherit
release-macos:
uses: ./.github/workflows/build-macos.yml
with:
version: ${{ inputs.version }}
secrets: inherit
+2 -1
View File
@@ -339,7 +339,8 @@ YTSage/
│ ├─── 📁 workflows/ # GitHub Actions workflows │ ├─── 📁 workflows/ # GitHub Actions workflows
│ │ ├── build-linux.yml # Linux build workflow │ │ ├── build-linux.yml # Linux build workflow
│ │ ├── build-macos.yml # macOS build workflow │ │ ├── build-macos.yml # macOS build workflow
│ │ ── build-windows.yml # Windows build workflow │ │ ── build-windows.yml # Windows build workflow
| | └── release-all.yml # Master release workflow
│ └── 📄 CI_CD_README.md # CI/CD documentation │ └── 📄 CI_CD_README.md # CI/CD documentation
├── 📁 assets/ # Static assets and resources ├── 📁 assets/ # Static assets and resources
│ ├── 📁 branding/ # Branding assets │ ├── 📁 branding/ # Branding assets
+11 -1
View File
@@ -138,7 +138,13 @@ else: # Linux and other UNIX-like
APP_THUMBNAILS_DIR: Path = APP_DATA_DIR / "thumbnails" APP_THUMBNAILS_DIR: Path = APP_DATA_DIR / "thumbnails"
YTDLP_DOWNLOAD_URL: str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp" YTDLP_DOWNLOAD_URL: str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp"
YTDLP_APP_BIN_PATH: Path = APP_BIN_DIR / "yt-dlp"
# Check for environment variable override (critical for Flatpak support)
_ytdlp_env_path = os.environ.get("YTDLP_APP_BIN_PATH")
if _ytdlp_env_path:
YTDLP_APP_BIN_PATH: Path = Path(_ytdlp_env_path)
else:
YTDLP_APP_BIN_PATH: Path = APP_BIN_DIR / "yt-dlp"
SUBPROCESS_CREATIONFLAGS: int = 0 SUBPROCESS_CREATIONFLAGS: int = 0
@@ -194,3 +200,7 @@ else:
APP_DATA_DIR.mkdir(parents=True, exist_ok=True) APP_DATA_DIR.mkdir(parents=True, exist_ok=True)
APP_LOG_DIR.mkdir(parents=True, exist_ok=True) APP_LOG_DIR.mkdir(parents=True, exist_ok=True)
APP_THUMBNAILS_DIR.mkdir(parents=True, exist_ok=True) APP_THUMBNAILS_DIR.mkdir(parents=True, exist_ok=True)
# Ensure custom yt-dlp directory exists if set
if OS_NAME not in ["Windows", "Darwin"]:
YTDLP_APP_BIN_PATH.parent.mkdir(parents=True, exist_ok=True)