Skip to content

Commit

Permalink
Rework build scripts (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko authored Feb 8, 2025
1 parent 8d221ac commit 707d63f
Show file tree
Hide file tree
Showing 32 changed files with 1,021 additions and 1,067 deletions.
88 changes: 25 additions & 63 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,45 @@ name: Build & Test
on: push

jobs:
PyTest:
runs-on: ubuntu-24.04
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.3"
- uses: actions/checkout@v4
- name: Set up poetry environment
run: poetry install --without extras
- name: Run pytest
run: poetry run pytest

BuildExe:
build_exe:
name: Windows portable build
runs-on: windows-latest
steps:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.7.2
- uses: actions/setup-python@v5
- uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.3"
python-version: 3.12.8
- name: Install Just
run: choco install -y just
- uses: actions/checkout@v4
- name: Set up poetry environment
run: poetry install
- name: Change in-app version
run: python3 ./scripts/bump_version.py git
- name: Run build script
run: .\scripts/build_win32\make.cmd
- name: Upload installer
uses: actions/upload-artifact@v4
with:
name: openfreebuds_test_win32
path: .\scripts\build_win32\dist\*_win32.exe
if-no-files-found: error
- run: just prepare
- run: just --evaluate
- run: just bump_version_git build win32_portable
- name: Upload portable
uses: actions/upload-artifact@v4
with:
name: openfreebuds_test_win32_portable
path: .\scripts\build_win32\dist\*_win32_portable.exe
name: openfreebuds_win32
path: .\dist\*
if-no-files-found: error

BuildDeb:
build_deb:
name: Run PyTest and build Debian package
runs-on: ubuntu-24.04
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.3"
- uses: actions/checkout@v4
- name: Install dev-dependencies
run: |
sudo apt update
sudo apt install -y build-essential
sudo ./scripts/install_dpkg_dependencies.sh
- name: Set up poetry environment
run: poetry install
- name: Change in-app version
run: python3 ./scripts/bump_version.py git
- name: Build
run: dpkg-buildpackage -b
- name: Move release to dist dir
run: mv ../*.deb ./dist
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.13
cache: true
- name: Install Just
run: curl -s https://just.systems/install.sh | sudo bash -s -- --to /usr/local/bin
- name: Install project dependencies
run: just deps_debian prepare
- run: just --evaluate
- run: just test
- run: just bump_version_git build debian
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: openfreebuds_test_debian
name: openfreebuds_debian
path: ./dist/*
if-no-files-found: error
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
*.swp
*#

/test.py
/build
/builddir
/.idea
/.flatpak
/.flatpak-pip-generator
/.vagrant
/.pdm-python
/dist
/scripts/tools
/release.json
/accent.json

# Portable mode data
/data
/is_portable

/.idea
96 changes: 46 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,75 +54,71 @@ May also work with newer/older devices in same series. If you want to get better
Download & install
-----------------

[![Download for Windows](./docs/img/windows.png)](https://mmk.pw/en/openfreebuds/)
[![Available in FlatHub](./docs/img/flathub.png)](https://flathub.org/apps/pw.mmk.OpenFreebuds)

#### Scoop (Windows)

```powershell
scoop bucket add extras
scoop install openfreebuds
```

#### Debian/Ubuntu

```shell
curl -s https://deb.mmk.pw/setup | sudo bash -
sudo apt install openfreebuds
```
Common installation options:

#### Arch Linux
[![Download for Windows](./docs/img/windows.png)](https://mmk.pw/en/openfreebuds/download/)
[![Available in FlatHub](./docs/img/flathub.png)](https://flathub.org/apps/pw.mmk.OpenFreebuds)

`openfreebuds` [available in AUR](https://aur.archlinux.org/packages/openfreebuds).
All installation options:

#### Test builds
| Platform | Package manager | Command/Linux |
|---|---|---|
| ![](./docs/img/i_win32.png) Windows | Direct install | [Website](https://mmk.pw/en/openfreebuds/download) or [releases](./releases)|
| ![](./docs/img/i_win32.png) Windows | [Winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) (preinstalled) | <pre>winget install MelianMiko.OpenFreebuds</pre> |
| ![](./docs/img/i_win32.png) Windows | [Scoop](https://scoop.sh/) | <pre>scoop bucket add extras<br/>scoop install openfreebuds</pre> |
| ![](./docs/img/i_linux.png) Any linux | [Available at Flathub](https://flathub.org/apps/pw.mmk.OpenFreebuds) | <pre>flatpak install pw.mmk.OpenFreebuds</pre> |
| ![](./docs/img/i_debian.png) Debian/Ubuntu | APT | <pre>curl -s https://deb.mmk.pw/setup \| sudo bash -<br/>sudo apt install openfreebuds</pre> |
| ![](./docs/img/i_arch.png) ArchLinux | [Yay](https://github.com/Jguer/yay) for AUR | <pre>yay -S openfreebuds</pre> |

Most recent `dev`-binaries can be found in [GitHub Actions](https://github.com/melianmiko/OpenFreebuds/actions/workflows/on_push.yml) build artifacts.
Most recent `dev`-binaries can be found as [GitHub Actions](https://github.com/melianmiko/OpenFreebuds/actions/workflows/on_push.yml) build artifacts.

Build or start from sources
Build from sources
-------------

### Manual build

Requirements:

- Windows 10/11, or enough modern Linux;
- Qt 6.0+ development tools, at least Linguist's `lrelease`;
- [Python](https://www.python.org/downloads/) (3.11+), [Poetry](https://python-poetry.org/docs/#installation) (1.8+);
- Qt 6.0+ development tools, at least Linguist's `lrelease` (under Windows, will be used auto-obtained from `PySide6`;
- [Just](https://github.com/casey/just)
- [Python](https://www.python.org/downloads/) (3.11+), [PDM](https://pdm-project.org/en/latest/);
- (Windows, optional) [NSIS](https://nsis.sourceforge.io/Download), [UPX](https://upx.github.io/);
- (Linux, optional) Build essentials and some libraries.

Also, some dev-scripts may have their own requirements, like `python3-polib` for
`./scripts/sync_translations.sh`. Setup poetry env and dependencies before
continue:

```shell
poetry install
```

### Just launch without installation
- (Debian/Ubuntu, optional) For Debian packaging, some native libs (command: `just deps_debian`).

```shell
./scripts/make.py build_launch
```
<details>
<summary>Get all dependencies for Windows</summary>
<pre>
winget install -e --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.12
powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | python -"
# Only for Python 3.13+
# winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
</pre>
</details>

### Windows
When dependencies listed above are resolved, parepare project environment and build Python
wheel by running: `just prepare build`.

If everything above is installed & added to `PATH`, just run:
Now, you can try launching OpenFreebuds by `just start` command or package it via:

```shell
.\scripts\build_win32\make.cmd
```
- `just win32` for Windows portable and installer;
- `just debian` for Debian `deb`-package;
- `just flatpak` for Flatpak bundle (will also automatically install application).

Output binaries will be located in `scripts\build_win32\dist`
### VM-based build (Vagrant)

### Debian/Ubuntu
> [!WARNING]
> This build method will require a machine with at least 16 GB of RAM and fast internet conneciton.
Install all packaging dependencies automated way:
`apt install build-essentials && ./scripts/install_dpkg_dependencies.sh`.
Install [Vagrant](https://developer.hashicorp.com/vagrant/install?product_intent=vagrant) and any
suitable hypervisor, I'm using VMware. Then just `vagrant up` in project root, it will automatically
deply Debian 12 & Windows 11 machines that will build OpenFreebuds in (mostly) all packages.

```shell
dpkg-buildpackage -b
```
Don't forgot to `vagrant halt` after finish, to free CPU/RAM usage.

Output file will be located in parent folder (`../*.deb`).
---

![Extra dialogs preview](docs/preview_2.png)
130 changes: 130 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
Vagrant.configure("2") do |config|
config.vm.define "debian", primary: true do |debian|
debian.vm.box = "generic/debian12"
debian.vm.synced_folder ".", "/home/vagrant/openfreebuds"

debian.vm.provision "shell",
run: 'once',
name: "Prepare base dependencies (Python, Just, PDM)",
privileged: true,
inline: <<-SHELL
apt update
apt install -y --no-install-recommends pipx curl flatpak python-is-python3 python3-venv
# Install qasync (not in Debian repos, required for packaging as runtime dep)
# Since Debian 13, will be in main repo
curl -s -o /tmp/qasync.deb https://deb.mmk.pw/pool/main/q/qasync/python3-qasync_0.27.1-4_all.deb
apt install -y --no-install-recommends /tmp/qasync.deb
rm /tmp/qasync.deb
# Install Just
# Since Debian 13, will be in main repo
if [ ! -f /usr/local/bin/just ]
then
curl -s https://just.systems/install.sh | bash -s -- --to /usr/local/bin
fi
# 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 -
fi
SHELL

debian.vm.provision "shell",
run: 'always',
name: "Install project dependencies",
privileged: false,
inline: <<-SHELL
cd ~/openfreebuds
just deps_debian prepare
SHELL

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

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 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

win.vm.provision "shell",
run: 'once',
name: "Prepare base dependencies (Just, Python, VSBuildTools, NSIS, UPX)",
privileged: true,
inline: <<-SHELL
powercfg.exe -x -standby-timeout-ac 0
powercfg.exe -x -standby-timeout-dc 0
powercfg.exe -x -hibernate-timeout-ac 0
powercfg.exe -x -hibernate-timeout-dc 0
if (-Not (Get-Command 'winget' -errorAction SilentlyContinue)) {
echo 'Sleep for 60s for winget appear...'; Start-Sleep -s 60
}
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.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",
run: 'once',
name: "Prepare PDM",
privileged: true,
inline: <<-SHELL
powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | python -"
SHELL

win.vm.provision "shell",
run: 'once',
name: "Prepare project dependencies",
privileged: true,
inline: <<-SHELL
cd C:\\openfreebuds
just prepare
SHELL

win.vm.provision "shell",
run: 'once',
name: "Build project",
privileged: true,
inline: <<-SHELL
cd C:\\openfreebuds
just --evaluate
just build win32
SHELL
end
end
Loading

0 comments on commit 707d63f

Please sign in to comment.