|
| 1 | +version: '3' |
| 2 | + |
| 3 | +includes: |
| 4 | + common: ../Taskfile.yml |
| 5 | + |
| 6 | +tasks: |
| 7 | + build: |
| 8 | + summary: Creates a production build of the application |
| 9 | + deps: |
| 10 | + - task: common:go:mod:tidy |
| 11 | + - task: common:build:frontend |
| 12 | + vars: |
| 13 | + BUILD_FLAGS: |
| 14 | + ref: .BUILD_FLAGS |
| 15 | + PRODUCTION: |
| 16 | + ref: .PRODUCTION |
| 17 | + - task: common:generate:icons |
| 18 | + cmds: |
| 19 | + - go build {{.BUILD_FLAGS}} -o {{.OUTPUT}} |
| 20 | + vars: |
| 21 | + BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false -ldflags="-w -s"{{else}}-buildvcs=false -gcflags=all="-l"{{end}}' |
| 22 | + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' |
| 23 | + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' |
| 24 | + env: |
| 25 | + GOOS: darwin |
| 26 | + CGO_ENABLED: 1 |
| 27 | + GOARCH: '{{.ARCH | default ARCH}}' |
| 28 | + CGO_CFLAGS: "-mmacosx-version-min=10.15" |
| 29 | + CGO_LDFLAGS: "-mmacosx-version-min=10.15" |
| 30 | + MACOSX_DEPLOYMENT_TARGET: "10.15" |
| 31 | + PRODUCTION: '{{.PRODUCTION | default "false"}}' |
| 32 | + |
| 33 | + build:universal: |
| 34 | + summary: Builds darwin universal binary (arm64 + amd64) |
| 35 | + deps: |
| 36 | + - task: build |
| 37 | + vars: |
| 38 | + ARCH: amd64 |
| 39 | + OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" |
| 40 | + - task: build |
| 41 | + vars: |
| 42 | + ARCH: arm64 |
| 43 | + OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" |
| 44 | + cmds: |
| 45 | + - lipo -create -output "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" |
| 46 | + - rm "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" |
| 47 | + |
| 48 | + package: |
| 49 | + summary: Packages a production build of the application into a `.app` bundle |
| 50 | + deps: |
| 51 | + - task: build |
| 52 | + vars: |
| 53 | + PRODUCTION: "true" |
| 54 | + cmds: |
| 55 | + - task: create:app:bundle |
| 56 | + |
| 57 | + package:universal: |
| 58 | + summary: Packages darwin universal binary (arm64 + amd64) |
| 59 | + deps: |
| 60 | + - task: build:universal |
| 61 | + cmds: |
| 62 | + - task: create:app:bundle |
| 63 | + |
| 64 | + |
| 65 | + create:app:bundle: |
| 66 | + summary: Creates an `.app` bundle |
| 67 | + cmds: |
| 68 | + - mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/{MacOS,Resources} |
| 69 | + - cp build/darwin/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources |
| 70 | + - cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS |
| 71 | + - cp build/darwin/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents |
| 72 | + - codesign --force --deep --sign - {{.BIN_DIR}}/{{.APP_NAME}}.app |
| 73 | + |
| 74 | + run: |
| 75 | + cmds: |
| 76 | + - mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/{MacOS,Resources} |
| 77 | + - cp build/darwin/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources |
| 78 | + - cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS |
| 79 | + - cp build/darwin/Info.dev.plist {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Info.plist |
| 80 | + - codesign --force --deep --sign - {{.BIN_DIR}}/{{.APP_NAME}}.dev.app |
| 81 | + - '{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS/{{.APP_NAME}}' |
0 commit comments