Skip to content

Commit

Permalink
Github action for CHIRP building
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Jan 2, 2024
1 parent 44fd5c6 commit 372c7a8
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 0 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
on:
push:

env:
CHIRP_DIR: ${{github.workspace}}\temp\chirp
BASH: C:\tools\cygwin\bin\bash

jobs:
build:
runs-on: windows-latest

steps:

- name: "Checkout repository"
uses: actions/checkout@v3

- name: "Install MSVC"
uses: ilammy/msvc-dev-cmd@v1

- name: "Install Python"
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: 'chirp\requirements-dev.txt'

- name: "Instal Python packages"
run: pip install -r chirp\requirements-dev.txt

- name: "Download PyInstaller"
uses: robinraju/release-downloader@v1.8
with:
repository: "pyinstaller/pyinstaller"
latest: true
zipBall: true
out-file-path: "temp"
extract: true

- name: "Build PyInstaller"
run: >
cd temp\pyinstaller-pyinstaller-*\bootloader &&
python.exe ./waf all --target-arch=64bit &&
cd ..
&& pip install .
- name: "Install Cygwin"
uses: egor-tensin/setup-cygwin@v4
with:
packages: make gettext

- name: "Prepare CHIRP repository"
run: >
New-Item -ItemType Directory -Force -Path temp &&
cd temp &&
git clone https://github.com/kk7ds/chirp.git &&
Copy-Item -Path "${{github.workspace}}\chirp\Makefile" -Destination "${{env.CHIRP_DIR}}\chirp\locale\" -Force &&
Copy-Item -Path "${{github.workspace}}\chirp\chirp.patch" -Destination "${{env.CHIRP_DIR}}\" -Force &&
Copy-Item -Path "${{github.workspace}}\uvk5_egzumer.py" -Destination "${{env.CHIRP_DIR}}\chirp\drivers\" -Force &&
cd chirp &&
git apply chirp.patch;
if ("${{github.ref}}" -like "refs/tags/v*") {
$content = Get-Content -Path "chirp\__init__.py" -Raw;
$content = $content -replace 'CHIRP_VERSION = "py3dev"', "CHIRP_VERSION = `"${{github.ref_name}}`"";
Set-Content -Path "chirp\__init__.py" -Value $content;
}
- name: "Build CHIRP locale"
run: >
${{env.BASH}} --login -c "cd '${{env.CHIRP_DIR}}\chirp\locale'; make" &&
${{env.BASH}} --login -c "cd '${{env.CHIRP_DIR}}'; find chirp/locale/ -maxdepth 1 -type f -delete"
- name: "Build CHIRP"
run: >
cd "${{env.CHIRP_DIR}}" &&
pyinstaller
--noconfirm
--onefile
--windowed
--icon "chirp/share/chirp.ico"
--name "CHIRP_egzumer"
--hidden-import "wx"
--hidden-import "wx._xml"
--hidden-import "importlib-resources"
--add-data "chirp/share;chirp/share/"
--add-data "chirp/stock_configs;chirp/stock_configs/"
--add-data "chirp/locale;chirp/locale/"
--add-data "chirp/drivers;chirp/drivers/"
"chirpwx.py";
- name: 'Upload exe Artifact'
uses: actions/upload-artifact@v3
with:
name: CHIRP_egzumer
path: ${{env.CHIRP_DIR}}\dist\CHIRP_egzumer.exe

- name: Upload onefile to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{env.CHIRP_DIR}}\dist\CHIRP_egzumer.exe
asset_name: CHIRP_egzumer.exe
tag: ${{ github.ref }}
overwrite: true
release_name: release ${{ github.ref_name }}
32 changes: 32 additions & 0 deletions chirp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
POFILES = $(shell ls *.po)
MOFILES = $(patsubst %.po,%/LC_MESSAGES/CHIRP.mo,$(POFILES))
SHELL = bash

COPY="Dan Smith <chirp@f.danplanet.com>"
PKG=CHIRP
XGT_OPTS=--copyright-holder=$(COPY) --package-name=$(PKG)

.PHONY: all

all: chirpui.pot $(MOFILES)

clean:
rm -f $(MOFILES) *~ *.orig chirpui.pot
find . -name '*.mo' -exec rm -f "{}" \;
find * -depth -type d -exec rmdir "{}" \;

chirpui.pot:
find .. -name '*.py' > file_list.txt
xgettext -s -L Python -k_ -o chirpui.pot --from-code=iso-8859-15 -f file_list.txt $(XGT_OPTS)
rm file_list.txt

%.po: chirpui.pot
if [ -f $@ ]; then \
msgmerge -sU $@ chirpui.pot; \
else \
msginit --input=chirpui.pot --locale=$(@:%.po=%); \
fi

%/LC_MESSAGES/CHIRP.mo: %.po
mkdir -p $(shell dirname $@)
msgfmt --output-file=$@ $^
60 changes: 60 additions & 0 deletions chirp/chirp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py
index bc599144..a1381603 100644
--- a/chirp/wxui/main.py
+++ b/chirp/wxui/main.py
@@ -506,7 +506,7 @@ class ChirpMain(wx.Frame):
return

def _detach(event):
- new = ChirpMain(None, title='CHIRP')
+ new = ChirpMain(None, title='CHIRP egzumer')
self._editors.RemovePage(selected)
eset.Reparent(new._editors)
new.add_editorset(eset)
@@ -1094,9 +1094,9 @@ class ChirpMain(wx.Frame):
is_memedit = isinstance(eset.current_editor, memedit.ChirpMemEdit)
is_bank = isinstance(eset.current_editor, bankedit.ChirpBankEdit)
can_edit = not is_network
- self.SetTitle('CHIRP (%s)' % os.path.basename(eset.filename))
+ self.SetTitle('CHIRP egzumer (%s)' % os.path.basename(eset.filename))
else:
- self.SetTitle('CHIRP')
+ self.SetTitle('CHIRP egzumer')

if self.current_editorset:
radio = self.current_editorset.radio
@@ -1640,7 +1640,7 @@ class ChirpMain(wx.Frame):

def _menu_about(self, event):
pyver = sys.version_info
- aboutinfo = 'CHIRP %s on Python %s wxPython %s' % (
+ aboutinfo = 'CHIRP egzumer %s\non Python %s\nwxPython %s' % (
CHIRP_VERSION,
'%s.%s.%s' % (pyver.major, pyver.minor, pyver.micro),
wx.version())
@@ -1768,8 +1768,8 @@ def display_update_notice(version):

CONF.set_int("last_update_check", int(time.time()), "state")

- url = 'https://chirp.danplanet.com/projects/chirp/wiki/ChirpNextBuild'
- msg = _('A new CHIRP version is available. Please visit the '
+ url = 'https://github.com/egzumer/uvk5-chirp-driver/releases'
+ msg = _('A new CHIRP egzumer version is available. Please visit the '
'website as soon as possible to download it!')
d = wx.MessageDialog(None, msg, _('New version available'),
style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
diff --git a/chirp/wxui/report.py b/chirp/wxui/report.py
index d2ca7711..d0e4dfc0 100644
--- a/chirp/wxui/report.py
+++ b/chirp/wxui/report.py
@@ -102,8 +102,8 @@ def with_session(fn):

@with_session
def check_for_updates(session, callback):
- r = session.get('%s/latest' % BASE)
- callback(r.json()['latest'])
+ r = session.get("https://api.github.com/repos/egzumer/uvk5-chirp-driver/releases/latest")
+ callback(r.json()['tag_name'])


@with_session
9 changes: 9 additions & 0 deletions chirp/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
future
six
wxPython
pypiwin32
pyserial
requests
yattag
wheel
importlib-resources

0 comments on commit 372c7a8

Please sign in to comment.