Mulberry/.github/workflows/build.yml

167 lines
7.5 KiB
YAML

name: Build
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller
- name: Version
shell: bash
run: echo "VERSION=$(python -c "import re;print(re.search(r'VERSION = \"(.+?)\"', open('mulberry/config.py').read()).group(1))")" >> $GITHUB_ENV
- name: Icons
run: python packaging/make_icons.py
- name: Fetch libmpv (gapless, EQ, CD playback & ripping)
continue-on-error: true
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$rel = Invoke-RestMethod "https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest" -Headers @{ Authorization = "Bearer $env:GH_TOKEN" }
$asset = $rel.assets | Where-Object { $_.name -match '^mpv-dev-x86_64-\d{8}-git-[0-9a-f]+\.7z$' } | Select-Object -First 1
if (-not $asset) { throw "libmpv asset not found" }
Invoke-WebRequest $asset.browser_download_url -OutFile mpv-dev.7z
7z x mpv-dev.7z -ompv-dev -y | Out-Null
New-Item -ItemType Directory -Force packaging/windows/mpv | Out-Null
Copy-Item mpv-dev/libmpv-2.dll packaging/windows/mpv/
Get-ChildItem packaging/windows/mpv
- name: PyInstaller
run: pyinstaller packaging/mulberry.spec --noconfirm --distpath build/dist --workpath build/work
- name: Self-test (launch the built app, screenshot, quit)
shell: pwsh
run: |
$env:MULBERRY_SELFTEST = "$PWD\selftest-windows"
$p = Start-Process build/dist/Mulberry/Mulberry.exe -PassThru
if (-not $p.WaitForExit(90000)) { Stop-Process $p.Id; throw "Mulberry did not finish the self-test" }
if (-not (Test-Path selftest-windows.png)) { Write-Output "::error title=Windows self-test::no screenshot"; throw "no screenshot - the app failed to start" }
Get-Content selftest-windows.txt
- uses: actions/upload-artifact@v4
with:
name: selftest-windows
path: selftest-windows.*
- name: Portable zip
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
Compress-Archive -Path build/dist/Mulberry -DestinationPath "dist/Mulberry-Windows-Portable.zip"
- name: Installer (Inno Setup)
shell: pwsh
run: |
$iscc = "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe"
if (-not (Test-Path $iscc)) { choco install innosetup -y --no-progress; $iscc = "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" }
& $iscc "/DAppVersion=$env:VERSION" packaging\windows\mulberry.iss
- uses: actions/upload-artifact@v4
with:
name: windows
path: dist/*
linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: System packages
run: sudo apt-get update && sudo apt-get install -y libegl1 libxkbcommon0 libxcb-cursor0 desktop-file-utils file
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller
- name: Version
run: echo "VERSION=$(python -c "import re;print(re.search(r'VERSION = \"(.+?)\"', open('mulberry/config.py').read()).group(1))")" >> $GITHUB_ENV
- name: Icons
run: python packaging/make_icons.py
- name: PyInstaller
run: pyinstaller packaging/mulberry.spec --noconfirm --distpath build/dist --workpath build/work
- name: Self-test (launch the built app, screenshot, quit)
run: |
set +e
QT_QPA_PLATFORM=offscreen MULBERRY_SELFTEST=$PWD/selftest-linux timeout 90 dbus-run-session -- build/dist/Mulberry/mulberry > selftest-linux.log 2>&1
rc=$?
if [ ! -f selftest-linux.png ]; then
echo "::error title=Linux self-test failed (rc=$rc)::$(tail -c 3000 selftest-linux.log | tr '\n' '|')"
exit 1
fi
cat selftest-linux.txt
- uses: actions/upload-artifact@v4
with:
name: selftest-linux
path: selftest-linux.*
- name: Tarball
run: |
mkdir -p dist
cp mulberry.desktop mulberry/assets/mulberry.svg build/dist/Mulberry/
tar -C build/dist -czf "dist/Mulberry-Linux-x86_64.tar.gz" Mulberry
- name: AppImage
run: |
APPDIR=build/AppDir
mkdir -p $APPDIR/usr/lib $APPDIR/usr/share/icons/hicolor/256x256/apps $APPDIR/usr/share/applications
cp -r build/dist/Mulberry $APPDIR/usr/lib/mulberry
cp packaging/linux/AppRun $APPDIR/AppRun && chmod +x $APPDIR/AppRun
grep -v '^Actions=\|^\[Desktop Action\|^Name=Play\|^Name=Next\|^Name=Previous\|^Exec=dbus' mulberry.desktop > $APPDIR/mulberry.desktop
cp $APPDIR/mulberry.desktop $APPDIR/usr/share/applications/
cp packaging/build-icons/mulberry-256.png $APPDIR/mulberry.png
cp packaging/build-icons/mulberry-256.png $APPDIR/usr/share/icons/hicolor/256x256/apps/mulberry.png
wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
ARCH=x86_64 ./appimagetool --appimage-extract-and-run $APPDIR "dist/Mulberry-x86_64.AppImage"
- uses: actions/upload-artifact@v4
with:
name: linux
path: dist/*
release:
# Publishes on every push to main (tag v<VERSION> is created by the action),
# or when a v* tag is pushed. Same-named assets are replaced on re-runs.
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
needs: [windows, linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Version
run: echo "VERSION=$(python3 -c "import re;print(re.search(r'VERSION = \"(.+?)\"', open('mulberry/config.py').read()).group(1))")" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
path: artifacts
- uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
target_commitish: ${{ github.sha }}
name: Mulberry ${{ env.VERSION }}
make_latest: true
overwrite_files: true
files: |
artifacts/windows/*
artifacts/linux/*
body: |
## Downloads
| Platform | File |
|---|---|
| Windows 10/11 installer | **Mulberry-Windows-Setup.exe** |
| Windows portable | **Mulberry-Windows-Portable.zip** (unzip, run `Mulberry.exe`) |
| Linux, any distro | **Mulberry-x86_64.AppImage** (`chmod +x`, then run) |
| Linux tarball | **Mulberry-Linux-x86_64.tar.gz** (run `Mulberry/mulberry`) |
On Linux, install `mpv` for gapless playback, the EQ and CD support. The Windows build includes it.
Windows SmartScreen may warn because the installer is unsigned: choose *More info → Run anyway*.
See the [README](https://github.com/${{ github.repository }}#readme) for features and setup.
*Coded by Claude (Anthropic) with @BeamStarTech.*