Switch remote deploy to vendored source builds

Move remote deployment to a vendored source bundle built on the target host via Docker so redeploys no longer require local cross-compilation or host Go installation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
GitHub Actions
2026-05-08 12:19:18 +08:00
parent bb27566e38
commit c1a0fe2949
1320 changed files with 497125 additions and 11 deletions

View File

@@ -0,0 +1,20 @@
package assetserver
import (
"net/http"
)
// Middleware defines a HTTP middleware that can be applied to the AssetServer.
// The handler passed as next is the next handler in the chain. One can decide to call the next handler
// or implement a specialized handling.
type Middleware func(next http.Handler) http.Handler
// ChainMiddleware allows chaining multiple middlewares to one middleware.
func ChainMiddleware(middleware ...Middleware) Middleware {
return func(h http.Handler) http.Handler {
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
return h
}
}

View File

@@ -0,0 +1,45 @@
package assetserver
import (
"fmt"
"io/fs"
"net/http"
)
// Options defines the configuration of the AssetServer.
type Options struct {
// Assets defines the static assets to be used. A GET request is first tried to be served from this Assets. If the Assets returns
// `os.ErrNotExist` for that file, the request handling will fallback to the Handler and tries to serve the GET
// request from it.
//
// If set to nil, all GET requests will be forwarded to Handler.
Assets fs.FS
// Handler will be called for every GET request that can't be served from Assets, due to `os.ErrNotExist`. Furthermore all
// non GET requests will always be served from this Handler.
//
// If not defined, the result is the following in cases where the Handler would have been called:
// GET request: `http.StatusNotFound`
// Other request: `http.StatusMethodNotAllowed`
Handler http.Handler
// Middleware is a HTTP Middleware which allows to hook into the AssetServer request chain. It allows to skip the default
// request handler dynamically, e.g. implement specialized Routing etc.
// The Middleware is called to build a new `http.Handler` used by the AssetSever and it also receives the default
// handler used by the AssetServer as an argument.
//
// If not defined, the default AssetServer request chain is executed.
//
// Multiple Middlewares can be chained together with:
// ChainMiddleware(middleware ...Middleware) Middleware
Middleware Middleware
}
// Validate the options
func (o Options) Validate() error {
if o.Assets == nil && o.Handler == nil && o.Middleware == nil {
return fmt.Errorf("AssetServer options invalid: either Assets, Handler or Middleware must be set")
}
return nil
}

View File

@@ -0,0 +1,7 @@
package options
// Debug options which are taken into account in debug builds.
type Debug struct {
// OpenInspectorOnStartup opens the inspector on startup of the app.
OpenInspectorOnStartup bool
}

View File

@@ -0,0 +1,56 @@
package linux
// WebviewGpuPolicy values used for determining the webview's hardware acceleration policy.
type WebviewGpuPolicy int
const (
// WebviewGpuPolicyAlways Hardware acceleration is always enabled.
WebviewGpuPolicyAlways WebviewGpuPolicy = iota
// WebviewGpuPolicyOnDemand Hardware acceleration is enabled/disabled as request by web contents.
WebviewGpuPolicyOnDemand
// WebviewGpuPolicyNever Hardware acceleration is always disabled.
WebviewGpuPolicyNever
)
// Options specific to Linux builds
type Options struct {
// Icon Sets up the icon representing the window. This icon is used when the window is minimized
// (also known as iconified).
Icon []byte
// WindowIsTranslucent sets the window's background to transparent when enabled.
WindowIsTranslucent bool
// Messages are messages that can be customised
Messages *Messages
// WebviewGpuPolicy used for determining the hardware acceleration policy for the webview.
// - WebviewGpuPolicyAlways
// - WebviewGpuPolicyOnDemand
// - WebviewGpuPolicyNever
//
// Due to https://github.com/wailsapp/wails/issues/2977, if options.Linux is nil
// in the call to wails.Run(), WebviewGpuPolicy is set by default to WebviewGpuPolicyNever.
// Client code may override this behavior by passing a non-nil Options and set
// WebviewGpuPolicy as needed.
WebviewGpuPolicy WebviewGpuPolicy
// ProgramName is used to set the program's name for the window manager via GTK's g_set_prgname().
//This name should not be localized. [see the docs]
//
//When a .desktop file is created this value helps with window grouping and desktop icons when the .desktop file's Name
//property differs form the executable's filename.
//
//[see the docs]: https://docs.gtk.org/glib/func.set_prgname.html
ProgramName string
}
type Messages struct {
WebKit2GTKMinRequired string
}
func DefaultMessages() *Messages {
return &Messages{
WebKit2GTKMinRequired: "This application requires at least WebKit2GTK %s to be installed.",
}
}

