Skip to content

Commit

Permalink
Update GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Sep 15, 2024
1 parent 5b3a44b commit 7b908dd
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 51 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: On `push` actions
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:
runs-on: windows-latest
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
- name: Change in-app version
run: bash.exe -c "./scripts/bump_version.sh \"0.99.git.$(git rev-parse HEAD)\""
- name: Run build script
run: .\scripts/build_win32\make.cmd
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: Win32 installer
path: .\scripts\build_win32\dist\openfreebuds_install.exe
if-no-files-found: error

BuildDeb:
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 install -y build-essential
sudo ./scripts/install_dpkg_dependencies.sh
- name: Set up poetry environment
run: poetry install
- name: Change in-app version
run: bash ./scripts/bump_version.sh "0.99.git.$(git rev-parse HEAD)"
- name: Run build script
run: bash ./scripts/build_debian/build.sh
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: Debian package
path: ./scripts/build_debian/openfreebuds_*.deb
if-no-files-found: error
50 changes: 12 additions & 38 deletions openfreebuds_backend/linux/ui_gtk.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,19 @@
import logging

import gi

gi.require_version("Gtk", "3.0")

log = logging.getLogger("OfbLinuxBackend")


# noinspection PyPackageRequirements
def ask_string(message, callback):
from gi.repository import GLib, Gtk

# noinspection PyArgumentList,PyUnresolvedReferences
def show_async():
# noinspection PyTypeChecker
dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK_CANCEL, "OpenFreebuds")
dialog.format_secondary_text(message)

area = dialog.get_content_area()
entry = Gtk.Entry()
entry.set_margin_start(16)
entry.set_margin_end(16)
area.pack_end(entry, False, False, 0)
dialog.show_all()

response = dialog.run()
text = entry.get_text()
dialog.destroy()

if response != Gtk.ResponseType.OK:
text = None

callback(text)

GLib.idle_add(show_async)


def is_dark_taskbar():
from gi.repository import Gtk
settings = Gtk.Settings()
defaults = settings.get_default()
theme_name = defaults.get_property("gtk-theme-name")
log.info(f"System theme name is {theme_name}")
return "Dark" in theme_name
try:
import gi
gi.require_version("Gtk", "3.0")

from gi.repository import Gtk
settings = Gtk.Settings()
defaults = settings.get_default()
theme_name = defaults.get_property("gtk-theme-name")
log.info(f"System theme name is {theme_name}")
return "Dark" in theme_name
except ImportError:
return False
2 changes: 1 addition & 1 deletion poetry.lock

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

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ openfreebuds_cmd = 'openfreebuds_cmd:main'
[tool.poetry.dependencies]
python = ">=3.10,<3.13"
pillow = "^10.4.0"
aiocmd = ">=0.1.5,<0.2.0"
psutil = "^6.0.0"
aiohttp = "^3.10.5"
pyinstaller = "6.10.0"
pygobject = { version = "^3.48.1", platform = "linux" }
winsdk = { version = "1.0.0b10", platform = "win32" }
pyqt6 = "^6.7.1"
qasync = "^0.27.1"
sdbus = { version = "^0.12.0", platform = "linux" }
pynput = "^1.7.7"

[tool.poetry.group.goodies.dependencies]
[tool.poetry.group.release.dependencies]
pyinstaller = "6.10.0"

[tool.poetry.group.extras.dependencies]
aiocmd = ">=0.1.5,<0.2.0"
pynput = ">=1.7.6,<1.8.0"
pygobject = { version = "^3.48.1", platform = "linux" }

[tool.poetry.group.test.dependencies]
pytest = "^8.3.2"
Expand Down
6 changes: 3 additions & 3 deletions scripts/build_debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ DIST_PACKAGES_PATH := /usr/lib/python3/dist-packages
WHEEL_FILE := $(shell find ${PWD} -maxdepth 1 -name '*.whl')

all:
cd ../.. && pyuic6 openfreebuds_qt/designer
cd ../.. && /usr/lib/qt6/bin/lrelease openfreebuds_qt/assets//i18n
bash ../make_qt_parts.sh
cd ../.. && poetry build
cp ../../dist/openfreebuds* .

install:
pip install --no-dependencies --target="${DESTDIR}${DIST_PACKAGES_PATH}" ${WHEEL_FILE}
pip install --upgrade --no-dependencies --target="${DESTDIR}${DIST_PACKAGES_PATH}" ${WHEEL_FILE}
mkdir -p ${DESTDIR}/usr/bin
mv ${DESTDIR}${DIST_PACKAGES_PATH}/bin/* ${DESTDIR}/usr/bin/
sed -i '1 s/^.*$$/\#\!\/usr\/bin\/env python3/' ${DESTDIR}/usr/bin/*
rm -rf ${DESTDIR}${DIST_PACKAGES_PATH}/bin
mkdir -p ${DESTDIR}/usr/share/applications
cp ../openfreebuds.desktop ${DESTDIR}/usr/share/applications
Expand Down
3 changes: 3 additions & 0 deletions scripts/build_debian/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

dpkg-buildpackage -S
dpkg-buildpackage -b

Expand Down
6 changes: 3 additions & 3 deletions scripts/build_debian/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Priority: optional
Maintainer: MelianMiko <[email protected]>
Build-Depends: debhelper-compat (= 12),
python3 (>= 3.11), python3-pip, pyqt6-dev-tools,
make
libcairo2-dev, gobject-introspection, libgirepository1.0-dev,
qt6-l10n-tools, make
Standards-Version: 4.4.1
Homepage: https://github.com/melianmiko/OpenFreebuds

Package: openfreebuds
Architecture: all
Depends:
${misc:Depends}, python3 (>= 3.11),
python3-gi, python3-sdbus, python3-pyqt6, python3-pil, python3-qasync, python3-aiohttp,
libgtk-3-0
python3-sdbus, python3-pyqt6, python3-pil, python3-qasync, python3-aiohttp
Description:
Open-source client application for HUAWEI FreeBuds bluetooth headset series.
.
Expand Down
5 changes: 3 additions & 2 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ cd "$(dirname "$0")"/..
source scripts/constants.sh

# Bump python wheel version
sed -i "s/version =.*/version = \"$1\"/g" pyproject.toml
VERSION_SHORT=`echo $1 | cut -d . -f -2`
sed -i "s/^version =.*/version = \"$VERSION_SHORT\"/g" pyproject.toml

# Create ./openfreebuds_qt/version_info.py
echo "VERSION = '$1'" > ./openfreebuds_qt/version_info.py
echo "LIBRARIES = [" >> ./openfreebuds_qt/version_info.py
poetry export --without-hashes -n | while read line
poetry export --without-hashes -n --with extras | while read line
do
echo " '$line'," >> ./openfreebuds_qt/version_info.py
done
Expand Down
18 changes: 18 additions & 0 deletions scripts/install_dpkg_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

apt install -y $(awk '
/^(Build-)?Depends:/ || /^ / && deps {
sub(/^[^ ]+: /, "")
deps = 1
dep_str = dep_str ", " $0
next
}
{ deps=0 }
END {
split(dep_str, dep_array, /[,|] */)
for (d in dep_array) {
dep = dep_array[d]
gsub(/[^a-z0-9_.+-].*$/, "", dep)
if (dep && !seen[dep]++) print dep
}
}' scripts/build_debian/debian/control)

0 comments on commit 7b908dd

Please sign in to comment.