Skip to content

Commit fdca20a

Browse files
committed
Make Installer/Update cross-platform, add release workflow
- Installer.py and Update.py now use backend.paths for the app data directory and a platform-appropriate executable suffix, instead of hardcoding LOCALAPPDATA/APPDATA and ".exe". win32com.client is only imported on Windows. - On Linux, Installer.py creates XDG .desktop entries instead of .lnk shortcuts (an applications/ entry for Text2Pen, an autostart/ entry for Update), marks downloaded binaries executable, and shows the uinput udev-rule instructions after install. - build.yml: build and upload Installer for Linux too (needs python3-tk, which was the only remaining blocker), no more Windows-only special case. - Add release.yml (workflow 2): runs build.yml for a fresh set of binaries, refuses to run if the target tag already exists, and publishes a GitHub Release with every binary uploaded as its own asset, matching how all existing releases are structured.
1 parent 34fd9f6 commit fdca20a

5 files changed

Lines changed: 315 additions & 150 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: |
5555
sudo apt-get update
5656
sudo apt-get install -y \
57-
python3-gi gir1.2-webkit2-4.1 \
57+
python3-gi gir1.2-webkit2-4.1 python3-tk \
5858
gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-base \
5959
gstreamer1.0-plugins-good gstreamer1.0-pipewire \
6060
python3-dbus libgirepository1.0-dev
@@ -75,13 +75,7 @@ jobs:
7575
- name: Build Update
7676
run: pyinstaller --onefile --noconsole --name Update Update.py
7777

78-
# Installer.py still does `import win32com.client` and reads
79-
# LOCALAPPDATA/APPDATA at module level — it's Windows-only code, not
80-
# just a Windows-only build target. PyInstaller can't resolve
81-
# win32com.client on Linux at all, so this step is Windows-only until
82-
# Installer.py itself is adapted; drop the `if:` once that's done.
83-
- name: Build Installer (Windows only for now)
84-
if: matrix.label == 'windows'
78+
- name: Build Installer
8579
run: pyinstaller --onefile --noconsole --name Installer Installer.py
8680

8781
- name: Upload Text2Pen artifact
@@ -99,9 +93,8 @@ jobs:
9993
if-no-files-found: error
10094

10195
- name: Upload Installer artifact
102-
if: matrix.label == 'windows'
10396
uses: actions/upload-artifact@v4
10497
with:
10598
name: Installer-${{ matrix.label }}${{ inputs.version != '' && format('-{0}', inputs.version) || '' }}
106-
path: dist/Installer.exe
99+
path: dist/Installer${{ matrix.label == 'windows' && '.exe' || '' }}
107100
if-no-files-found: error

‎.github/workflows/release.yml‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Create release
2+
3+
# Workflow 2 of 2: runs build.yml for a fresh set of executables, renames
4+
# them to their final release filenames, and publishes a new GitHub Release
5+
# with each file uploaded as its own asset — same as every existing release,
6+
# so Update.exe's per-file SHA256 check keeps working. Refuses to run if the
7+
# tag already exists, so it can never overwrite a past release.
8+
#
9+
# Multi-line release notes don't fit well in the "Run workflow" web form
10+
# (it's a single-line box); use the gh CLI for those, e.g.:
11+
# gh workflow run release.yml -f version=v2.8 -f release_notes="$(cat notes.md)"
12+
on:
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: "Tag/version to release, e.g. v2.8"
17+
required: true
18+
release_notes:
19+
description: "Release notes (markdown, shown on the release page)"
20+
required: true
21+
prerelease:
22+
description: "Mark as a pre-release"
23+
type: boolean
24+
required: false
25+
default: false
26+
27+
permissions:
28+
contents: write
29+
30+
jobs:
31+
build:
32+
uses: ./.github/workflows/build.yml
33+
with:
34+
version: ${{ inputs.version }}
35+
36+
release:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
fetch-tags: true
44+
45+
- name: Refuse to overwrite an existing tag/release
46+
run: |
47+
if git rev-parse "refs/tags/${{ inputs.version }}" >/dev/null 2>&1; then
48+
echo "::error::Tag ${{ inputs.version }} already exists. Refusing to overwrite an existing release."
49+
exit 1
50+
fi
51+
52+
- name: Download all build artifacts
53+
uses: actions/download-artifact@v4
54+
with:
55+
path: artifacts
56+
pattern: "*-${{ inputs.version }}"
57+
58+
# find, not a hardcoded nested path: upload-artifact's exact internal
59+
# layout for a single-file `path:` has shifted across versions, so this
60+
# locates each binary by name inside its artifact folder instead of
61+
# assuming where under it it landed.
62+
- name: Lay out release assets with their final names
63+
run: |
64+
set -euo pipefail
65+
mkdir -p release
66+
67+
copy_asset() {
68+
local artifact_dir="artifacts/$1"
69+
local filename="$2"
70+
local found
71+
found=$(find "$artifact_dir" -type f -name "$filename" | head -n1)
72+
if [ -z "$found" ]; then
73+
echo "::error::Could not find $filename in $artifact_dir"
74+
exit 1
75+
fi
76+
cp "$found" "release/$filename"
77+
}
78+
79+
copy_asset "Text2Pen-windows-${{ inputs.version }}" "Text2Pen.exe"
80+
copy_asset "Update-windows-${{ inputs.version }}" "Update.exe"
81+
copy_asset "Installer-windows-${{ inputs.version }}" "Installer.exe"
82+
copy_asset "Text2Pen-linux-${{ inputs.version }}" "Text2Pen"
83+
copy_asset "Update-linux-${{ inputs.version }}" "Update"
84+
copy_asset "Installer-linux-${{ inputs.version }}" "Installer"
85+
86+
chmod +x release/Text2Pen release/Update release/Installer
87+
ls -la release/
88+
89+
- name: Create GitHub release
90+
uses: softprops/action-gh-release@v2
91+
with:
92+
tag_name: ${{ inputs.version }}
93+
name: ${{ inputs.version }}
94+
body: ${{ inputs.release_notes }}
95+
prerelease: ${{ inputs.prerelease }}
96+
files: |
97+
release/Text2Pen.exe
98+
release/Update.exe
99+
release/Installer.exe
100+
release/Text2Pen
101+
release/Update
102+
release/Installer

0 commit comments

Comments
 (0)