View File

@@ -0,0 +1,23 @@
package mac
// AppearanceType is a type of Appearance for Cocoa windows
type AppearanceType string
const (
// DefaultAppearance uses the default system value
DefaultAppearance AppearanceType = ""
// NSAppearanceNameAqua - The standard light system appearance.
NSAppearanceNameAqua AppearanceType = "NSAppearanceNameAqua"
// NSAppearanceNameDarkAqua - The standard dark system appearance.
NSAppearanceNameDarkAqua AppearanceType = "NSAppearanceNameDarkAqua"
// NSAppearanceNameVibrantLight - The light vibrant appearance
NSAppearanceNameVibrantLight AppearanceType = "NSAppearanceNameVibrantLight"
// NSAppearanceNameAccessibilityHighContrastAqua - A high-contrast version of the standard light system appearance.
NSAppearanceNameAccessibilityHighContrastAqua AppearanceType = "NSAppearanceNameAccessibilityHighContrastAqua"
// NSAppearanceNameAccessibilityHighContrastDarkAqua - A high-contrast version of the standard dark system appearance.
NSAppearanceNameAccessibilityHighContrastDarkAqua AppearanceType = "NSAppearanceNameAccessibilityHighContrastDarkAqua"
// NSAppearanceNameAccessibilityHighContrastVibrantLight - A high-contrast version of the light vibrant appearance.
NSAppearanceNameAccessibilityHighContrastVibrantLight AppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantLight"
// NSAppearanceNameAccessibilityHighContrastVibrantDark - A high-contrast version of the dark vibrant appearance.
NSAppearanceNameAccessibilityHighContrastVibrantDark AppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantDark"
)

View File

@@ -0,0 +1,31 @@
package mac
//type ActivationPolicy int
//
//const (
// NSApplicationActivationPolicyRegular ActivationPolicy = 0
// NSApplicationActivationPolicyAccessory ActivationPolicy = 1
// NSApplicationActivationPolicyProhibited ActivationPolicy = 2
//)
type AboutInfo struct {
Title string
Message string
Icon []byte
}
// Options are options specific to Mac
type Options struct {
TitleBar *TitleBar
Appearance AppearanceType
ContentProtection bool
WebviewIsTransparent bool
WindowIsTranslucent bool
Preferences *Preferences
DisableZoom bool
// ActivationPolicy ActivationPolicy
About *AboutInfo
OnFileOpen func(filePath string) `json:"-"`
OnUrlOpen func(filePath string) `json:"-"`
// URLHandlers map[string]func(string)
}

View File

@@ -0,0 +1,21 @@
package mac
import "github.com/leaanthony/u"
var (
Enabled = u.True
Disabled = u.False
)
// Preferences allows to set webkit preferences
type Preferences struct {
// A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls.
// Set to false by default.
TabFocusesLinks u.Bool
// A Boolean value that indicates whether to allow people to select or otherwise interact with text.
// Set to true by default.
TextInteractionEnabled u.Bool
// A Boolean value that indicates whether a web view can display content full screen.
// Set to false by default
FullscreenEnabled u.Bool
}

View File

