This commit is contained in:
brontomark committed 2026-11-22 10:47:38 +01:00
1 parent 08aeaa3f42
commit 58b9a8543f
4 files changed
+205 -21

No files matched your search

+104 -20
View File
@@ -69,14 +69,49 @@ jobs:
} }
} }
- name: Upload Windows Installer Asset - name: Upload Windows Installer Asset su Gitea Release
uses: https://gitea.com/actions/release-action@main uses: https://gitea.com/actions/release-action@main
with: with:
files: "server/dist/installer/BarcodeServerSetup.exe" files: "server/dist/installer/BarcodeServerSetup.exe"
api_key: ${{ secrets.MYRELEASE_TOKEN }} api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Pubblica Windows Installer su apps.catelli.it
env:
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_USER: ${{ secrets.VPS_USER }}
VPS_PORT: ${{ secrets.VPS_PORT }}
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
VPS_APPS_DOWNLOADS_DIR: ${{ secrets.VPS_APPS_DOWNLOADS_DIR }}
run: |
if ([string]::IsNullOrWhiteSpace($env:VPS_SSH_KEY)) {
Write-Host "[!] Secret VPS_SSH_KEY non configurato: salto deploy su apps.catelli.it."
exit 0
}
$VpsHost = if ([string]::IsNullOrWhiteSpace($env:VPS_HOST)) { "vps.catelli.it" } else { $env:VPS_HOST }
$VpsUser = if ([string]::IsNullOrWhiteSpace($env:VPS_USER)) { "mark" } else { $env:VPS_USER }
$Port = if ([string]::IsNullOrWhiteSpace($env:VPS_PORT)) { "22" } else { $env:VPS_PORT }
$DestDir = if ([string]::IsNullOrWhiteSpace($env:VPS_APPS_DOWNLOADS_DIR)) { "/home/mark/caddy-docker/apps.catelli.it/downloads" } else { $env:VPS_APPS_DOWNLOADS_DIR.TrimEnd('/') }
$KeyFile = Join-Path $env:TEMP ("vps_deploy_key_" + [guid]::NewGuid().ToString("N"))
try {
$NormalizedKey = $env:VPS_SSH_KEY.Replace("`r`n", "`n").TrimEnd() + "`n"
[System.IO.File]::WriteAllText($KeyFile, $NormalizedKey, (New-Object System.Text.UTF8Encoding($false)))
& icacls $KeyFile /inheritance:r /grant:r "$($env:USERNAME):(R)" | Out-Null
$SshOpts = @("-i", $KeyFile, "-o", "StrictHostKeyChecking=accept-new", "-o", "BatchMode=yes")
& ssh.exe @SshOpts -p $Port "$VpsUser@$VpsHost" "mkdir -p '$DestDir' && chmod 755 '$DestDir'"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& scp.exe @SshOpts -P $Port "server\dist\installer\BarcodeServerSetup.exe" "$VpsUser@$VpsHost`:$DestDir/BarcodeServerSetup.exe.tmp"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& ssh.exe @SshOpts -p $Port "$VpsUser@$VpsHost" "chmod 644 '$DestDir/BarcodeServerSetup.exe.tmp' && mv -f '$DestDir/BarcodeServerSetup.exe.tmp' '$DestDir/BarcodeServerSetup.exe'"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
} finally {
if (Test-Path $KeyFile) { Remove-Item -Force $KeyFile }
}
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# JOB 2: LINUX APPIMAGE (.AppImage) # JOB 2: LINUX APPIMAGE (.AppImage via Docker Ubuntu 22.04)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
build-linux: build-linux:
runs-on: linux-runner runs-on: linux-runner
@@ -84,31 +119,53 @@ jobs:
- name: Checkout del codice - name: Checkout del codice
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Compila binario e AppDir PySide6 - name: Prepara immagine Docker (Ubuntu 22.04 / glibc compatibile)
run: |
docker build -t barcode-linux-builder -f docker/linux-appimage.Dockerfile .
- name: Build Server Linux e Genera AppImage nel container
run: | run: |
TagVersion="${GITHUB_REF_NAME#v}" TagVersion="${GITHUB_REF_NAME#v}"
python3 server/build_binary.py --onedir --windowed --appdir --version "$TagVersion" docker run --rm \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-e APP_VERSION="$TagVersion" \
-v "$PWD:/workspace" \
barcode-linux-builder
- name: Scarica appimagetool se non presente - name: Upload Linux AppImage Asset su Gitea Release
run: |
if [ ! -x /tmp/appimagetool-x86_64.AppImage ] || ! head -c 4 /tmp/appimagetool-x86_64.AppImage | grep -q "ELF"; then
rm -f /tmp/appimagetool-x86_64.AppImage
curl -fSL -o /tmp/appimagetool-x86_64.AppImage https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x /tmp/appimagetool-x86_64.AppImage
fi
- name: Genera AppImage
run: |
ARCH=x86_64 APPIMAGE_EXTRACT_AND_RUN=1 /tmp/appimagetool-x86_64.AppImage server/dist/BarcodeServer.AppDir BarcodeServer-x86_64.AppImage
chmod +x BarcodeServer-x86_64.AppImage
APPIMAGE_EXTRACT_AND_RUN=1 ./BarcodeServer-x86_64.AppImage --version
- name: Upload Linux AppImage Asset
uses: https://gitea.com/actions/release-action@main uses: https://gitea.com/actions/release-action@main
with: with:
files: "BarcodeServer-x86_64.AppImage" files: "BarcodeServer-x86_64.AppImage"
api_key: ${{ secrets.MYRELEASE_TOKEN }} api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Pubblica Linux AppImage su apps.catelli.it
env:
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_USER: ${{ secrets.VPS_USER }}
VPS_PORT: ${{ secrets.VPS_PORT }}
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
VPS_APPS_DOWNLOADS_DIR: ${{ secrets.VPS_APPS_DOWNLOADS_DIR }}
run: |
if [ -z "${VPS_SSH_KEY:-}" ]; then
echo "[!] Secret VPS_SSH_KEY non configurato: salto deploy su apps.catelli.it."
exit 0
fi
HOST="${VPS_HOST:-vps.catelli.it}"
USER="${VPS_USER:-mark}"
PORT="${VPS_PORT:-22}"
DEST_DIR="${VPS_APPS_DOWNLOADS_DIR:-/home/mark/caddy-docker/apps.catelli.it/downloads}"
DEST_DIR="${DEST_DIR%/}"
KEY_FILE="$(mktemp)"
trap 'rm -f "$KEY_FILE"' EXIT
printf '%s\n' "$VPS_SSH_KEY" > "$KEY_FILE"
chmod 600 "$KEY_FILE"
SSH_OPTS=(-i "$KEY_FILE" -o StrictHostKeyChecking=accept-new -o BatchMode=yes)
ssh "${SSH_OPTS[@]}" -p "$PORT" "${USER}@${HOST}" "mkdir -p '${DEST_DIR}' && chmod 755 '${DEST_DIR}'"
scp "${SSH_OPTS[@]}" -P "$PORT" "BarcodeServer-x86_64.AppImage" "${USER}@${HOST}:${DEST_DIR}/BarcodeServer-x86_64.AppImage.tmp"
ssh "${SSH_OPTS[@]}" -p "$PORT" "${USER}@${HOST}" "chmod 644 '${DEST_DIR}/BarcodeServer-x86_64.AppImage.tmp' && mv -f '${DEST_DIR}/BarcodeServer-x86_64.AppImage.tmp' '${DEST_DIR}/BarcodeServer-x86_64.AppImage'"
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# JOB 3: MACOS (.dmg e .zip per auto-update) # JOB 3: MACOS (.dmg e .zip per auto-update)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
@@ -129,7 +186,7 @@ jobs:
hdiutil create -volname "Barcode Reader Server" -srcfolder "server/dist/BarcodeServer.app" -ov -format UDZO "BarcodeServer-macOS.dmg" hdiutil create -volname "Barcode Reader Server" -srcfolder "server/dist/BarcodeServer.app" -ov -format UDZO "BarcodeServer-macOS.dmg"
ditto -c -k --sequesterRsrc --keepParent "server/dist/BarcodeServer.app" "BarcodeServer-macOS.zip" ditto -c -k --sequesterRsrc --keepParent "server/dist/BarcodeServer.app" "BarcodeServer-macOS.zip"
- name: Upload macOS Assets - name: Upload macOS Assets su Gitea Release
uses: https://gitea.com/actions/release-action@main uses: https://gitea.com/actions/release-action@main
with: with:
files: | files: |
@@ -137,3 +194,30 @@ jobs:
BarcodeServer-macOS.zip BarcodeServer-macOS.zip
api_key: ${{ secrets.MYRELEASE_TOKEN }} api_key: ${{ secrets.MYRELEASE_TOKEN }}
- name: Pubblica macOS DMG e ZIP su apps.catelli.it
env:
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_USER: ${{ secrets.VPS_USER }}
VPS_PORT: ${{ secrets.VPS_PORT }}
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
VPS_APPS_DOWNLOADS_DIR: ${{ secrets.VPS_APPS_DOWNLOADS_DIR }}
run: |
if [ -z "${VPS_SSH_KEY:-}" ]; then
echo "[!] Secret VPS_SSH_KEY non configurato: salto deploy su apps.catelli.it."
exit 0
fi
HOST="${VPS_HOST:-vps.catelli.it}"
USER="${VPS_USER:-mark}"
PORT="${VPS_PORT:-22}"
DEST_DIR="${VPS_APPS_DOWNLOADS_DIR:-/home/mark/caddy-docker/apps.catelli.it/downloads}"
DEST_DIR="${DEST_DIR%/}"
KEY_FILE="$(mktemp)"
trap 'rm -f "$KEY_FILE"' EXIT
printf '%s\n' "$VPS_SSH_KEY" > "$KEY_FILE"
chmod 600 "$KEY_FILE"
SSH_OPTS=(-i "$KEY_FILE" -o StrictHostKeyChecking=accept-new -o BatchMode=yes)
ssh "${SSH_OPTS[@]}" -p "$PORT" "${USER}@${HOST}" "mkdir -p '${DEST_DIR}' && chmod 755 '${DEST_DIR}'"
scp "${SSH_OPTS[@]}" -P "$PORT" "BarcodeServer-macOS.dmg" "${USER}@${HOST}:${DEST_DIR}/BarcodeServer-macOS.dmg.tmp"
scp "${SSH_OPTS[@]}" -P "$PORT" "BarcodeServer-macOS.zip" "${USER}@${HOST}:${DEST_DIR}/BarcodeServer-macOS.zip.tmp"
ssh "${SSH_OPTS[@]}" -p "$PORT" "${USER}@${HOST}" "chmod 644 '${DEST_DIR}/BarcodeServer-macOS.dmg.tmp' '${DEST_DIR}/BarcodeServer-macOS.zip.tmp' && mv -f '${DEST_DIR}/BarcodeServer-macOS.dmg.tmp' '${DEST_DIR}/BarcodeServer-macOS.dmg' && mv -f '${DEST_DIR}/BarcodeServer-macOS.zip.tmp' '${DEST_DIR}/BarcodeServer-macOS.zip'"
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
SRC_DIR="/tmp/barcode-src"
OUT_APPIMAGE="/workspace/BarcodeServer-x86_64.AppImage"
rm -rf "${SRC_DIR}"
mkdir -p "${SRC_DIR}/server"
tar -C /workspace/server \
--exclude='./venv' \
--exclude='./venv_unix' \
--exclude='./venv_win' \
--exclude='./build' \
--exclude='./dist' \
--exclude='./__pycache__' \
--exclude='./.DS_Store' \
-cf - . | tar -C "${SRC_DIR}/server" -xf -
cd "${SRC_DIR}"
BUILD_ARGS=(server/build_binary.py --onedir --windowed --appdir)
if [ -n "${APP_VERSION:-}" ]; then
BUILD_ARGS+=(--version "${APP_VERSION}")
fi
python "${BUILD_ARGS[@]}"
ARCH=x86_64 appimagetool \
"${SRC_DIR}/server/dist/BarcodeServer.AppDir" \
"${OUT_APPIMAGE}"
chmod +x "${OUT_APPIMAGE}"
APPIMAGE_EXTRACT_AND_RUN=1 "${OUT_APPIMAGE}" --version
if [ -n "${HOST_UID:-}" ] && [ -n "${HOST_GID:-}" ]; then
chown "${HOST_UID}:${HOST_GID}" "${OUT_APPIMAGE}"
fi
+62
View File
@@ -0,0 +1,62 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
binutils \
ca-certificates \
curl \
file \
libdbus-1-3 \
libegl1 \
libfontconfig1 \
libgl1 \
libglib2.0-0 \
libx11-6 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-xinerama0 \
libxcb-xkb1 \
libxkbcommon0 \
libxkbcommon-x11-0 \
libxtst6 \
patchelf \
python3 \
python3-dev \
python3-pip \
python3-venv \
tar \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# Pre-crea il venv Python e installa le dipendenze in cache layer Docker
RUN python3 -m venv /opt/venv
ENV VIRTUAL_ENV="/opt/venv"
ENV PATH="/opt/venv/bin:${PATH}"
COPY server/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r /tmp/requirements.txt pyinstaller \
&& rm -f /tmp/requirements.txt
# Estrae appimagetool per funzionare senza FUSE dentro Docker
RUN curl -fsSL -o /tmp/appimagetool.AppImage \
https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage \
&& chmod +x /tmp/appimagetool.AppImage \
&& cd /opt \
&& /tmp/appimagetool.AppImage --appimage-extract \
&& mv /opt/squashfs-root /opt/appimagetool \
&& ln -s /opt/appimagetool/AppRun /usr/local/bin/appimagetool \
&& rm -f /tmp/appimagetool.AppImage
COPY docker/build-linux-appimage.sh /usr/local/bin/build-linux-appimage.sh
RUN chmod +x /usr/local/bin/build-linux-appimage.sh
WORKDIR /workspace
ENTRYPOINT ["/usr/local/bin/build-linux-appimage.sh"]
+1 -1
View File
@@ -7,7 +7,7 @@ APP_NAME = "Barcode Reader Server"
APP_BINARY_NAME = "BarcodeServer" APP_BINARY_NAME = "BarcodeServer"
APP_ID = "com.catellisrl.barcodereader" APP_ID = "com.catellisrl.barcodereader"
APP_PUBLISHER = "Catelli Srl" APP_PUBLISHER = "Catelli Srl"
APP_VERSION = "1.0.3" APP_VERSION = "1.0.4"
GITEA_BASE_URL = "https://gitea.catelli.it" GITEA_BASE_URL = "https://gitea.catelli.it"
GITEA_REPO = "brontomark/barcode_reader_pc" GITEA_REPO = "brontomark/barcode_reader_pc"