This commit is contained in:
2026-02-05 04:26:59 +08:00
parent 82812ca4bc
commit dcba4c3e05
9 changed files with 225 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
version: '3'
version: "3"
includes:
common: ../Taskfile.yml
@@ -21,11 +21,11 @@ tasks:
# Auto-detect CGO: if CGO_ENABLED=1, use Docker; otherwise use native Go cross-compile
- task: '{{if and (ne OS "windows") (eq .CGO_ENABLED "1")}}build:docker{{else}}build:native{{end}}'
vars:
ARCH: '{{.ARCH}}'
DEV: '{{.DEV}}'
ARCH: "{{.ARCH}}"
DEV: "{{.DEV}}"
vars:
# Default to CGO_ENABLED=0 if not explicitly set
CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'
CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'--lzma
build:native:
summary: Builds the application using native Go cross-compilation
@@ -46,12 +46,13 @@ tasks:
platforms: [windows]
- cmd: rm -f *.syso
platforms: [linux, darwin]
- cmd: upx --best --lzma "{{.BIN_DIR}}/{{.APP_NAME}}.exe"
vars:
BUILD_FLAGS: '{{if eq .DEV "true"}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production -trimpath -buildvcs=false -ldflags="-w -s -H windowsgui"{{end}}'
env:
GOOS: windows
CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'
GOARCH: '{{.ARCH | default ARCH}}'
GOARCH: "{{.ARCH | default ARCH}}"
build:docker:
summary: Cross-compiles for Windows using Docker with Zig (for CGO builds on non-Windows)
@@ -104,7 +105,7 @@ tasks:
cmds:
- wails3 generate syso -arch {{.ARCH}} -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ../wails_windows_{{.ARCH}}.syso
vars:
ARCH: '{{.ARCH | default ARCH}}'
ARCH: "{{.ARCH | default ARCH}}"
create:nsis:installer:
summary: Creates an NSIS installer
@@ -114,14 +115,14 @@ tasks:
cmds:
# Create the Microsoft WebView2 bootstrapper if it doesn't exist
- wails3 generate webview2bootstrapper -dir "{{.ROOT_DIR}}/build/windows/nsis"
- |
- |
{{if eq OS "windows"}}
makensis -DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}\{{.BIN_DIR}}\{{.APP_NAME}}.exe" project.nsi
{{else}}
makensis -DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}.exe" project.nsi
{{end}}
vars:
ARCH: '{{.ARCH | default ARCH}}'
ARCH: "{{.ARCH | default ARCH}}"
ARG_FLAG: '{{if eq .ARCH "amd64"}}AMD64{{else}}ARM64{{end}}'
create:msix:package:
@@ -140,7 +141,7 @@ tasks:
{{if .PUBLISHER}}--publisher "{{.PUBLISHER}}"{{end}} \
{{if .USE_MSIX_TOOL}}--use-msix-tool{{else}}--use-makeappx{{end}}
vars:
ARCH: '{{.ARCH | default ARCH}}'
ARCH: "{{.ARCH | default ARCH}}"
CERT_PATH: '{{.CERT_PATH | default ""}}'
PUBLISHER: '{{.PUBLISHER | default ""}}'
USE_MSIX_TOOL: '{{.USE_MSIX_TOOL | default "false"}}'
@@ -152,7 +153,7 @@ tasks:
run:
cmds:
- '{{.BIN_DIR}}/{{.APP_NAME}}.exe'
- "{{.BIN_DIR}}/{{.APP_NAME}}.exe"
sign:
summary: Signs the Windows executable