@@ -0,0 +1,52 @@
package mac
// TitleBar contains options for the Mac titlebar
type TitleBar struct {
TitlebarAppearsTransparent bool
HideTitle bool
HideTitleBar bool
FullSizeContent bool
UseToolbar bool
HideToolbarSeparator bool
}
// TitleBarDefault results in the default Mac Titlebar
func TitleBarDefault() *TitleBar {
return &TitleBar{
TitlebarAppearsTransparent: false,
HideTitle: false,
HideTitleBar: false,
FullSizeContent: false,
UseToolbar: false,
HideToolbarSeparator: false,
}
}
// Credit: Comments from Electron site
// TitleBarHidden results in a hidden title bar and a full size content window,
// yet the title bar still has the standard window controls (“traffic lights”)
// in the top left.
func TitleBarHidden() *TitleBar {
return &TitleBar{
TitlebarAppearsTransparent: true,
HideTitle: true,
HideTitleBar: false,
FullSizeContent: true,
UseToolbar: false,
HideToolbarSeparator: false,
}
}
// TitleBarHiddenInset results in a hidden title bar with an alternative look where
// the traffic light buttons are slightly more inset from the window edge.
func TitleBarHiddenInset() *TitleBar {
return &TitleBar{
TitlebarAppearsTransparent: true,
HideTitle: true,
HideTitleBar: false,
FullSizeContent: true,
UseToolbar: true,
HideToolbarSeparator: true,
}
}

View File

