224 lines
11 KiB
YAML
224 lines
11 KiB
YAML
name: Build and Release Barcode Reader Server (Multi-Platform)
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
# -----------------------------------------------------------------
|
|
# JOB 1: WINDOWS INSTALLER (.exe)
|
|
# -----------------------------------------------------------------
|
|
build-windows:
|
|
runs-on: windows-native
|
|
steps:
|
|
- name: Checkout del codice
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Rileva Python e compila binario PySide6
|
|
run: |
|
|
$TagVersion = "${{ github.ref_name }}".TrimStart('v')
|
|
$PyCmd = $null
|
|
if (Get-Command py -ErrorAction SilentlyContinue) {
|
|
$PyCmd = @("py", "-3")
|
|
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
|
|
$PyCmd = @("python")
|
|
} elseif (Get-Command python3 -ErrorAction SilentlyContinue) {
|
|
$PyCmd = @("python3")
|
|
} else {
|
|
throw "Python 3 non trovato sul runner Windows."
|
|
}
|
|
|
|
if ($PyCmd.Count -gt 1) {
|
|
& $PyCmd[0] $PyCmd[1] server/build_binary.py --onedir --windowed --version "$TagVersion"
|
|
} else {
|
|
& $PyCmd[0] server/build_binary.py --onedir --windowed --version "$TagVersion"
|
|
}
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
- name: Firma opzionale eseguibile Windows
|
|
run: |
|
|
$PfxPath = "C:\flux_privato.pfx"
|
|
$PfxPass = "${{ secrets.PFX_PASSWORD }}"
|
|
if ((Test-Path $PfxPath) -and (-not [string]::IsNullOrWhiteSpace($PfxPass))) {
|
|
$Signtool = (Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1).FullName
|
|
if ($Signtool) {
|
|
& $Signtool sign /f $PfxPath /p $PfxPass /fd SHA256 "server\dist\BarcodeServer\BarcodeServer.exe"
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
} else {
|
|
Write-Host "[i] signtool.exe non trovato: firma saltata."
|
|
}
|
|
} else {
|
|
Write-Host "[i] Certificato o PFX_PASSWORD non configurati: salto firma eseguibile."
|
|
}
|
|
|
|
- name: Build Installer Inno Setup
|
|
run: |
|
|
$TagVersion = "${{ github.ref_name }}".TrimStart('v')
|
|
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "/DMyAppVersion=$TagVersion" "server\win_installer.iss"
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
- name: Firma opzionale Installer Windows
|
|
run: |
|
|
$PfxPath = "C:\flux_privato.pfx"
|
|
$PfxPass = "${{ secrets.PFX_PASSWORD }}"
|
|
if ((Test-Path $PfxPath) -and (-not [string]::IsNullOrWhiteSpace($PfxPass))) {
|
|
$Signtool = (Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1).FullName
|
|
if ($Signtool) {
|
|
& $Signtool sign /f $PfxPath /p $PfxPass /fd SHA256 "server\dist\installer\BarcodeServerSetup.exe"
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
}
|
|
|
|
- name: Upload Windows Installer Asset su Gitea Release
|
|
uses: https://gitea.com/actions/release-action@main
|
|
with:
|
|
files: "server/dist/installer/BarcodeServerSetup.exe"
|
|
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 via Docker Ubuntu 22.04)
|
|
# -----------------------------------------------------------------
|
|
build-linux:
|
|
runs-on: linux-runner
|
|
steps:
|
|
- name: Checkout del codice
|
|
uses: actions/checkout@v3
|
|
|
|
- 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: |
|
|
TagVersion="${GITHUB_REF_NAME#v}"
|
|
docker run --rm \
|
|
-e HOST_UID="$(id -u)" \
|
|
-e HOST_GID="$(id -g)" \
|
|
-e APP_VERSION="$TagVersion" \
|
|
-v "$PWD:/workspace" \
|
|
barcode-linux-builder
|
|
|
|
- name: Upload Linux AppImage Asset su Gitea Release
|
|
uses: https://gitea.com/actions/release-action@main
|
|
with:
|
|
files: "BarcodeServer-x86_64.AppImage"
|
|
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)
|
|
# -----------------------------------------------------------------
|
|
build-macos:
|
|
runs-on: macos-runner
|
|
steps:
|
|
- name: Checkout del codice
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Compila bundle .app PySide6
|
|
run: |
|
|
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
|
TagVersion="${GITHUB_REF_NAME#v}"
|
|
python3 server/build_binary.py --onedir --windowed --version "$TagVersion"
|
|
|
|
- name: Genera DMG e ZIP macOS
|
|
run: |
|
|
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"
|
|
|
|
- name: Upload macOS Assets su Gitea Release
|
|
uses: https://gitea.com/actions/release-action@main
|
|
with:
|
|
files: |
|
|
BarcodeServer-macOS.dmg
|
|
BarcodeServer-macOS.zip
|
|
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'"
|