Skip to content

Commit

Permalink
[Refactor] Build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Feb 8, 2025
1 parent cf53295 commit 901846c
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 124 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: Build & Test
on: push

jobs:
BuildExe:
runs-on: windows-latest
build_exe:
name: Windows portable build
runs-on: windows-2025
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.13
python-version: 3.12.8
cache: true
- name: Install Just
run: choco install just
run: winget install -e --accept-source-agreements --no-upgrade --id Casey.Just
- run: just prepare
- run: just --evaluate
- run: just bump_version_git build win32_portable
Expand All @@ -22,7 +23,8 @@ jobs:
path: .\dist\*
if-no-files-found: error

TestAndBuildDebian:
build_deb:
name: Run PyTest and build Debian package
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -32,7 +34,10 @@ jobs:
cache: true
- name: Install Just
run: curl -s https://just.systems/install.sh | sudo bash -s -- --to /usr/local/bin
- run: just deps_debian prepare
- name: Install native project dependencies
run: sudo just deps_debian
- name: Install PDM dependencies
run: just prepare
- run: just --evaluate
- run: just test
- run: just bump_version_git build debian
Expand Down
38 changes: 24 additions & 14 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Vagrant.configure("2") do |config|

debian.vm.provision "shell",
run: 'once',
name: "Prepare base dependencies (Flatpak, Just, Poetry)",
name: "Prepare base dependencies (Python, Just, PDM)",
privileged: true,
inline: <<-SHELL
apt update
Expand All @@ -24,7 +24,7 @@ Vagrant.configure("2") do |config|
curl -s https://just.systems/install.sh | bash -s -- --to /usr/local/bin
fi
# Install Poetry for user
# Install PDM for user
if [ ! -f /home/vagrant/.local/bin/pdm ]
then
curl -sSL https://pdm-project.org/install-pdm.py | sudo -u vagrant python3 -
Expand All @@ -33,39 +33,48 @@ Vagrant.configure("2") do |config|

debian.vm.provision "shell",
run: 'always',
name: "Install Flatpak requirements",
name: "Install project dependencies",
privileged: false,
inline: <<-SHELL
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user org.flatpak.Builder
cd ~/openfreebuds
sudo just deps_debian
just prepare
SHELL

debian.vm.provision "shell",
run: 'always',
name: "Install project dependencies",
name: "Build binaries",
privileged: false,
inline: <<-SHELL
export FLATPAKBUILDDIR=$HOME/flatpak
cd ~/openfreebuds
just deps_debian prepare
just --evaluate
just build debian
SHELL

debian.vm.provision "shell",
run: 'always',
name: "Build binaries",
debian.vm.provision "shell",
run: 'once',
name: "Install Flatpak requirements and build Flatpak bundle",
privileged: false,
inline: <<-SHELL
export FLATPAKBUILDDIR=$HOME/flatpak
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user org.flatpak.Builder
cd ~/openfreebuds
just --evaluate
just build debian flatpak
just build flatpak
SHELL
end

config.vm.define "windows", primary: true do |win|
win.vm.box = "gusztavvargadr/windows-11-24h2-enterprise"
win.vm.synced_folder ".", "C:\\openfreebuds"
win.vm.provider "vmware_desktop" do |v|
v.vmx["numvcpus"] = "4"
v.vmx["memsize"] = "4096"
v.gui = true
end

Expand All @@ -86,8 +95,9 @@ Vagrant.configure("2") do |config|
winget install -e --accept-source-agreements --no-upgrade --id Casey.Just
winget install -e --no-upgrade --id NSIS.NSIS
winget install -e --no-upgrade --id UPX.UPX
winget install -e --no-upgrade --id Python.Python.3.13
winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
winget install -e --no-upgrade --id Python.Python.3.12
# Only for Python 3.13
# winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
SHELL