@@ -0,0 +1,276 @@
package options
import (
"context"
"html"
"io/fs"
"net/http"
"os"
"path/filepath"
"runtime"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/logger"
)
type WindowStartState int
const (
Normal WindowStartState = 0
Maximised WindowStartState = 1
Minimised WindowStartState = 2
Fullscreen WindowStartState = 3
)
type Experimental struct{}
// App contains options for creating the App
type App struct {
Title string
Width int
Height int
DisableResize bool
Fullscreen bool
Frameless bool
MinWidth int
MinHeight int
MaxWidth int
MaxHeight int
StartHidden bool
HideWindowOnClose bool
AlwaysOnTop bool
// BackgroundColour is the background colour of the window
// You can use the options.NewRGB and options.NewRGBA functions to create a new colour
BackgroundColour *RGBA
// Deprecated: Use AssetServer.Assets instead.
Assets fs.FS
// Deprecated: Use AssetServer.Handler instead.
AssetsHandler http.Handler
// AssetServer configures the Assets for the application
AssetServer *assetserver.Options
Menu *menu.Menu
Logger logger.Logger `json:"-"`
LogLevel logger.LogLevel
LogLevelProduction logger.LogLevel
OnStartup func(ctx context.Context) `json:"-"`
OnDomReady func(ctx context.Context) `json:"-"`
OnShutdown func(ctx context.Context) `json:"-"`
OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"`
Bind []interface{}
EnumBind []interface{}
WindowStartState WindowStartState
// ErrorFormatter overrides the formatting of errors returned by backend methods
ErrorFormatter ErrorFormatter
// CSS property to test for draggable elements. Default "--wails-draggable"
CSSDragProperty string
// The CSS Value that the CSSDragProperty must have to be draggable, EG: "drag"
CSSDragValue string
// EnableDefaultContextMenu enables the browser's default context-menu in production
// This menu is already enabled in development and debug builds
EnableDefaultContextMenu bool
// EnableFraudulentWebsiteDetection enables scan services for fraudulent content, such as malware or phishing attempts.
// These services might send information from your app like URLs navigated to and possibly other content to cloud
// services of Apple and Microsoft.
EnableFraudulentWebsiteDetection bool
SingleInstanceLock *SingleInstanceLock
Windows *windows.Options
Mac *mac.Options
Linux *linux.Options
// Experimental options
Experimental *Experimental
// Debug options for debug builds. These options will be ignored in a production build.
Debug Debug
// DragAndDrop options for drag and drop behavior
DragAndDrop *DragAndDrop
// DisablePanicRecovery disables the panic recovery system in messages processing
DisablePanicRecovery bool
// List of additional allowed origins for bindings in format "https://*.myapp.com,https://example.com"
BindingsAllowedOrigins string
}
type ErrorFormatter func(error) any
type RGBA struct {
R uint8 `json:"r"`
G uint8 `json:"g"`
B uint8 `json:"b"`
A uint8 `json:"a"`
}
// NewRGBA creates a new RGBA struct with the given values
func NewRGBA(r, g, b, a uint8) *RGBA {
return &RGBA{
R: r,
G: g,
B: b,
A: a,
}
}
// NewRGB creates a new RGBA struct with the given values and Alpha set to 255
func NewRGB(r, g, b uint8) *RGBA {
return &RGBA{
R: r,
G: g,
B: b,
A: 255,
}
}
// MergeDefaults will set the minimum default values for an application
func MergeDefaults(appoptions *App) {
// Do set defaults
if appoptions.Width <= 0 {
appoptions.Width = 1024
}
if appoptions.Height <= 0 {
appoptions.Height = 768
}
if appoptions.Logger == nil {
appoptions.Logger = logger.NewDefaultLogger()
}
if appoptions.LogLevel == 0 {
appoptions.LogLevel = logger.INFO
}
if appoptions.LogLevelProduction == 0 {
appoptions.LogLevelProduction = logger.ERROR
}
if appoptions.CSSDragProperty == "" {
appoptions.CSSDragProperty = "--wails-draggable"
}
if appoptions.CSSDragValue == "" {
appoptions.CSSDragValue = "drag"
}
if appoptions.DragAndDrop == nil {
appoptions.DragAndDrop = &DragAndDrop{}
}
if appoptions.DragAndDrop.CSSDropProperty == "" {
appoptions.DragAndDrop.CSSDropProperty = "--wails-drop-target"
}
if appoptions.DragAndDrop.CSSDropValue == "" {
appoptions.DragAndDrop.CSSDropValue = "drop"
}
if appoptions.BackgroundColour == nil {
appoptions.BackgroundColour = &RGBA{
R: 255,
G: 255,
B: 255,
A: 255,
}
}
// Ensure max and min are valid
processMinMaxConstraints(appoptions)
// Default menus
processMenus(appoptions)
// Process Drag Options
processDragOptions(appoptions)
}
type SingleInstanceLock struct {
// uniqueId that will be used for setting up messaging between instances
UniqueId string
OnSecondInstanceLaunch func(secondInstanceData SecondInstanceData)
}
type SecondInstanceData struct {
Args []string
WorkingDirectory string
}
type DragAndDrop struct {
// EnableFileDrop enables wails' drag and drop functionality that returns the dropped in files' absolute paths.
EnableFileDrop bool
// Disable webview's drag and drop functionality.
//
// It can be used to prevent accidental file opening of dragged in files in the webview, when there is no need for drag and drop.
DisableWebViewDrop bool
// CSS property to test for drag and drop target elements. Default "--wails-drop-target"
CSSDropProperty string
// The CSS Value that the CSSDropProperty must have to be a valid drop target. Default "drop"
CSSDropValue string
}
func NewSecondInstanceData() (*SecondInstanceData, error) {
ex, err := os.Executable()
if err != nil {
return nil, err
}
workingDirectory := filepath.Dir(ex)
return &SecondInstanceData{
Args: os.Args[1:],
WorkingDirectory: workingDirectory,
}, nil
}
func processMenus(appoptions *App) {
switch runtime.GOOS {
case "darwin":
if appoptions.Menu == nil {
items := []*menu.MenuItem{
menu.EditMenu(),
}
if !appoptions.Frameless {
items = append(items, menu.WindowMenu()) // Current options in Window Menu only work if not frameless
}
appoptions.Menu = menu.NewMenuFromItems(menu.AppMenu(), items...)
}
}
}
func processMinMaxConstraints(appoptions *App) {
if appoptions.MinWidth > 0 && appoptions.MaxWidth > 0 {
if appoptions.MinWidth > appoptions.MaxWidth {
appoptions.MinWidth = appoptions.MaxWidth
}
}
if appoptions.MinHeight > 0 && appoptions.MaxHeight > 0 {
if appoptions.MinHeight > appoptions.MaxHeight {
appoptions.MinHeight = appoptions.MaxHeight
}
}
// Ensure width and height are limited if max/min is set
if appoptions.Width < appoptions.MinWidth {
appoptions.Width = appoptions.MinWidth
}
if appoptions.MaxWidth > 0 && appoptions.Width > appoptions.MaxWidth {
appoptions.Width = appoptions.MaxWidth
}
if appoptions.Height < appoptions.MinHeight {
appoptions.Height = appoptions.MinHeight
}
if appoptions.MaxHeight > 0 && appoptions.Height > appoptions.MaxHeight {
appoptions.Height = appoptions.MaxHeight
}
}
func processDragOptions(appoptions *App) {
appoptions.CSSDragProperty = html.EscapeString(appoptions.CSSDragProperty)
appoptions.CSSDragValue = html.EscapeString(appoptions.CSSDragValue)
}

