version: '3' includes: common: ../Taskfile.yml vars: # Signing configuration - edit these values for your project # SIGN_IDENTITY: "Developer ID Application: Your Company (TEAMID)" # KEYCHAIN_PROFILE: "my-notarize-profile" # ENTITLEMENTS: "build/darwin/entitlements.plist" # Docker image for cross-compilation (used when building on non-macOS) CROSS_IMAGE: wails-cross tasks: build: summary: Builds the application cmds: - task: '{{if eq OS "darwin"}}build:native{{else}}build:docker{{end}}' vars: ARCH: '{{.ARCH}}' DEV: '{{.DEV}}' OUTPUT: '{{.OUTPUT}}' vars: DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' build:native: summary: Builds the application natively on macOS internal: true deps: - task: common:go:mod:tidy - task: common:build:frontend vars: BUILD_FLAGS: ref: .BUILD_FLAGS DEV: ref: .DEV - task: common:generate:icons cmds: - go build {{.BUILD_FLAGS}} -o {{.OUTPUT}} vars: BUILD_FLAGS: '{{if eq .DEV "true"}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production -trimpath -buildvcs=false -ldflags="-w -s"{{end}}' DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' env: GOOS: darwin CGO_ENABLED: 1 GOARCH: '{{.ARCH | default ARCH}}' CGO_CFLAGS: "-mmacosx-version-min=10.15" CGO_LDFLAGS: "-mmacosx-version-min=10.15" MACOSX_DEPLOYMENT_TARGET: "10.15" build:docker: summary: Cross-compiles for macOS using Docker (for Linux/Windows hosts) internal: true deps: - task: common:build:frontend - task: common:generate:icons preconditions: - sh: docker info > /dev/null 2>&1 msg: "Docker is required for cross-compilation. Please install Docker." - sh: docker image inspect {{.CROSS_IMAGE}} > /dev/null 2>&1 msg: | Docker image '{{.CROSS_IMAGE}}' not found. Build it first: wails3 task setup:docker cmds: - docker run --rm -v "{{.ROOT_DIR}}:/app" {{.GO_CACHE_MOUNT}} {{.REPLACE_MOUNTS}} -e APP_NAME="{{.APP_NAME}}" {{.CROSS_IMAGE}} darwin {{.DOCKER_ARCH}} - docker run --rm -v "{{.ROOT_DIR}}:/app" alpine chown -R $(id -u):$(id -g) /app/bin - mkdir -p {{.BIN_DIR}} - mv "bin/{{.APP_NAME}}-darwin-{{.DOCKER_ARCH}}" "{{.OUTPUT}}" vars: DOCKER_ARCH: '{{if eq .ARCH "arm64"}}arm64{{else if eq .ARCH "amd64"}}amd64{{else}}arm64{{end}}' DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' # Mount Go module cache for faster builds GO_CACHE_MOUNT: sh: 'echo "-v ${GOPATH:-$HOME/go}/pkg/mod:/go/pkg/mod"' # Extract replace directives from go.mod and create -v mounts for each # Handles both relative (=> ../) and absolute (=> /) paths REPLACE_MOUNTS: sh: | grep -E '^replace .* => ' go.mod 2>/dev/null | while read -r line; do path=$(echo "$line" | sed -E 's/^replace .* => //' | tr -d '\r') # Convert relative paths to absolute if [ "${path#/}" = "$path" ]; then path="$(cd "$(dirname "$path")" 2>/dev/null && pwd)/$(basename "$path")" fi # Only mount if directory exists if [ -d "$path" ]; then echo "-v $path:$path:ro" fi done | tr '\n' ' ' build:universal: summary: Builds darwin universal binary (arm64 + amd64) deps: - task: build vars: ARCH: amd64 OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" - task: build vars: ARCH: arm64 OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" cmds: - task: '{{if eq OS "darwin"}}build:universal:lipo:native{{else}}build:universal:lipo:go{{end}}' build:universal:lipo:native: summary: Creates universal binary using native lipo (macOS) internal: true cmds: - lipo -create -output "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" - rm "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" build:universal:lipo:go: summary: Creates universal binary using wails3 tool lipo (Linux/Windows) internal: true cmds: - wails3 tool lipo -output "{{.BIN_DIR}}/{{.APP_NAME}}" -input "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" -input "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" - rm -f "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" package: summary: Packages the application into a `.app` bundle deps: - task: build cmds: - task: create:app:bundle package:universal: summary: Packages darwin universal binary (arm64 + amd64) deps: - task: build:universal cmds: - task: create:app:bundle create:app:bundle: summary: Creates an `.app` bundle cmds: - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS" - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources" - cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources" - cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS" - cp build/darwin/Info.plist "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents" - task: '{{if eq OS "darwin"}}codesign:adhoc{{else}}codesign:skip{{end}}' codesign:adhoc: summary: Ad-hoc signs the app bundle (macOS only) internal: true cmds: - codesign --force --deep --sign - "{{.BIN_DIR}}/{{.APP_NAME}}.app" codesign:skip: summary: Skips codesigning when cross-compiling internal: true cmds: - 'echo "Skipping codesign (not available on {{OS}}). Sign the .app on macOS before distribution."' run: cmds: - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS" - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources" - cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources" - cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS" - cp "build/darwin/Info.dev.plist" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Info.plist" - codesign --force --deep --sign - "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app" - '{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS/{{.APP_NAME}}' sign: summary: Signs the application bundle with Developer ID desc: | Signs the .app bundle for distribution. Configure SIGN_IDENTITY in the vars section at the top of this file. deps: - task: package cmds: - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.app" --identity "{{.SIGN_IDENTITY}}" {{if .ENTITLEMENTS}}--entitlements {{.ENTITLEMENTS}}{{end}} preconditions: - sh: '[ -n "{{.SIGN_IDENTITY}}" ]' msg: "SIGN_IDENTITY is required. Set it in the vars section at the top of build/darwin/Taskfile.yml" sign:notarize: summary: Signs and notarizes the application bundle desc: | Signs the .app bundle and submits it for notarization. Configure SIGN_IDENTITY and KEYCHAIN_PROFILE in the vars section at the top of this file. Setup (one-time): wails3 signing credentials --apple-id "you@email.com" --team-id "TEAMID" --password "app-specific-password" --profile "my-profile" deps: - task: package cmds: - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.app" --identity "{{.SIGN_IDENTITY}}" {{if .ENTITLEMENTS}}--entitlements {{.ENTITLEMENTS}}{{end}} --notarize --keychain-profile {{.KEYCHAIN_PROFILE}} preconditions: - sh: '[ -n "{{.SIGN_IDENTITY}}" ]' msg: "SIGN_IDENTITY is required. Set it in the vars section at the top of build/darwin/Taskfile.yml" - sh: '[ -n "{{.KEYCHAIN_PROFILE}}" ]' msg: "KEYCHAIN_PROFILE is required. Set it in the vars section at the top of build/darwin/Taskfile.yml"