Taskfile.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. version: '3'
  2. includes:
  3. common: ../Taskfile.yml
  4. vars:
  5. # Signing configuration - edit these values for your project
  6. # PGP_KEY: "path/to/signing-key.asc"
  7. # SIGN_ROLE: "builder" # Options: origin, maint, archive, builder
  8. #
  9. # Password is stored securely in system keychain. Run: wails3 setup signing
  10. tasks:
  11. build:
  12. summary: Builds the application for Linux
  13. # MPCkit builds on each system natively; there is no Docker cross-build.
  14. # The experimental CGO-free backend (-tags purego) uses the Go toolchain
  15. # directly on every host; a cgo build needs Linux, a C compiler and the
  16. # same architecture.
  17. preconditions:
  18. - sh: '{{if or (ne .CGO_ENABLED "1") (and (eq OS "linux") (eq .HAS_CC "true") (eq .TARGET_ARCH ARCH))}}true{{else}}false{{end}}'
  19. msg: "The Linux app must be built on Linux, with gcc or clang, for the same architecture."
  20. cmds:
  21. - task: build:native
  22. vars:
  23. ARCH: '{{.ARCH}}'
  24. DEV: '{{.DEV}}'
  25. OUTPUT: '{{.OUTPUT}}'
  26. EXTRA_TAGS: '{{.EXTRA_TAGS}}'
  27. OBFUSCATED: '{{.OBFUSCATED}}'
  28. GARBLE_ARGS: '{{.GARBLE_ARGS}}'
  29. CGO_ENABLED: '{{.CGO_ENABLED}}'
  30. vars:
  31. DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
  32. OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
  33. # Determine target architecture (defaults to host ARCH if not specified)
  34. TARGET_ARCH: '{{.ARCH | default ARCH}}'
  35. CGO_ENABLED: '{{.CGO_ENABLED | default (ternary "0" "1" (has "purego" (splitList "," (.EXTRA_TAGS | default ""))))}}'
  36. # Check if a C compiler is available (gcc or clang) — cross-platform via wails3 tool
  37. HAS_CC:
  38. sh: 'wails3 tool has "gcc|clang"'
  39. build:native:
  40. summary: Builds the application natively on Linux
  41. internal: true
  42. deps:
  43. - task: common:go:mod:tidy
  44. - task: common:build:frontend
  45. vars:
  46. BUILD_FLAGS:
  47. ref: .BUILD_FLAGS
  48. OBFUSCATED:
  49. ref: .OBFUSCATED
  50. DEV:
  51. ref: .DEV
  52. - task: common:generate:icons
  53. - task: generate:dotdesktop
  54. preconditions:
  55. - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}'
  56. 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."
  57. cmds:
  58. - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o {{.OUTPUT}}'
  59. vars:
  60. 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}}"{{end}}'
  61. DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
  62. OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
  63. env:
  64. GOOS: linux
  65. CGO_ENABLED: '{{.CGO_ENABLED | default (ternary "0" "1" (has "purego" (splitList "," (.EXTRA_TAGS | default ""))))}}'
  66. GOARCH: '{{.ARCH | default ARCH}}'
  67. package:
  68. summary: Packages the application for Linux
  69. deps:
  70. - task: build
  71. cmds:
  72. - task: create:appimage
  73. - task: create:deb
  74. - task: create:rpm
  75. - task: create:aur
  76. create:appimage:
  77. summary: Creates an AppImage
  78. dir: build/linux/appimage
  79. deps:
  80. - task: build
  81. - task: generate:dotdesktop
  82. cmds:
  83. - cp "{{.APP_BINARY}}" "{{.APP_NAME}}"
  84. - cp ../../appicon.png "{{.APP_NAME}}.png"
  85. - wails3 generate appimage -binary "{{.APP_NAME}}" -icon {{.ICON}} -desktopfile {{.DESKTOP_FILE}} -outputdir {{.OUTPUT_DIR}} -builddir {{.ROOT_DIR}}/build/linux/appimage/build
  86. vars:
  87. APP_NAME: '{{.APP_NAME}}'
  88. APP_BINARY: '../../../bin/{{.APP_NAME}}'
  89. ICON: '{{.APP_NAME}}.png'
  90. DESKTOP_FILE: '../{{.APP_NAME}}.desktop'
  91. OUTPUT_DIR: '../../../bin'
  92. create:deb:
  93. summary: Creates a deb package
  94. deps:
  95. - task: build
  96. cmds:
  97. - task: generate:dotdesktop
  98. - task: generate:deb
  99. create:rpm:
  100. summary: Creates a rpm package
  101. deps:
  102. - task: build
  103. cmds:
  104. - task: generate:dotdesktop
  105. - task: generate:rpm
  106. create:aur:
  107. summary: Creates a arch linux packager package
  108. deps:
  109. - task: build
  110. cmds:
  111. - task: generate:dotdesktop
  112. - task: generate:aur
  113. generate:deb:
  114. summary: Creates a deb package
  115. cmds:
  116. - wails3 tool package -name "{{.APP_NAME}}" -format deb -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin
  117. generate:rpm:
  118. summary: Creates a rpm package
  119. cmds:
  120. - wails3 tool package -name "{{.APP_NAME}}" -format rpm -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin
  121. generate:aur:
  122. summary: Creates a arch linux packager package
  123. cmds:
  124. - wails3 tool package -name "{{.APP_NAME}}" -format archlinux -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin
  125. generate:dotdesktop:
  126. summary: Generates a `.desktop` file
  127. dir: build
  128. cmds:
  129. - mkdir -p {{.ROOT_DIR}}/build/linux/appimage
  130. - wails3 generate .desktop -name "{{.PRODUCT_NAME}}" -exec "{{.EXEC}}" -icon "{{.ICON}}" -outputfile "{{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop" -categories "{{.CATEGORIES}}"
  131. vars:
  132. APP_NAME: '{{.APP_NAME}}'
  133. EXEC: '{{.APP_NAME}}'
  134. ICON: '{{.APP_NAME}}'
  135. CATEGORIES: 'Development;'
  136. OUTPUTFILE: '{{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop'
  137. run:
  138. cmds:
  139. - '{{.BIN_DIR}}/{{.APP_NAME}}'
  140. sign:deb:
  141. summary: Signs the DEB package
  142. desc: |
  143. Signs the .deb package with a PGP key.
  144. Set PGP_KEY in the vars section to override the key configured globally via
  145. `wails3 setup` (~/.config/wails/defaults.yaml).
  146. Password is retrieved from system keychain (run: wails3 setup signing)
  147. deps:
  148. - task: create:deb
  149. cmds:
  150. # PGP_KEY is optional: if unset, `wails3 tool sign` falls back to the key
  151. # configured globally via `wails3 setup`.
  152. - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}*.deb" {{if .PGP_KEY}}--pgp-key "{{.PGP_KEY}}"{{end}} {{if .SIGN_ROLE}}--role "{{.SIGN_ROLE}}"{{end}}
  153. sign:rpm:
  154. summary: Signs the RPM package
  155. desc: |
  156. Signs the .rpm package with a PGP key.
  157. Set PGP_KEY in the vars section to override the key configured globally via
  158. `wails3 setup` (~/.config/wails/defaults.yaml).
  159. Password is retrieved from system keychain (run: wails3 setup signing)
  160. deps:
  161. - task: create:rpm
  162. cmds:
  163. - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}*.rpm" {{if .PGP_KEY}}--pgp-key "{{.PGP_KEY}}"{{end}}
  164. sign:packages:
  165. summary: Signs all Linux packages (DEB and RPM)
  166. desc: |
  167. Signs both .deb and .rpm packages with a PGP key.
  168. Set PGP_KEY in the vars section to override the key configured globally via
  169. `wails3 setup` (~/.config/wails/defaults.yaml).
  170. Password is retrieved from system keychain (run: wails3 setup signing)
  171. cmds:
  172. - task: sign:deb
  173. - task: sign:rpm