From 16e61c5d6fa6e9166146185aa7042cd239e1b0dc Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 6 Jan 2026 15:52:58 +0200 Subject: [PATCH 1/5] Refactor release workflows and add release-all trigger Refactored build workflows for Linux, macOS, and Windows to use workflow_dispatch and workflow_call with explicit version input, replacing tag-based triggers. Updated release steps to use the provided version input for tagging and naming. Added a new release-all workflow to trigger all platform builds with a single version input. --- .github/workflows/build-linux.yml | 28 +++++++++++++++++----------- .github/workflows/build-macos.yml | 28 +++++++++++++++++----------- .github/workflows/build-windows.yml | 28 +++++++++++++++++----------- .github/workflows/release-all.yml | 28 ++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/release-all.yml diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index c81f051..6e3fcab 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -1,9 +1,18 @@ name: Build Linux Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + 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: contents: write @@ -21,12 +30,11 @@ jobs: with: fetch-depth: 0 - - name: Extract version from tag + - name: Get version id: get_version shell: bash run: | - tag="${GITHUB_REF_NAME}" - version="${tag#v}" + version="${{ inputs.version || github.event.inputs.version }}" echo "Extracted version: $version" echo "VERSION=$version" >> "$GITHUB_OUTPUT" @@ -405,18 +413,16 @@ jobs: - name: Create/Update draft release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - name: YTSage ${{ github.ref_name }} + tag_name: v${{ steps.get_version.outputs.VERSION }} + name: YTSage v${{ steps.get_version.outputs.VERSION }} draft: true prerelease: false append_body: true fail_on_unmatched_files: false body: | - # YTSage ${{ github.ref_name }} + # YTSage v${{ steps.get_version.outputs.VERSION }} **Release Date**: ${{ github.event.head_commit.timestamp }} - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }} files: | artifacts/* env: diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index b57164b..5531531 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,9 +1,18 @@ name: Build macOS Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + 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: contents: write @@ -21,12 +30,11 @@ jobs: with: fetch-depth: 0 - - name: Extract version from tag + - name: Get version id: get_version shell: bash run: | - tag="${GITHUB_REF_NAME}" - version="${tag#v}" + version="${{ inputs.version || github.event.inputs.version }}" echo "Extracted version: $version" echo "VERSION=$version" >> "$GITHUB_OUTPUT" @@ -240,18 +248,16 @@ jobs: - name: Create/Update draft release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - name: YTSage ${{ github.ref_name }} + tag_name: v${{ steps.get_version.outputs.VERSION }} + name: YTSage v${{ steps.get_version.outputs.VERSION }} draft: true prerelease: false append_body: true fail_on_unmatched_files: false body: | - # YTSage ${{ github.ref_name }} + # YTSage v${{ steps.get_version.outputs.VERSION }} **Release Date**: ${{ github.event.head_commit.timestamp }} - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }} files: | artifacts/* env: diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index f2e1220..b64a4b3 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -1,9 +1,18 @@ name: Build Windows Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + 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: contents: write @@ -21,12 +30,11 @@ jobs: with: fetch-depth: 0 - - name: Extract version from tag + - name: Get version id: get_version shell: powershell run: | - $tag = "${{ github.ref_name }}" - $version = $tag -replace '^v', '' + $version = "${{ inputs.version || github.event.inputs.version }}" Write-Host "Extracted version: $version" echo "VERSION=$version" >> $env:GITHUB_OUTPUT @@ -298,16 +306,14 @@ jobs: - name: Create draft release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - name: YTSage ${{ github.ref_name }} + tag_name: v${{ steps.get_version.outputs.VERSION }} + name: YTSage v${{ steps.get_version.outputs.VERSION }} draft: true prerelease: false body: | - # YTSage ${{ github.ref_name }} + # YTSage v${{ steps.get_version.outputs.VERSION }} **Release Date**: ${{ github.event.head_commit.timestamp }} - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }} files: | artifacts/* env: diff --git a/.github/workflows/release-all.yml b/.github/workflows/release-all.yml new file mode 100644 index 0000000..7e0fdef --- /dev/null +++ b/.github/workflows/release-all.yml @@ -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 From 45ce4ba69ca47cbb1c1ee9368ad1265d3f229c7d Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 6 Jan 2026 16:02:11 +0200 Subject: [PATCH 2/5] Update CI/CD README for manual workflow triggers Revamps the CI/CD documentation to reflect the new manual workflow dispatch system, replacing tag-based triggers. Adds detailed instructions for running full or platform-specific builds, clarifies artifact naming, and updates configuration and process notes to match the current GitHub Actions setup. --- .github/CI_CD_README.md | 125 +++++++++++++++------------------------- 1 file changed, 45 insertions(+), 80 deletions(-) diff --git a/.github/CI_CD_README.md b/.github/CI_CD_README.md index 343ee55..3bd04d7 100644 --- a/.github/CI_CD_README.md +++ b/.github/CI_CD_README.md @@ -1,38 +1,40 @@ # 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 ### 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 -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 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 -### Creating a Release +### Creating a Full Release (Recommended) -1. **Update version** in your source code if needed -2. **Commit your changes**: - ```bash - git add . - git commit -m "Release v4.9.5" - ``` +1. Go to the **Actions** tab in the GitHub repository. +2. Select **"Create All Releases"** from the left sidebar. +3. Click **Run workflow**. +4. Enter the **Version name** (e.g., `1.0.0`). + > *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**: - ```bash - git tag v4.9.5 - git push origin v4.9.5 - ``` +### Creating a Single Platform Build -4. **Watch the action**: Go to Actions tab in GitHub to monitor progress - -5. **Review draft release**: Once complete, check the Releases section for the draft +1. Go to the **Actions** tab. +2. Select the specific workflow (e.g., **"Build Windows Release"**). +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 @@ -43,12 +45,12 @@ The workflow creates the following files based on the platform: - `YTSage-v{version}-ffmpeg-portable.zip` - FFmpeg bundle portable #### 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}.deb` - Debian package #### 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 ## 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 - **macOS**: Matrix build for both Intel (x64) and Apple Silicon (arm64) -### Automatic Version Detection -- Extracts version from git tag (removes 'v' prefix) -- Names all artifacts consistently across platforms +### Manual Versioning +- Version is strictly controlled by the input you provide at runtime. +- No longer dependent on git tags, reducing accidental releases. ### Caching -- Python dependencies are cached to speed up builds -- Virtual environment is cached between runs +- Python dependencies and virtual environments are cached to speed up builds. ### Error Handling -- Comprehensive error checking at each step -- Detailed logging for troubleshooting -- Artifact verification before upload +- Comprehensive error checking at each step. +- Artifact verification before upload. ### Security -- Uses official GitHub Actions -- No external dependencies -- Secure token handling +- Uses official GitHub Actions. +- Secure token handling via `secrets: inherit` for the master workflow. ## Manual Intervention ### After Workflow Completion -1. **Review the draft release** in GitHub -2. **Test the artifacts** if needed -3. **Edit release notes** if desired -4. **Publish the release** when ready - -### 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 +1. **Review the draft release** in GitHub. +2. **Test the artifacts** if needed. +3. **Edit release notes** to add changelogs or descriptions. +4. **Publish the release** when ready (change from Draft to Published). ## Configuration ### Modifying the Workflow The workflow files are located in `.github/workflows/`: -- `build-windows.yml` - Windows builds -- `build-linux.yml` - Linux builds -- `build-macos.yml` - macOS builds +- `release-all.yml` - Master workflow that orchestrates the others +- `build-windows.yml` - Windows builds logic +- `build-linux.yml` - Linux builds logic +- `build-macos.yml` - macOS builds logic ### Key Configuration Options -- `PYTHON_VERSION`: Python version (currently 3.13.6) -- Artifact naming patterns -- 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 - +- `PYTHON_VERSION`: Python version (currently 3.13) +- `version` input: Defined as a required string in all workflows. ## Notes -- All builds use cx_Freeze for packaging -- FFmpeg binaries are bundled where needed -- Screenshots are removed from builds to reduce size -- 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 -``` +- All builds use cx_Freeze for packaging. +- FFmpeg binaries are bundled where needed (Windows). +- Screenshots are removed from builds to reduce size. +- Draft releases allow for review before publication. From 0edc64a5e98f8b435823ac91f842c611bcdc2ebd Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 6 Jan 2026 16:02:59 +0200 Subject: [PATCH 3/5] Add release-all.yml to CI workflow list in README Documented the master release workflow (release-all.yml) in the CI/CD section of the README for better visibility of available workflows. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1fadcb3..8c3c772 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,7 @@ YTSage/ │ │ ├── build-linux.yml # Linux build workflow │ │ ├── build-macos.yml # macOS build workflow │ │ └── build-windows.yml # Windows build workflow +| | └── release-all.yml # Master release workflow │ └── 📄 CI_CD_README.md # CI/CD documentation ├── 📁 assets/ # Static assets and resources │ ├── 📁 branding/ # Branding assets From 462252b4524604867ab67cbd9cb566ccdef37edc Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 6 Jan 2026 16:04:59 +0200 Subject: [PATCH 4/5] Fix formatting in workflows section of README Corrected indentation and line formatting for the workflows section in the README to improve readability and consistency. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c3c772..2ded665 100644 --- a/README.md +++ b/README.md @@ -339,8 +339,8 @@ YTSage/ │ ├─── 📁 workflows/ # GitHub Actions workflows │ │ ├── build-linux.yml # Linux build workflow │ │ ├── build-macos.yml # macOS build workflow -│ │ └── build-windows.yml # Windows build workflow -| | └── release-all.yml # Master release workflow +│ │ │── build-windows.yml # Windows build workflow +| | └── release-all.yml # Master release workflow │ └── 📄 CI_CD_README.md # CI/CD documentation ├── 📁 assets/ # Static assets and resources │ ├── 📁 branding/ # Branding assets From 0b5b5b3189b64861fa5c7dbacf7071d409aa2341 Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 6 Jan 2026 16:13:21 +0200 Subject: [PATCH 5/5] Add Flatpak build support and env override for yt-dlp path Introduces a Flatpak packaging step to the Linux CI workflow and updates ytsage_constants.py to support overriding the yt-dlp binary path via the YTDLP_APP_BIN_PATH environment variable, which is critical for Flatpak compatibility. Also ensures the custom yt-dlp directory is created if the environment variable is set. --- .github/workflows/build-linux.yml | 81 +++++++++++++++++++++++++++++++ src/utils/ytsage_constants.py | 12 ++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 6e3fcab..ed6be84 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -380,6 +380,84 @@ jobs: mv "$deb_out" artifacts/ 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 </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) shell: bash run: | @@ -407,6 +485,9 @@ jobs: # 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/" + # Check for Flatpak + ls -1 artifacts/*.flatpak 2>/dev/null || echo "Warning: No .flatpak found in artifacts/" + echo "Final artifacts:" ls -lh artifacts || true diff --git a/src/utils/ytsage_constants.py b/src/utils/ytsage_constants.py index 09faa1b..2f4d7b2 100644 --- a/src/utils/ytsage_constants.py +++ b/src/utils/ytsage_constants.py @@ -138,7 +138,13 @@ else: # Linux and other UNIX-like 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_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 @@ -194,3 +200,7 @@ else: APP_DATA_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) + + # 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)