Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 64 additions & 15 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,27 +218,18 @@ jobs:
with:
node-version: 22

# Build tooling for the makers (.deb -> dpkg/fakeroot, .rpm -> rpm,
# .flatpak -> flatpak/flatpak-builder/eu-strip) plus libudev for the `usb` native module.
# Build tooling for the blocking makers only (.deb -> dpkg/fakeroot,
# .rpm -> rpm) plus libudev for the `usb` native module. Flatpak tooling
# is installed in the non-blocking Flatpak section below so an apt
# failure on those packages can't block the .deb/.rpm publish.
- name: 🐧 Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libudev-dev \
dpkg fakeroot \
rpm \
flatpak flatpak-builder elfutils

# The Flatpak maker builds against the Freedesktop runtime + Electron BaseApp,
# which are pulled from Flathub. Pre-install them so the build is deterministic.
- name: 🐧 Install Flatpak runtime + Electron BaseApp
run: |
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user flathub \
org.freedesktop.Platform//24.08 \
org.freedesktop.Sdk//24.08 \
org.electronjs.Electron2.BaseApp//24.08
rpm

- name: 📦 Install and rebuild native modules
env:
Expand All @@ -250,7 +241,65 @@ jobs:
npm install
npm run rebuild:all

- name: 🚀 Publish Linux release (.deb / .rpm / .flatpak)
# Flatpak is excluded from this step (forge.config.ts only enables the
# Flatpak maker when WCPOS_FLATPAK=1) so a flatpak-builder failure can
# never block the .deb/.rpm assets again. Flatpak is attempted below as
# a non-blocking step.
- name: 🚀 Publish Linux release (.deb / .rpm)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run publish-app

# --- Non-blocking Flatpak attempt below: every step is continue-on-error ---

# Flatpak build tooling (flatpak-builder, eu-strip from elfutils), then the
# Freedesktop runtime + Electron BaseApp pulled from Flathub. Pre-install the
# runtimes so the build is deterministic.
- name: 🐧 Install Flatpak tooling + runtime + Electron BaseApp (non-blocking)
id: flatpak-runtime
continue-on-error: true
run: |
sudo apt-get install -y flatpak flatpak-builder elfutils
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user flathub \
org.freedesktop.Platform//24.08 \
org.freedesktop.Sdk//24.08 \
org.electronjs.Electron2.BaseApp//24.08

- name: 📦 Make Flatpak bundle (non-blocking)
id: make-flatpak
if: steps.flatpak-runtime.outcome == 'success'
continue-on-error: true
env:
WCPOS_FLATPAK: '1'
# Surface flatpak-builder output — Forge swallows it otherwise, which is
# why past failures only showed "flatpak-builder failed with status code 1".
DEBUG: 'electron-installer-flatpak*'
run: npx electron-forge make --targets=@electron-forge/maker-flatpak --skip-package

- name: ⬆️ Upload Flatpak to release (non-blocking)
if: steps.make-flatpak.outcome == 'success'
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(node -p "require('./package.json').version")
files=$(find out/make -name '*.flatpak' -type f)
if [ -z "$files" ]; then
echo "::warning title=Flatpak missing::Flatpak make reported success but no .flatpak file was found under out/make."
exit 0
fi
echo "$files" | while read -r f; do
echo "Uploading $f to release v$version"
gh release upload "v$version" "$f" --clobber
done

- name: 📋 Report Flatpak result
if: steps.flatpak-runtime.outcome != 'success' || steps.make-flatpak.outcome != 'success'
run: |
echo "::warning title=Flatpak deferred::The non-blocking Flatpak build did not complete (runtime install: ${{ steps.flatpak-runtime.outcome }}, make: ${{ steps.make-flatpak.outcome }}). .deb/.rpm assets are unaffected. See the 'Make Flatpak bundle' step log (DEBUG output enabled) for the flatpak-builder error."
{
echo "## :warning: Flatpak deferred"
echo "The non-blocking Flatpak build did not complete (runtime install: \`${{ steps.flatpak-runtime.outcome }}\`, make: \`${{ steps.make-flatpak.outcome }}\`)."
echo ".deb/.rpm assets are unaffected."
} >> "$GITHUB_STEP_SUMMARY"
78 changes: 43 additions & 35 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,41 +157,49 @@ const config: ForgeConfig = {
),
// Sandboxed Flatpak bundle (also the format published to Flathub) —
// https://js.electronforge.io/interfaces/_electron_forge_maker_flatpak.MakerFlatpakConfig.html
new MakerFlatpak(
{
options: {
id: LINUX_APP_ID,
productName: 'WCPOS',
genericName: 'Point of Sale',
// Electron BaseApp + Freedesktop runtime is the recommended pairing for Electron.
// NOTE: confirm these are still the latest non-EOL branches at release time.
base: 'org.electronjs.Electron2.BaseApp',
baseVersion: '24.08',
runtime: 'org.freedesktop.Platform',
runtimeVersion: '24.08',
sdk: 'org.freedesktop.Sdk',
icon: path.resolve(__dirname, 'icons/icon.png'),
categories: ['Office', 'Finance'],
mimeType: ['x-scheme-handler/wcpos'],
// Sandbox permissions. --device=all is required for raw USB receipt printers /
// cash drawers (the `usb` native module); --share=network covers TCP/ESC-POS
// network printers and sync. Keep this in sync with the Flathub manifest.
finishArgs: [
'--share=ipc',
'--share=network',
'--socket=x11',
'--socket=fallback-x11',
'--socket=wayland',
'--socket=pulseaudio',
'--device=dri',
'--device=all',
'--talk-name=org.freedesktop.Notifications',
'--env=ELECTRON_TRASH=gio',
],
},
},
['linux']
),
// Opt-in via WCPOS_FLATPAK=1: the Flatpak maker has been failing in CI and a
// maker failure aborts the whole `electron-forge publish` run, which blocked
// .deb/.rpm from shipping (no Linux assets since v1.9.1). The publish workflow
// runs deb/rpm by default and attempts the Flatpak in a separate non-blocking step.
...(process.env.WCPOS_FLATPAK === '1'
? [
new MakerFlatpak(
{
options: {
id: LINUX_APP_ID,
productName: 'WCPOS',
genericName: 'Point of Sale',
// Electron BaseApp + Freedesktop runtime is the recommended pairing for Electron.
// NOTE: confirm these are still the latest non-EOL branches at release time.
base: 'org.electronjs.Electron2.BaseApp',
baseVersion: '24.08',
runtime: 'org.freedesktop.Platform',
runtimeVersion: '24.08',
sdk: 'org.freedesktop.Sdk',
icon: path.resolve(__dirname, 'icons/icon.png'),
categories: ['Office', 'Finance'],
mimeType: ['x-scheme-handler/wcpos'],
// Sandbox permissions. --device=all is required for raw USB receipt printers /
// cash drawers (the `usb` native module); --share=network covers TCP/ESC-POS
// network printers and sync. Keep this in sync with the Flathub manifest.
finishArgs: [
'--share=ipc',
'--share=network',
'--socket=x11',
'--socket=fallback-x11',
'--socket=wayland',
'--socket=pulseaudio',
'--device=dri',
'--device=all',
'--talk-name=org.freedesktop.Notifications',
'--env=ELECTRON_TRASH=gio',
],
},
},
['linux']
),
]
: []),
],
publishers: [
new PublisherGithub({
Expand Down
Loading