Repository navigation
191 lines (170 loc) · 6.78 KB
/
Copy pathdesktop.yml
File metadata and controls
191 lines (170 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Desktop
# Builds the Wails desktop app natively on each OS (Wails cannot be
# cross-compiled — it links each platform's native webview), packages a
# per-OS installer, and attaches them to the GitHub Release on version tags.
#
# This workflow is intentionally separate from release.yml (which builds the
# CLI/agent binaries + container image) so the desktop app can be iterated and
# triggered independently.
on:
workflow_dispatch:
inputs:
version:
description: 'Version label for the desktop build (e.g. v0.14.5). Defaults to "dev".'
required: false
type: string
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: desktop-${{ github.ref }}
cancel-in-progress: true
env:
WAILS_VERSION: v2.12.0
jobs:
build:
name: Build (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
# ubuntu-22.04 links against an older glibc for a broader-compatible
# tarball; if libwebkit2gtk-4.1-dev is ever unavailable here, switch
# to ubuntu-latest (the AppImage bundles webkit regardless).
- name: linux
os: ubuntu-22.04
- name: macos
os: macos-latest
- name: windows
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install Linux build dependencies
if: matrix.name == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev build-essential pkg-config
- name: Install NSIS (Windows installer toolchain)
if: matrix.name == 'windows'
shell: pwsh
run: |
choco install nsis -y --no-progress
"C:\Program Files (x86)\NSIS" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }}
- name: Resolve version
id: version
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
echo "value=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
else
echo "value=dev" >> "$GITHUB_OUTPUT"
fi
# ---- Native builds (Wails picks the host's webview) ----
- name: Build desktop app (Linux)
if: matrix.name == 'linux'
working-directory: desktop
run: wails build -tags webkit2_41 -platform linux/amd64
- name: Build desktop app (macOS, universal)
if: matrix.name == 'macos'
working-directory: desktop
run: wails build -platform darwin/universal
- name: Build desktop app (Windows + NSIS installer)
if: matrix.name == 'windows'
working-directory: desktop
run: wails build -platform windows/amd64 -nsis
# ---- Per-OS packaging ----
- name: Package Linux (tarball + AppImage)
if: matrix.name == 'linux'
working-directory: desktop
run: |
set -euo pipefail
# Always produce a portable tarball (needs host libwebkit2gtk-4.1).
tar -czf build/bin/StacyVM-linux-amd64.tar.gz -C build/bin StacyVM
- name: Package Linux AppImage (self-contained)
if: matrix.name == 'linux'
continue-on-error: true
working-directory: desktop
run: |
set -euo pipefail
APPDIR=StacyVM.AppDir
mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/share/applications" "$APPDIR/usr/share/icons/hicolor/512x512/apps"
cp build/bin/StacyVM "$APPDIR/usr/bin/StacyVM"
cp build/appicon.png "$APPDIR/usr/share/icons/hicolor/512x512/apps/stacyvm.png"
printf '[Desktop Entry]\nType=Application\nName=StacyVM\nExec=StacyVM\nIcon=stacyvm\nCategories=Development;\nTerminal=false\n' \
> "$APPDIR/usr/share/applications/stacyvm.desktop"
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-gtk/raw/master/linuxdeploy-plugin-gtk.sh
chmod +x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-gtk.sh
./linuxdeploy-x86_64.AppImage --appimage-extract-and-run \
--appdir "$APPDIR" --plugin gtk --output appimage \
--desktop-file "$APPDIR/usr/share/applications/stacyvm.desktop" \
--icon-file build/appicon.png
mv StacyVM*.AppImage build/bin/StacyVM-x86_64.AppImage
- name: Package macOS DMG
if: matrix.name == 'macos'
working-directory: desktop
run: |
set -euo pipefail
brew install create-dmg
create-dmg \
--volname "StacyVM" \
--window-size 600 400 \
--icon-size 100 \
--icon "StacyVM.app" 150 200 \
--app-drop-link 450 200 \
"build/bin/StacyVM-macos-universal.dmg" \
"build/bin/StacyVM.app" \
|| hdiutil create -volname "StacyVM" -srcfolder "build/bin/StacyVM.app" -ov -format UDZO "build/bin/StacyVM-macos-universal.dmg"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: stacyvm-desktop-${{ matrix.name }}
if-no-files-found: warn
path: |
desktop/build/bin/*.AppImage
desktop/build/bin/*.tar.gz
desktop/build/bin/*.dmg
desktop/build/bin/*-installer.exe
release:
name: Attach to GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all desktop artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Upload desktop installers to the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
# release.yml may create the release first; create it here only if missing.
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|| gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --title "$TAG" --generate-notes \
|| true
gh release upload "$TAG" artifacts/* --repo "$GITHUB_REPOSITORY" --clobber