Skip to content

Commit

Permalink
Polish the AppImage build process
Browse files Browse the repository at this point in the history
  • Loading branch information
nemuelw committed Nov 25, 2024
1 parent 350b5a2 commit 40747c9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 40 deletions.
68 changes: 30 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,72 +20,64 @@ jobs:

- name: Install dependencies
run: |
pip3 install flake8
pip install flake8
- name: Run flake8
run: |
flake8 .
multiarch-build:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Install dependencies
run: |
sudo apt-get install -y desktop-file-utils
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker image
- name: Set clean version variable
run: |
docker build --platform linux/${{ matrix.arch }} -t protodesk .
- name: Run Docker image
VERSION=$(git describe --tags)
APP_VERSION=${VERSION#v}
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install project dependencies
run: |
docker run --name protodesk-container protodesk
pip install -r requirements.txt
- name: Copy build from container to host
- name: Build the app with Nuitka
run: |
docker cp protodesk-container:/app/protodesk .
nuitka --enable-plugin=pyside6 --include-data-dir=./assets=./assets --standalone --onefile --lto=yes --output-filename=protodesk app.py
- name: Prepare AppImage directory
- name: Prepare AppImage contents
run: |
mkdir -p app.AppDir/usr/bin
cp ./protodesk app.AppDir/usr/bin/
cp ./assets/logo.png app.AppDir/protodesk.png
cp protodesk app.AppDir/usr/bin/
cp assets/logo.png app.AppDir/protodesk.png
- name: Download AppImageTool for amd64
if: matrix.arch == 'amd64'
- name: Set up appimagetool
run: |
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
- name: Download AppImageTool for aarch64
if: matrix.arch == 'arm64'
run: |
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-aarch64.AppImage -O appimagetool
chmod +x appimagetool
- name: Install the desktop-file-utils dependency
run: |
sudo apt-get update && sudo apt-get install -y desktop-file-utils
- name: Build AppImage for amd64
- name: Build the AppImage
run: |
./appimagetool app.AppDir Protodesk-${{ matrix.arch }}.AppImage
echo "[+] Build successful on ${{ matrix.arch }}"
./appimagetool app.AppDir Protodesk-${APP_VERSION}-x86_64.AppImage
# - name: Upload release asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ github.event.release.upload_url}}
# asset_path: Protodesk-${{ matrix.arch }}.AppImage
# asset_name: Protodesk-${{ matrix.arch }}.AppImage
# asset_path: Protodesk-${{ env.APP_VERSION }}-${{ matrix.arch }}.AppImage
# asset_name: Protodesk-${{ env.APP_VERSION }}-${{ matrix.arch }}.AppImage
# asset_content_type: application/octet-stream
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ app.onefile-build/
protodesk
.DirIcon
*.AppImage
Dockerfile
27 changes: 25 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
FROM python:3.12-bullseye

ARG APP_VERSION
ARG ARCH
# ENV APP_VERSION=${APP_VERSION}
# ENV ARCH=${ARCH}

WORKDIR /app

RUN apt-get update && apt-get install -y patchelf
RUN apt-get update && apt-get install -y patchelf desktop-file-utils libfuse2

COPY . /app

# create and activate a virtual environment
RUN python -m venv .venv && chmod +x .venv/bin/activate && .venv/bin/activate

# install project dependencies
RUN pip3 install -r requirements.txt
RUN pip install -r requirements.txt

# build the app with Nuitka
RUN nuitka --enable-plugin=pyside6 --include-data-dir=./assets=./assets --standalone --onefile --lto=yes --output-filename=protodesk app.py

# prepare AppImage directory
RUN mkdir -p app.AppDir/usr/bin
RUN cp protodesk app.AppDir/usr/bin/
RUN cp assets/logo.png app.AppDir/protodesk.png

# set up appimagetool
RUN bash -c "\
if [ "$(uname -m)" == "x86_64" ]; then \
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool; \
elif [ "$(uname -m)" == "aarch64" ]; then \
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-aarch64.AppImage -O appimagetool; \
fi && \
chmod +x appimagetool \
"

# build the AppImage
RUN ./appimagetool app.AppDir Protodesk-${APP_VERSION}-${ARCH}.AppImage

0 comments on commit 40747c9

Please sign in to comment.