feat: implement Linux auto-installation and update Windows build process to use NSIS installer
This commit is contained in:
@@ -30,8 +30,8 @@ jobs:
|
|||||||
cp build/bin/goexplore dist/goexplore-linux-amd64
|
cp build/bin/goexplore dist/goexplore-linux-amd64
|
||||||
|
|
||||||
# Windows amd64
|
# Windows amd64
|
||||||
wails build -platform windows/amd64 -clean
|
wails build -platform windows/amd64 -clean -nsis
|
||||||
cp build/bin/goexplore.exe dist/goexplore-windows-amd64.exe
|
cp build/bin/goexplore-amd64-installer.exe dist/goexplore-windows-installer.exe
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT_URL }}
|
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT_URL }}
|
||||||
run: |
|
run: |
|
||||||
aws s3 cp dist/goexplore-linux-amd64 s3://apps/goexplore/goexplore-linux-amd64 --endpoint-url "$R2_ENDPOINT"
|
aws s3 cp dist/goexplore-linux-amd64 s3://apps/goexplore/goexplore-linux-amd64 --endpoint-url "$R2_ENDPOINT"
|
||||||
aws s3 cp dist/goexplore-windows-amd64.exe s3://apps/goexplore/goexplore-windows-amd64.exe --endpoint-url "$R2_ENDPOINT"
|
aws s3 cp dist/goexplore-windows-installer.exe s3://apps/goexplore/goexplore-windows-installer.exe --endpoint-url "$R2_ENDPOINT"
|
||||||
|
|
||||||
- name: Clean up
|
- name: Clean up
|
||||||
run: sudo rm -rf dist build/bin/*
|
run: sudo rm -rf dist build/bin/*
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
curl \
|
curl \
|
||||||
gcc \
|
gcc \
|
||||||
mingw-w64 \
|
mingw-w64 \
|
||||||
|
nsis \
|
||||||
libgtk-3-dev \
|
libgtk-3-dev \
|
||||||
libwebkit2gtk-4.1-dev \
|
libwebkit2gtk-4.1-dev \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
@@ -15,7 +20,64 @@ var assets embed.FS
|
|||||||
//go:embed build/appicon.png
|
//go:embed build/appicon.png
|
||||||
var icon []byte
|
var icon []byte
|
||||||
|
|
||||||
|
func installLinux() {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
exe, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
targetDir := filepath.Join(home, ".local", "bin")
|
||||||
|
targetExe := filepath.Join(targetDir, "goexplore")
|
||||||
|
|
||||||
|
// If we are already running from the target path, do nothing.
|
||||||
|
if exe == targetExe {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure target directories exist
|
||||||
|
os.MkdirAll(targetDir, 0755)
|
||||||
|
|
||||||
|
// Copy the executable
|
||||||
|
data, err := os.ReadFile(exe)
|
||||||
|
if err == nil {
|
||||||
|
os.WriteFile(targetExe, data, 0755)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the application icon
|
||||||
|
iconDir := filepath.Join(home, ".local", "share", "icons", "hicolor", "512x512", "apps")
|
||||||
|
os.MkdirAll(iconDir, 0755)
|
||||||
|
os.WriteFile(filepath.Join(iconDir, "goexplore.png"), icon, 0644)
|
||||||
|
|
||||||
|
// Write the desktop shortcut file
|
||||||
|
appDir := filepath.Join(home, ".local", "share", "applications")
|
||||||
|
os.MkdirAll(appDir, 0755)
|
||||||
|
desktopContent := fmt.Sprintf(`[Desktop Entry]
|
||||||
|
Name=GoExplore
|
||||||
|
Exec=%s
|
||||||
|
Icon=goexplore
|
||||||
|
Type=Application
|
||||||
|
Terminal=false
|
||||||
|
Categories=Utility;FileTools;`, targetExe)
|
||||||
|
os.WriteFile(filepath.Join(appDir, "goexplore.desktop"), []byte(desktopContent), 0644)
|
||||||
|
|
||||||
|
// Execute the newly installed binary and exit the current running process
|
||||||
|
cmd := exec.Command(targetExe)
|
||||||
|
cmd.Start()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
installLinux()
|
||||||
|
|
||||||
// Create an instance of the app structure
|
// Create an instance of the app structure
|
||||||
app := NewApp()
|
app := NewApp()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user