Skip to content

Attempt to unify build pipelines [wip] #356

Attempt to unify build pipelines [wip]

Attempt to unify build pipelines [wip] #356

Workflow file for this run

name: 'Pipeline'
on:
push:
branches: [ '**' ]
defaults:
run:
shell: bash
env:
LIBMPV_URL: "https://sourceforge.net/projects/mpv-player-windows/files/libmpv/mpv-dev-x86_64-20240811-git-4e50da3.7z"
LIBMPV_SHA1: "37e1172f74cb7a3e443197fd1f7ad757ec164be6"
jobs:
matrix-build:
strategy:
matrix:
os: [ windows-latest, ubuntu-24.04 ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Install Python 3.12'
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 'Install just'
uses: taiki-e/install-action@just
- name: 'Run Build'
id: build_step
run: |
set -euo pipefail
function debug() { echo -e "\033[0;35m$*\033[0m"; }
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
echo "::group::Download libmpv"
if [ "$RUNNER_OS" == "Linux" ]; then
execute sudo apt install -y libmpv2 patchelf libopengl0
elif [ "$RUNNER_OS" == "Windows" ]; then
ARTIFACT="$(basename "$LIBMPV_URL")"
execute curl -L -O "$LIBMPV_URL"
echo -e "\033[0;34mecho -n $LIBMPV_SHA1 $ARTIFACT > $ARTIFACT.sha1\033[0m"
echo -n "$LIBMPV_SHA1 $ARTIFACT" > "$ARTIFACT.sha1"
execute sha1sum --check "$ARTIFACT.sha1"
execute 7z x "$ARTIFACT"
else
echo "$RUNNER_OS not supported"
exit 1
fi
echo "::endgroup::"
echo "::group::Remove Qml Test Files"
execute find . -type f -name 'tst_*' -delete
echo "::endgroup::"
echo "::group::Set Build Information"
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 "artifact_app_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "mpvqc/startup.py"
execute cat "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute cat "qml/dialogs/about/MpvqcAboutView.qml"
echo "::endgroup::"
echo "::group::Setup Virtual Environment"
execute python -m venv venv
if [ "$RUNNER_OS" == "Linux" ]; then
execute source venv/bin/activate
elif [ "$RUNNER_OS" == "Windows" ]; then
execute source venv/Scripts/activate
else
echo "$RUNNER_OS not supported"
exit 1
fi
execute python -m pip install --upgrade pip
execute just install-dependencies
echo "::endgroup::"
echo "::group::Set Dependency Versions"
DEPENDENCY_MODEL_PATH='qml/models/MpvqcLibraryModel.qml'
execute python build-aux/generate-dependency-versions.py \
--pyproject-file pyproject.toml \
--optional-group dev \
insert \
--update-inplace "$DEPENDENCY_MODEL_PATH"
execute cat "$DEPENDENCY_MODEL_PATH"
echo "::endgroup::"
echo "::group::Run Python Build"
execute just test-python
execute just clean
execute just build
echo "::endgroup::"
echo "::group::Lint Python"
execute just lint-python
echo "::endgroup::"
build_python_win:
runs-on: windows-latest
name: 'Build Windows'
outputs:
version: ${{ steps.step_version.outputs.version }}
steps:
- name: 'Set 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
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "mpvqc/startup.py"
execute cat "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute cat "qml/dialogs/about/MpvqcAboutView.qml"
- name: 'Setup Virtual 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 just install-dependencies
- name: 'Set Dependency Versions'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
DEPENDENCY_MODEL_PATH='qml/models/MpvqcLibraryModel.qml'
execute python -m venv venv
execute source venv/Scripts/activate
execute python build-aux/generate-dependency-versions.py \
--pyproject-file pyproject.toml \
--optional-group dev \
insert \
--update-inplace "$DEPENDENCY_MODEL_PATH"
execute cat "$DEPENDENCY_MODEL_PATH"
- name: 'Run Python Build'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/Scripts/activate
execute just test-python
execute just clean
execute just build
- name: 'Lint Python Files'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/Scripts/activate
execute just lint-python
continue-on-error: true
- name: 'Upload Build Artifact'
uses: actions/upload-artifact@v4
with:
path: build/release
name: release-build-win
build_python_linux:
runs-on: ubuntu-24.04
name: 'Build Linux'
outputs:
version: ${{ steps.step_version.outputs.version }}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Remove Qml Test Files'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute find . -type f -name 'tst_*' -delete
- name: 'Install Python 3.12'
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 'Install just'
uses: taiki-e/install-action@just
- name: 'Download libmpv'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute sudo apt install -y libmpv2 patchelf libopengl0
- name: 'Set 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
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "mpvqc/startup.py"
execute cat "mpvqc/startup.py"
execute sed -i "s/$PLACEHOLDER_TAG/$CURRENT_TAG/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute sed -i "s/$PLACEHOLDER_COMMIT/$CURRENT_COMMIT/g" "qml/dialogs/about/MpvqcAboutView.qml"
execute cat "qml/dialogs/about/MpvqcAboutView.qml"
- 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 just install-dependencies
- name: 'Set Dependency Versions'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
DEPENDENCY_MODEL_PATH='qml/models/MpvqcLibraryModel.qml'
execute python -m venv venv
execute source venv/bin/activate
execute python build-aux/generate-dependency-versions.py \
--pyproject-file pyproject.toml \
--optional-group dev \
insert \
--update-inplace "$DEPENDENCY_MODEL_PATH"
execute cat "$DEPENDENCY_MODEL_PATH"
- 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: 'Lint Python Files'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/bin/activate
execute just lint-python
continue-on-error: true
- name: 'Upload Build Artifact'
uses: actions/upload-artifact@v4
with:
path: build/release
name: release-build-linux
test_qml:
runs-on: ubuntu-latest
name: 'Test Qml'
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Install Qt 6.7.2'
uses: jurplel/install-qt-action@v4
with:
version: '6.7.2'
- 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'
needs:
- build_python_win
- test_qml
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Install Python 3.12'
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 'Install just'
uses: taiki-e/install-action@just
- name: 'Remove Python sources'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute rm -rf mpvqc main.py
- name: 'Download Build Artifact'
uses: actions/download-artifact@v4
with:
name: release-build-win
path: .
- 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 just install-dependencies
execute python -m pip install nuitka
- name: 'Build Bundle'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute source venv/Scripts/activate
execute python.exe -m nuitka main.py \
--assume-yes-for-downloads \
--standalone \
--deployment \
--enable-plugin=pyside6 \
--output-dir=deployment \
--include-data-files=LICENSE=LICENSE \
--include-data-files=venv/Lib/site-packages/PySide6/translations/qtbase*.qm=PySide6/translations/ \
--windows-console-mode=attach \
--windows-icon-from-ico=build-aux/windows/icon.ico \
--include-qt-plugins=all \
--include-qt-plugins=qml \
--noinclude-qt-plugins=designer \
--noinclude-qt-plugins=multimedia \
--noinclude-qt-plugins=sqldrivers \
--noinclude-qt-translations \
--noinclude-dlls=opengl32sw.dll \
--noinclude-dlls=qt6designer.dll \
--noinclude-dlls=qt6pdf.dll \
--noinclude-dlls=qt6widgets.dll \
--noinclude-dlls=Qt6Charts* \
--noinclude-dlls=Qt6Quick3D* \
--noinclude-dlls=Qt6Sensors* \
--noinclude-dlls=Qt6Test* \
--noinclude-dlls=Qt6WebEngine* \
--noinclude-data-files=PySide6/QtWidgets.pyd \
--output-filename=mpvQC.exe
- name: 'Remove Redundant Binaries'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute find deployment/main.dist -type f -name 'QtWidgets.pyd' -delete
- name: 'Package libmpv'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
ARTIFACT="mpv-dev-x86_64-20240811-git-4e50da3.7z"
SHA1="37e1172f74cb7a3e443197fd1f7ad757ec164be6"
URL="https://sourceforge.net/projects/mpv-player-windows/files/libmpv/$ARTIFACT"
execute curl -L -O "$URL"
echo -e "\033[0;34mecho -n $SHA1 $ARTIFACT > $ARTIFACT.sha1\033[0m"
echo -n "$SHA1 $ARTIFACT" > "$ARTIFACT.sha1"
execute sha1sum --check "$ARTIFACT.sha1"
execute 7z x "$ARTIFACT"
execute mv libmpv-2.dll deployment/main.dist
- name: 'Make Application Portable'
run: |
function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
execute touch deployment/main.dist/portable
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: "${{ needs.build_python_win.outputs.version }}-win-x86_64"
path: "deployment/main.dist"