Skip to content

Inline key event handler #81

Inline key event handler

Inline key event handler #81

Workflow file for this run

name: 'Pipeline'
on:
push:
branches: [ '**' ]
defaults:
run:
shell: bash
jobs:
build_python:
runs-on: ubuntu-latest
name: 'Test Python & Build mpvQC'
outputs:
version: ${{ steps.step_version.outputs.version }}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Install Python 3.12'
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: 'Install just'
uses: taiki-e/install-action@just
- name: 'Update Project Build Information'
id: step_version
run: |
function debug() { echo -e "\033[0;35m$*\033[0m"; }
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
PLACEHOLDER_TAG=">>>tag<<<"
PLACEHOLDER_COMMIT=">>>commit-id<<<"
CURRENT_TAG="$(git describe --tags --abbrev=0)"
debug "git tag: $CURRENT_TAG"
CURRENT_COMMIT="$(git rev-parse HEAD)"
CURRENT_COMMIT="${CURRENT_COMMIT:0:8}"
debug "git commit: $CURRENT_COMMIT"
ARTIFACT_NAME="mpvQC-$CURRENT_TAG-$CURRENT_COMMIT"
debug "artifact name: $ARTIFACT_NAME"
echo "version=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
FILES_UPDATABLE="$(grep -rli -e "$PLACEHOLDER_TAG" -e "$PLACEHOLDER_COMMIT" mpvqc qml)"
echo "$FILES_UPDATABLE" | while read -r FILE; do
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "$FILE"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "$FILE"
execute cat "$FILE"
done
- name: 'Update Packages And Dependencies'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute sudo apt update -y
execute sudo apt upgrade -y
execute sudo apt install -y libmpv1 patchelf libopengl0
- name: 'Setup Virtual Environment'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute python -m venv venv
execute source venv/bin/activate
execute python -m pip install --upgrade pip
execute python -m pip install wheel
execute python -m pip install -r requirements.txt
- name: 'Set Dependency Versions'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
function error() { echo -e "\033[0;31m$*\033[0m"; }
execute source venv/bin/activate
DEPENDENCY_MODEL_FILE='MpvqcLibraryModel.qml'
DEPENDENCY_MODEL_PATH=$(find qml -type f -name "$DEPENDENCY_MODEL_FILE")
if [ -z "$DEPENDENCY_MODEL_PATH" ]; then
error "Could not find dependency model $DEPENDENCY_MODEL_FILE"
exit 1
fi
DEPENDENCIES=("inject" "mpv" "PySide6" "pytest" "pywin32") # List ALL dependencies for ALL os manually :|
for (( i=0; i<${#DEPENDENCIES[@]}; i++ )) do
DEPENDENCY="${DEPENDENCIES[$i]}"
VERSION=$(curl -s "https://pypi.org/pypi/$DEPENDENCY/json" | jq -r .info.version)
if [ -z "$VERSION" ]; then
error "Could not fetch version for dependency: $DEPENDENCY"
exit 1
fi
execute sed -i "s/@@pypi-$DEPENDENCY@@/$VERSION/g" "$DEPENDENCY_MODEL_PATH"
done
if grep '@@' "$DEPENDENCY_MODEL_PATH"; then
error 'Could not find all dependency versions'
exit 1
else
execute cat "$DEPENDENCY_MODEL_PATH"
fi
- name: 'Remove Qml Test Files'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute find . -type f -name 'tst_*.qml' -delete
- name: 'Run Python Build'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/bin/activate
execute just test-python
execute just clean
execute just build
- name: 'Upload Build Artifact'
uses: actions/upload-artifact@v3
if: github.ref_name == 'main'
with:
path: build/release
name: release-build-artifact
test_qml:
runs-on: ubuntu-latest
name: 'Test Qml'
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Install Qt 6.6.0'
uses: jurplel/install-qt-action@v3
with:
version: '6.6.0'
- name: 'Install just'
uses: taiki-e/install-action@just
- name: 'Lint Qml Files'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute just lint-qml
continue-on-error: true
- name: 'Execute Qml Tests'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute export QT_QPA_PLATFORM=offscreen
execute just test-qml
build_windows:
runs-on: windows-latest
name: 'Build Windows'
if: github.ref_name == 'main'
needs:
- build_python
- test_qml
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Download Build Artifact'
uses: actions/download-artifact@v3
with:
path: build/release
name: release-build-artifact
- name: 'Install Python 3.12'
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: 'Setup Build Environment'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute python -m venv venv
execute source venv/Scripts/activate
execute python -m pip install --upgrade pip
execute python -m pip install wheel
execute python -m pip install -r requirements.txt
execute python -m pip install pyinstaller
- name: 'Build Bundle'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/Scripts/activate
execute pyinstaller \
--name mpvQC \
--workpath build-windows \
--icon=build-aux/windows/icon.ico \
--collect-binaries PySide6 \
--add-data "LICENSE;." \
--noconsole \
build/release/main.py
- name: 'Remove Redundant Binaries'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute find dist/mpvQC -type f -name 'Qt6WebEngineCore.dll' -delete
execute find dist/mpvQC -type f -name 'opengl32sw.dll' -delete
- name: 'Make Archive Portable'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute touch dist/mpvQC/_internal/portable
- name: 'Package libmpv'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
ARTIFACT="mpv-dev-x86_64-20231126-git-6898d57.7z"
URL="https://sourceforge.net/projects/mpv-player-windows/files/libmpv/$ARTIFACT"
execute curl -L -O "$URL"
execute 7z x "$ARTIFACT"
execute mv libmpv-2.dll dist/mpvQC
- name: 'Compress Artifact'
shell: pwsh
run: Compress-Archive -Path "dist\mpvQC\*" -DestinationPath "${{ needs.build_python.outputs.version }}.zip"
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: "${{ needs.build_python.outputs.version }}-win-x86_64"
path: "${{ needs.build_python.outputs.version }}.zip"
build_linux:
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08
options: --privileged
name: 'Build Linux'
if: github.ref_name == 'main'
needs:
- build_python
- test_qml
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Download Build Artifact'
uses: actions/download-artifact@v3
with:
path: build/release
name: release-build-artifact
- name: 'Prepare Flatpak Build'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute mv build-aux/linux/com.github.mpvqc.mpvQC.yml com.github.mpvqc.mpvQC.yml
- name: 'Build Flatpak'
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
with:
manifest-path: com.github.mpvqc.mpvQC.yml
bundle: ${{ needs.build_python.outputs.version }}-linux.flatpak
branch: main
cache: false
cache-key: flatpak-builder-${{ github.sha }}