win.vm.provision "shell",
Expand Down
5 changes: 0 additions & 5 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ Priority: optional
Maintainer: MelianMiko <[email protected]>
Build-Depends: debhelper-compat (= 12),
build-essential,
python3-dev,
python3-pip,
libcairo2-dev,
gobject-introspection,
libgirepository1.0-dev,
qt6-l10n-tools,
fakeroot,
make,
git
Expand Down
30 changes: 22 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set windows-shell := ["powershell.exe", "-c"]
set script-interpreter := ["python"]

# Tools
pyside6_dir := `python -c "
pyside6_dir := `pdm run python -c "
import os
try:
import PySide6
Expand Down Expand Up @@ -65,6 +65,9 @@ test:
prepare:
pdm install

vg_all:
vagrant halt -f
vagrant up --parallel


# ------------------------------------------------
Expand Down Expand Up @@ -203,8 +206,19 @@ debian_full:
# Install build dependencies for Debian\Ubuntu
[linux]
deps_debian:
# TODO: Move inside Justfile
sudo bash ./scripts/install_dpkg_dependencies.sh
apt install -y --no-install-recommends \
build-essential \
python3-dbus-next \
python3-pyqt6 \
python3-pil \
python3-qasync \
python3-aiohttp \
python3-psutil \
python3-pip \
qt6-l10n-tools \
fakeroot \
make \
git



Expand All @@ -220,20 +234,20 @@ win32: win32_installer win32_portable
[windows]
win32_installer: win32_bundle
New-Item -ItemType Directory -Force -Path ./dist
cd ./scripts/build_win32; makensis openfreebuds.nsi
mv ./scripts/build_win32/dist/openfreebuds.install.exe ./dist/openfreebuds_{{version}}_win32.exe
cd ./scripts; & "C:\Program Files (x86)\NSIS\Bin\makensis.exe" openfreebuds.nsi
mv -Force ./scripts/dist/openfreebuds.install.exe ./dist/openfreebuds_{{version}}_win32.exe

# Make windows portable executable
[windows]
win32_portable:
New-Item -ItemType Directory -Force -Path ./dist
cd ./scripts/build_win32; & pdm run pyinstaller openfreebuds_portable.spec
mv ./scripts/build_win32/dist/openfreebuds_portable.exe ./dist/openfreebuds_{{version}}_win32_portable.exe
cd ./scripts; & pdm run pyinstaller -y openfreebuds_portable.spec
mv -Force ./scripts/dist/openfreebuds_portable.exe ./dist/openfreebuds_{{version}}_win32_portable.exe

# Prepare ./dist/ for win32 installer build
[windows,private]
win32_bundle:
cd ./scripts/build_win32; pdm run pyinstaller openfreebuds.spec
cd ./scripts; pdm run pyinstaller -y openfreebuds.spec



Expand Down
79 changes: 73 additions & 6 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ dependencies = [
"qasync<1.0.0,>=0.27.1",
"pynput<2.0.0,>=1.7.7",
"pyqt6<7.0.0,>=6.7.1",
"dbus-next<1.0.0,>=0.2.3",
"winsdk==1.0.0b10; sys_platform == 'win32'",
"dbus-next<1.0.0,>=0.2.3; sys_platform == 'linux'",
]

[dependency-groups]
dev = [
"pytest<9.0.0,>=8.3.2",
"pytest-asyncio<1.0.0,>=0.24.0",
"pyinstaller==6.10.0; sys_platform == 'win32'",
# lrelease.exe provider
"pyside6>=6.8.2.1; sys_platform == 'win32'",
]
no_flatpak = [
"pyqt6<7.0.0,>=6.7.1",
Expand Down
2 changes: 2 additions & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
2 changes: 0 additions & 2 deletions scripts/build_win32/.gitignore

This file was deleted.

22 changes: 0 additions & 22 deletions scripts/build_win32/make.cmd

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/build_win32/make_portable.cmd

This file was deleted.

Loading

0 comments on commit 901846c

Please sign in to comment.