View File

@@ -0,0 +1,167 @@
package windows
type Theme int
type Messages struct {
InstallationRequired string
UpdateRequired string
MissingRequirements string
Webview2NotInstalled string
Error string
FailedToInstall string
DownloadPage string
PressOKToInstall string
ContactAdmin string
InvalidFixedWebview2 string
WebView2ProcessCrash string
}
const (
// SystemDefault will use whatever the system theme is. The application will follow system theme changes.
SystemDefault Theme = 0
// Dark Mode
Dark Theme = 1
// Light Mode
Light Theme = 2
)
type BackdropType int32
const (
Auto BackdropType = 0
None BackdropType = 1
Mica BackdropType = 2
Acrylic BackdropType = 3
Tabbed BackdropType = 4
)
const (
// Default is 0, which means no changes to the default Windows DLL search behavior
DLLSearchDefault uint32 = 0
// LoadLibrary flags for determining from where to search for a DLL
DLLSearchDontResolveDllReferences uint32 = 0x1 // windows.DONT_RESOLVE_DLL_REFERENCES
DLLSearchAsDataFile uint32 = 0x2 // windows.LOAD_LIBRARY_AS_DATAFILE
DLLSearchWithAlteredPath uint32 = 0x8 // windows.LOAD_WITH_ALTERED_SEARCH_PATH
DLLSearchIgnoreCodeAuthzLevel uint32 = 0x10 // windows.LOAD_IGNORE_CODE_AUTHZ_LEVEL
DLLSearchAsImageResource uint32 = 0x20 // windows.LOAD_LIBRARY_AS_IMAGE_RESOURCE
DLLSearchAsDataFileExclusive uint32 = 0x40 // windows.LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
DLLSearchRequireSignedTarget uint32 = 0x80 // windows.LOAD_LIBRARY_REQUIRE_SIGNED_TARGET
DLLSearchDllLoadDir uint32 = 0x100 // windows.LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
DLLSearchApplicationDir uint32 = 0x200 // windows.LOAD_LIBRARY_SEARCH_APPLICATION_DIR
DLLSearchUserDirs uint32 = 0x400 // windows.LOAD_LIBRARY_SEARCH_USER_DIRS
DLLSearchSystem32 uint32 = 0x800 // windows.LOAD_LIBRARY_SEARCH_SYSTEM32
DLLSearchDefaultDirs uint32 = 0x1000 // windows.LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
DLLSearchSafeCurrentDirs uint32 = 0x2000 // windows.LOAD_LIBRARY_SAFE_CURRENT_DIRS
DLLSearchSystem32NoForwarder uint32 = 0x4000 // windows.LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER
DLLSearchOsIntegrityContinuity uint32 = 0x8000 // windows.LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY
)
func RGB(r, g, b uint8) int32 {
col := int32(b)
col = col<<8 | int32(g)
col = col<<8 | int32(r)
return col
}
// ThemeSettings contains optional colours to use.
// They may be set using the hex values: 0x00BBGGRR
type ThemeSettings struct {
DarkModeTitleBar int32
DarkModeTitleBarInactive int32
DarkModeTitleText int32
DarkModeTitleTextInactive int32
DarkModeBorder int32
DarkModeBorderInactive int32
LightModeTitleBar int32
LightModeTitleBarInactive int32
LightModeTitleText int32
LightModeTitleTextInactive int32
LightModeBorder int32
LightModeBorderInactive int32
}
// Options are options specific to Windows
type Options struct {
ContentProtection bool
WebviewIsTransparent bool
WindowIsTranslucent bool
DisableWindowIcon bool
IsZoomControlEnabled bool
ZoomFactor float64
DisablePinchZoom bool
// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
// "Rounded Corners" are only available on Windows 11.
DisableFramelessWindowDecorations bool
// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
WebviewUserDataPath string
// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
WebviewBrowserPath string
// Dark/Light or System Default Theme
Theme Theme
// Custom settings for dark/light mode
CustomTheme *ThemeSettings
// Select the type of translucent backdrop. Requires Windows 11 22621 or later.
BackdropType BackdropType
// User messages that can be customised
Messages *Messages
// ResizeDebounceMS is the amount of time to debounce redraws of webview2
// when resizing the window
ResizeDebounceMS uint16
// OnSuspend is called when Windows enters low power mode
OnSuspend func()
// OnResume is called when Windows resumes from low power mode
OnResume func()
// WebviewGpuIsDisabled is used to enable / disable GPU acceleration for the webview
WebviewGpuIsDisabled bool
// WebviewDisableRendererCodeIntegrity disables the `RendererCodeIntegrity` of WebView2. Some Security Endpoint
// Protection Software inject themself into the WebView2 with unsigned or wrongly signed dlls, which is not allowed
// and will stop the WebView2 processes. Those security software need an update to fix this issue or one can disable
// the integrity check with this flag.
//
// The event viewer log contains `Code Integrity Errors` like mentioned here: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2051
//
// !! Please keep in mind when disabling this feature, this also allows malicious software to inject into the WebView2 !!
WebviewDisableRendererCodeIntegrity bool
// Configure whether swipe gestures should be enabled
EnableSwipeGestures bool
// Class name for the window. If empty, 'wailsWindow' will be used.
WindowClassName string
// DLLSearchPaths controls which directories are searched when loading DLLs
// Set to 0 for default behavior, or combine multiple flags with bitwise OR
// Example: DLLSearchApplicationDir | DLLSearchSystem32
DLLSearchPaths uint32
}
func DefaultMessages() *Messages {
return &Messages{
InstallationRequired: "The WebView2 runtime is required. Press Ok to download and install. Note: The installer will download silently so please wait.",
UpdateRequired: "The WebView2 runtime needs updating. Press Ok to download and install. Note: The installer will download silently so please wait.",
MissingRequirements: "Missing Requirements",
Webview2NotInstalled: "WebView2 runtime not installed",
Error: "Error",
FailedToInstall: "The runtime failed to install correctly. Please try again.",
DownloadPage: "This application requires the WebView2 runtime. Press OK to open the download page. Minimum version required: ",
PressOKToInstall: "Press Ok to install.",
ContactAdmin: "The WebView2 runtime is required to run this application. Please contact your system administrator.",
InvalidFixedWebview2: "The WebView2 runtime is manually specified, but It is not valid. Check minimum required version and webview2 path.",
WebView2ProcessCrash: "The WebView2 process crashed and the application needs to be restarted.",
}
}