Taskfile.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. version: '3'
  2. includes:
  3. common: ../Taskfile.yml
  4. vars:
  5. # Signing configuration - edit these values for your project
  6. # SIGN_CERTIFICATE: "path/to/certificate.pfx"
  7. # SIGN_THUMBPRINT: "certificate-thumbprint" # Alternative to SIGN_CERTIFICATE
  8. # TIMESTAMP_SERVER: "http://timestamp.digicert.com"
  9. #
  10. # Password is stored securely in system keychain. Run: wails3 setup signing
  11. tasks:
  12. build:
  13. summary: Builds the application for Windows
  14. # MPCkit builds on each system natively; there is no Docker cross-build.
  15. # Without cgo (the default) Go can still cross-compile for Windows.
  16. preconditions:
  17. - sh: '{{if and (ne OS "windows") (eq .CGO_ENABLED "1")}}false{{else}}true{{end}}'
  18. msg: "A cgo build for Windows must be made on Windows."
  19. cmds:
  20. - task: build:native
  21. vars:
  22. ARCH: '{{.ARCH}}'
  23. DEV: '{{.DEV}}'
  24. EXTRA_TAGS: '{{.EXTRA_TAGS}}'
  25. OBFUSCATED: '{{.OBFUSCATED}}'
  26. GARBLE_ARGS: '{{.GARBLE_ARGS}}'
  27. vars:
  28. # Default to CGO_ENABLED=0 if not explicitly set
  29. CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'
  30. build:native:
  31. summary: Builds the application using native Go cross-compilation
  32. internal: true
  33. deps:
  34. - task: common:go:mod:tidy
  35. - task: common:build:frontend
  36. vars:
  37. BUILD_FLAGS:
  38. ref: .BUILD_FLAGS
  39. OBFUSCATED:
  40. ref: .OBFUSCATED
  41. DEV:
  42. ref: .DEV
  43. - task: common:generate:icons
  44. preconditions:
  45. - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}'
  46. msg: "garble is required for obfuscated builds. Install it with: go install mvdan.cc/garble@v0.16.0 (requires Go 1.24+). See https://github.com/burrowers/garble/releases for version/toolchain compatibility."
  47. cmds:
  48. - task: generate:syso
  49. vars:
  50. ARCH: '{{.ARCH}}'
  51. - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o "{{.BIN_DIR}}/{{.APP_NAME}}.exe"'
  52. - cmd: powershell Remove-item *.syso
  53. platforms: [windows]
  54. - cmd: rm -f *.syso
  55. platforms: [linux, darwin]
  56. vars:
  57. BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.APP_VERSION}} -X git.monoexp.com/bajdev/mpckit/internal/app.Commit={{.COMMIT}} -H windowsgui"{{end}}'
  58. env:
  59. GOOS: windows
  60. CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'
  61. GOARCH: '{{.ARCH | default ARCH}}'
  62. package:
  63. summary: Packages the application
  64. cmds:
  65. - task: '{{if eq (.FORMAT | default "nsis") "msix"}}create:msix:package{{else}}create:nsis:installer{{end}}'
  66. vars:
  67. INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}'
  68. vars:
  69. FORMAT: '{{.FORMAT | default "nsis"}}'
  70. INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}'
  71. generate:syso:
  72. summary: Generates Windows `.syso` file
  73. dir: build
  74. cmds:
  75. - wails3 generate syso -arch {{.ARCH}} -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ../wails_windows_{{.ARCH}}.syso
  76. vars:
  77. ARCH: '{{.ARCH | default ARCH}}'
  78. create:nsis:installer:
  79. summary: Creates an NSIS installer
  80. dir: build/windows/nsis
  81. deps:
  82. - task: build
  83. preconditions:
  84. - sh: '[ "{{.INSTALL_SCOPE}}" = "user" ] || [ "{{.INSTALL_SCOPE}}" = "machine" ]'
  85. msg: "INSTALL_SCOPE must be 'user' or 'machine', got '{{.INSTALL_SCOPE}}'"
  86. cmds:
  87. # Create the Microsoft WebView2 bootstrapper if it doesn't exist
  88. - wails3 generate webview2bootstrapper -dir "{{.ROOT_DIR}}/build/windows/nsis"
  89. - |
  90. {{if eq OS "windows"}}
  91. makensis {{if eq .INSTALL_SCOPE "user"}}-DWAILS_INSTALL_SCOPE=user -DREQUEST_EXECUTION_LEVEL=user {{end}}-DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}\{{.BIN_DIR}}\{{.APP_NAME}}.exe" project.nsi
  92. {{else}}
  93. makensis {{if eq .INSTALL_SCOPE "user"}}-DWAILS_INSTALL_SCOPE=user -DREQUEST_EXECUTION_LEVEL=user {{end}}-DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}.exe" project.nsi
  94. {{end}}
  95. vars:
  96. ARCH: '{{.ARCH | default ARCH}}'
  97. ARG_FLAG: '{{if eq .ARCH "amd64"}}AMD64{{else}}ARM64{{end}}'
  98. INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}'
  99. create:msix:package:
  100. summary: Creates an MSIX package
  101. deps:
  102. - task: build
  103. cmds:
  104. - |-
  105. wails3 tool msix \
  106. --config "{{.ROOT_DIR}}/build/config.yml" \
  107. --name "{{.APP_NAME}}.exe" \
  108. --executable "{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}.exe" \
  109. --arch "{{.ARCH}}" \
  110. --out "{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}-{{.ARCH}}.msix" \
  111. {{if .CERT_PATH}}--cert "{{.CERT_PATH}}"{{end}} \
  112. {{if .PUBLISHER}}--publisher "{{.PUBLISHER}}"{{end}} \
  113. {{if eq .USE_MSIX_TOOL "true"}}--use-msix-tool{{else}}--use-makeappx{{end}}
  114. vars:
  115. ARCH: '{{.ARCH | default ARCH}}'
  116. CERT_PATH: '{{.CERT_PATH | default ""}}'
  117. PUBLISHER: '{{.PUBLISHER | default ""}}'
  118. USE_MSIX_TOOL: '{{.USE_MSIX_TOOL | default "false"}}'
  119. install:msix:tools:
  120. summary: Installs tools required for MSIX packaging
  121. cmds:
  122. - wails3 tool msix-install-tools
  123. run:
  124. cmds:
  125. - '{{.BIN_DIR}}/{{.APP_NAME}}.exe'
  126. sign:
  127. summary: Signs the Windows executable
  128. desc: |
  129. Signs the .exe with an Authenticode certificate.
  130. Set SIGN_CERTIFICATE or SIGN_THUMBPRINT to override the certificate
  131. configured globally via `wails3 setup` (~/.config/wails/defaults.yaml).
  132. Password is retrieved from system keychain (run: wails3 setup signing)
  133. deps:
  134. - task: build
  135. cmds:
  136. # Certificate vars are optional: if unset, `wails3 tool sign` falls back to
  137. # the certificate configured globally via `wails3 setup`.
  138. - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.exe" {{if .SIGN_CERTIFICATE}}--certificate "{{.SIGN_CERTIFICATE}}"{{end}} {{if .SIGN_THUMBPRINT}}--thumbprint "{{.SIGN_THUMBPRINT}}"{{end}} {{if .TIMESTAMP_SERVER}}--timestamp "{{.TIMESTAMP_SERVER}}"{{end}}
  139. sign:installer:
  140. summary: Signs the NSIS installer
  141. desc: |
  142. Creates and signs the NSIS installer.
  143. Set SIGN_CERTIFICATE or SIGN_THUMBPRINT to override the certificate
  144. configured globally via `wails3 setup` (~/.config/wails/defaults.yaml).
  145. Password is retrieved from system keychain (run: wails3 setup signing)
  146. deps:
  147. - task: create:nsis:installer
  148. vars:
  149. INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}'
  150. vars:
  151. INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}'
  152. cmds:
  153. - wails3 tool sign --input "build/windows/nsis/{{.APP_NAME}}-installer.exe" {{if .SIGN_CERTIFICATE}}--certificate "{{.SIGN_CERTIFICATE}}"{{end}} {{if .SIGN_THUMBPRINT}}--thumbprint "{{.SIGN_THUMBPRINT}}"{{end}} {{if .TIMESTAMP_SERVER}}--timestamp "{{.TIMESTAMP_SERVER}}"{{end}}