Skip to content

Commit be54304

Browse files
committed
refactored project.
* now lekhika supports suggestion based on trained words. * created separate trainer app for learn from text files. user can set auto training with commited words.
1 parent dfa20cf commit be54304

24 files changed

+2855
-1122
lines changed

.editorconfig

Whitespace-only changes.

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# .github/workflows/build.yml
2+
name: Build & Test
3+
4+
on:
5+
push:
6+
branches: [ main, develop ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
linux:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
cc: [gcc, clang]
16+
build_type: [Debug, Release]
17+
runs-on: ubuntu-latest
18+
env:
19+
CC: ${{ matrix.cc }}
20+
CXX: ${{ matrix.cc == 'gcc' && 'g++' || 'clang++' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install distro dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y \
28+
cmake ninja-build extra-cmake-modules \
29+
libfcitx5core-dev libfcitx5utils-dev libfcitx5config-dev \
30+
libsqlite3-dev qt6-base-dev qt6-base-dev-tools libicu-dev \
31+
gettext appstream
32+
33+
- name: Configure
34+
run: |
35+
cmake -B build -G Ninja \
36+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
37+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
38+
39+
- name: Build
40+
run: cmake --build build
41+
42+
- name: Test (CTest)
43+
run: |
44+
cd build
45+
ctest --output-on-failure || true # add real tests later
46+
47+
- name: Upload build artefacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: linux-${{ matrix.cc }}-${{ matrix.build_type }}
51+
path: |
52+
build/*.so
53+
build/lekhika-trainer
54+
build/Testing/Temporary/LastTest.log

.github/workflows/main.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
source:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
tarball: ${{ steps.src.outputs.tarball }}
15+
version: ${{ steps.src.outputs.version }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- id: src
21+
run: |
22+
VER=${GITHUB_REF_NAME#v}
23+
TAR="fcitx5-lekhika-${VER}.tar.gz"
24+
git archive --format=tar.gz --prefix="fcitx5-lekhika-${VER}/" \
25+
-o "$TAR" "$GITHUB_REF_NAME"
26+
echo "tarball=$TAR" >> "$GITHUB_OUTPUT"
27+
echo "version=$VER" >> "$GITHUB_OUTPUT"
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: source-tarball
31+
path: ${{ steps.src.outputs.tarball }}
32+
33+
deb:
34+
needs: source
35+
runs-on: ${{ matrix.distro }}
36+
strategy:
37+
matrix:
38+
distro: [ubuntu-22.04, ubuntu-latest]
39+
steps:
40+
- name: install build-deps
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y --no-install-recommends \
44+
build-essential dpkg-dev debhelper devscripts \
45+
cmake ninja-build \
46+
libfcitx5core-dev libfcitx5utils-dev libfcitx5config-dev \
47+
libsqlite3-dev qt6-base-dev libicu-dev libgl-dev
48+
- uses: actions/checkout@v4
49+
- uses: actions/download-artifact@v4
50+
with:
51+
name: source-tarball
52+
- name: Build debian package
53+
run: |
54+
mkdir pkg && tar -xf *.tar.gz -C pkg --strip-components=1
55+
cd pkg
56+
mkdir -p debian
57+
# control file
58+
{
59+
echo 'Source: fcitx5-lekhika'
60+
echo 'Section: utils'
61+
echo 'Priority: optional'
62+
echo 'Maintainer: CI <[email protected]>'
63+
echo 'Build-Depends: debhelper-compat (= 13), cmake, ninja-build,'
64+
echo ' libfcitx5core-dev, libfcitx5utils-dev, libfcitx5config-dev,'
65+
echo ' libsqlite3-dev, qt6-base-dev, libicu-dev, libgl-dev'
66+
echo 'Standards-Version: 4.6.0'
67+
echo ''
68+
echo 'Package: fcitx5-lekhika'
69+
echo 'Architecture: any'
70+
echo 'Depends: ${shlibs:Depends}, ${misc:Depends}'
71+
echo 'Description: Lekhika input-method addon for Fcitx5'
72+
echo ''
73+
echo 'Package: lekhika-trainer'
74+
echo 'Architecture: any'
75+
echo 'Depends: ${shlibs:Depends}, ${misc:Depends}, libqt6widgets6t64 | libqt6widgets6'
76+
echo 'Description: GUI training tool for fcitx5-lekhika'
77+
} > debian/control
78+
# Create .install files to map build artifacts to packages
79+
{
80+
echo 'usr/lib/*/fcitx5/fcitx5lekhika.so'
81+
echo 'usr/share/fcitx5/addon/fcitx5lekhika.conf'
82+
echo 'usr/share/fcitx5/fcitx5-lekhika/*'
83+
echo 'usr/share/fcitx5/inputmethod/fcitx5lekhika.conf'
84+
echo 'usr/share/metainfo/fcitx5-lekhika.metainfo.xml'
85+
} > debian/fcitx5-lekhika.install
86+
{
87+
echo 'usr/bin/lekhika-trainer'
88+
echo 'usr/share/applications/lekhika-trainer.desktop'
89+
echo 'usr/share/icons/hicolor/*/apps/*'
90+
echo 'usr/share/metainfo/lekhika-trainer.metainfo.xml'
91+
} > debian/lekhika-trainer.install
92+
# rules file with real TABs, overriding the auto-test step
93+
printf '#!/usr/bin/make -f\n%%:\n\tdh $@ --buildsystem=cmake+ninja\noverride_dh_auto_configure:\n\tdh_auto_configure -- -DCMAKE_BUILD_TYPE=Release\noverride_dh_auto_test:\n' > debian/rules
94+
chmod +x debian/rules
95+
export [email protected] DEBFULLNAME="CI Bot"
96+
VER=$(cat version.txt)
97+
dch --create -v "${VER}-1" --package fcitx5-lekhika "CI build"
98+
dpkg-buildpackage -b -uc -us
99+
- name: Remove debug packages
100+
run: rm -f ./*.ddeb
101+
- name: Add t64 suffix for latest ubuntu build
102+
if: matrix.distro == 'ubuntu-latest'
103+
run: |
104+
# Rename all build artifacts with a _t64 suffix to avoid name collisions in the release.
105+
shopt -s nullglob
106+
for f in *.deb *.changes *.buildinfo; do
107+
new_name="${f%.*}_t64.${f##*.}"
108+
echo "Renaming $f to $new_name"
109+
mv -- "$f" "$new_name"
110+
done
111+
- uses: actions/upload-artifact@v4
112+
with:
113+
name: debian-packages-${{ matrix.distro }}
114+
path: |
115+
*deb
116+
*changes
117+
118+
rpm-fedora:
119+
needs: source
120+
runs-on: ubuntu-latest
121+
container: fedora:39
122+
steps:
123+
- run: |
124+
dnf install -y rpm-build cmake ninja-build gcc-c++ \
125+
fcitx5-devel qt6-qtbase-devel sqlite-devel libicu-devel
126+
- uses: actions/checkout@v4
127+
- uses: actions/download-artifact@v4
128+
with:
129+
name: source-tarball
130+
- run: |
131+
mkdir pkg && tar -xf *.tar.gz -C pkg --strip-components=1
132+
cd pkg
133+
VER=$(cat version.txt)
134+
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
135+
tar -czf ~/rpmbuild/SOURCES/fcitx5-lekhika-${VER}.tar.gz \
136+
--transform "s,^,fcitx5-lekhika-${VER}/," .
137+
{
138+
echo "Name: fcitx5-lekhika"
139+
echo "Version: ${VER}"
140+
echo "Release: 1%{?dist}"
141+
echo "Summary: Lekhika input method for Fcitx5"
142+
echo "License: GPL-3.0+"
143+
echo "Source0: %{name}-%{version}.tar.gz"
144+
echo "BuildRequires: cmake ninja-build gcc-c++ fcitx5-devel qt6-qtbase-devel sqlite-devel libicu-devel"
145+
echo "%description"
146+
echo "Lekhika input-method addon for Fcitx5"
147+
echo "%prep"
148+
echo "%autosetup"
149+
echo "%build"
150+
echo "%cmake -DCMAKE_BUILD_TYPE=Release"
151+
echo "%cmake_build"
152+
echo "%install"
153+
echo "%cmake_install"
154+
echo "%files"
155+
echo "%{_libdir}/fcitx5/*.so"
156+
echo "%{_bindir}/lekhika-trainer"
157+
echo "%{_datadir}/metainfo/*.xml"
158+
echo "%{_datadir}/fcitx5/*"
159+
echo "%{_datadir}/applications/*.desktop"
160+
echo "%{_datadir}/icons/hicolor/*/apps/lekhika.*"
161+
echo "%changelog"
162+
echo "* $(date +"%a %b %d %Y") CI <[email protected]> - ${VER}-1"
163+
echo "- Automated build"
164+
} > ~/rpmbuild/SPECS/fcitx5-lekhika.spec
165+
rpmbuild -bb ~/rpmbuild/SPECS/fcitx5-lekhika.spec
166+
- name: Remove debug packages
167+
run: rm -f ~/rpmbuild/RPMS/*/*-debug{info,source}-*.rpm
168+
- uses: actions/upload-artifact@v4
169+
with:
170+
name: fedora-rpms
171+
path: ~/rpmbuild/RPMS/*/*.rpm
172+
173+
arch:
174+
needs: source
175+
runs-on: ubuntu-latest
176+
container: archlinux:latest
177+
steps:
178+
- run: |
179+
pacman -Sy --noconfirm base-devel cmake ninja fcitx5-qt sqlite qt6-base icu
180+
- uses: actions/checkout@v4
181+
- uses: actions/download-artifact@v4
182+
with:
183+
name: source-tarball
184+
- run: |
185+
useradd -m builder
186+
mkdir arch_build
187+
mv *.tar.gz arch_build/
188+
chown -R builder:builder arch_build
189+
sudo -u builder \
190+
GITHUB_REPOSITORY=${{ github.repository }} \
191+
PKGVER=${{ needs.source.outputs.version }} \
192+
bash -c '
193+
set -e
194+
cd arch_build
195+
VER=$PKGVER
196+
{
197+
echo "pkgname=(fcitx5-lekhika lekhika-trainer)"
198+
echo "pkgver=${VER}"
199+
echo "pkgrel=1"
200+
echo "pkgdesc=\"Lekhika input method for Fcitx5\""
201+
echo "arch=(x86_64)"
202+
echo "url=\"https://github.com/${GITHUB_REPOSITORY}\""
203+
echo "license=(GPL3)"
204+
echo "options=(\"!debug\")"
205+
echo "depends=(fcitx5 qt6-base icu sqlite)"
206+
echo "makedepends=(cmake ninja)"
207+
echo "source=(fcitx5-lekhika-\${pkgver}.tar.gz)"
208+
echo "sha256sums=(\"SKIP\")"
209+
echo "build() {"
210+
echo " cd \"fcitx5-lekhika-\${pkgver}\""
211+
echo " cmake -B build -G Ninja \\"
212+
echo " -DCMAKE_BUILD_TYPE=Release \\"
213+
echo " -DCMAKE_INSTALL_PREFIX=/usr"
214+
echo " cmake --build build"
215+
echo "}"
216+
echo "package_fcitx5-lekhika() {"
217+
echo " cd \"fcitx5-lekhika-\${pkgver}\""
218+
echo " DESTDIR=\"\$pkgdir\" cmake --install build --component Runtime"
219+
echo "}"
220+
echo "package_lekhika-trainer() {"
221+
echo " cd \"fcitx5-lekhika-\${pkgver}\""
222+
echo " DESTDIR=\"\$pkgdir\" cmake --install build --component Trainer"
223+
echo "}"
224+
} > PKGBUILD
225+
makepkg -f
226+
'
227+
mv arch_build/*.pkg.tar.zst .
228+
- uses: actions/upload-artifact@v4
229+
with:
230+
name: arch-packages
231+
path: '*.pkg.tar.zst'
232+
233+
release:
234+
needs: [source, deb, rpm-fedora, arch]
235+
runs-on: ubuntu-latest
236+
steps:
237+
- uses: actions/checkout@v4
238+
with:
239+
fetch-depth: 0
240+
- uses: actions/download-artifact@v4
241+
- run: |
242+
mkdir release
243+
shopt -s nullglob globstar
244+
files_to_copy=(
245+
source-tarball/*
246+
debian-packages-*/*
247+
fedora-rpms/**/*.rpm
248+
arch-packages/*.pkg.tar.zst
249+
)
250+
if [ ${#files_to_copy[@]} -gt 0 ]; then
251+
cp -v "${files_to_copy[@]}" release/
252+
fi
253+
cd release
254+
if [ -n "$(ls -A .)" ]; then
255+
sha256sum * > SHA256SUMS.txt
256+
fi
257+
- name: changelog
258+
run: |
259+
PREV=$(git describe --tags --abbrev=0 HEAD~1 2/dev/null || true)
260+
if [ -n "$PREV" ]; then
261+
echo "### Changes since $PREV" > CHANGELOG.md
262+
git log --pretty=format:"- %s (%h)" "$PREV..HEAD" >> CHANGELOG.md
263+
else
264+
echo "### Initial release" > CHANGELOG.md
265+
fi
266+
- name: create GitHub release
267+
uses: softprops/action-gh-release@v1
268+
with:
269+
files: release/*
270+
body_path: CHANGELOG.md
271+
draft: false
272+
prerelease: false
273+

0 commit comments

Comments
 (0)