diff --git a/.github/workflows/release-probo-agent.yaml b/.github/workflows/release-probo-agent.yaml index e2be0c427..6bb82715c 100644 --- a/.github/workflows/release-probo-agent.yaml +++ b/.github/workflows/release-probo-agent.yaml @@ -80,7 +80,7 @@ jobs: retention-days: 1 build-macos: - name: "macos (universal pkg + darwin archives)" + name: "macos (darwin pkg + darwin archives)" runs-on: "macos-26" permissions: contents: "read" @@ -112,7 +112,7 @@ jobs: security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" security list-keychain -d user -s "$KEYCHAIN_PATH" rm certificate.p12 - - name: "Build CGO darwin binaries and universal pkg" + - name: "Build CGO darwin binaries and darwin pkg" env: CGO_ENABLED: "1" CODESIGN_IDENTITY: "${{ secrets.CODESIGN_IDENTITY }}" @@ -151,18 +151,16 @@ jobs: done chmod +x cmd/probo-agent/installer/macos/build.sh \ - cmd/probo-agent/installer/macos/enroll-ui/build-app.sh \ cmd/probo-agent/installer/macos/scripts/preinstall \ cmd/probo-agent/installer/macos/scripts/postinstall cmd/probo-agent/installer/macos/build.sh \ --binary dist/probo-agent_universal \ - --arch universal \ --version "${VERSION}" \ - --output "archives/probo-agent_${VERSION}_darwin_universal.pkg" + --output "archives/probo-agent_${VERSION}_darwin.pkg" - uses: "actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a" # v7 with: - name: "archive-darwin-universal" + name: "archive-darwin" path: "archives/" retention-days: 1 diff --git a/cmd/probo-agent/GNUmakefile b/cmd/probo-agent/GNUmakefile index cc6b329d3..40967fb47 100644 --- a/cmd/probo-agent/GNUmakefile +++ b/cmd/probo-agent/GNUmakefile @@ -69,7 +69,12 @@ ARCHIVE_PATH= $(RELEASE_DIR)/$(ARCHIVE_NAME) STAGING_DIR= $(CACHE_ROOT)/staging/$(AGENT_DIR) BUILD_BINARY= $(STAGING_DIR)/probo-agent -PKG= $(REPO_ROOT)/dist/probo-agent_$(VERSION)_darwin_$(ARCH_LABEL).pkg +# Fat binary required by installer/macos/build.sh (arm64 + x86_64). +FAT_BINARY= $(REPO_ROOT)/dist/probo-agent_fat +THIN_ARM64= $(REPO_ROOT)/dist/probo-agent_arm64 +THIN_AMD64= $(REPO_ROOT)/dist/probo-agent_amd64 +PKG= $(REPO_ROOT)/dist/probo-agent_$(VERSION)_darwin.pkg +AGENT_LDFLAGS= -ldflags "-X 'main.version=$(VERSION)'" INSTALL_ARGS?= --skip-service --dir "$(STATE_DIR)" INSTALL_ENV= PROBO_AGENT_RELEASE_TAG="$(DEV_TAG)" \ @@ -80,7 +85,7 @@ INSTALL_ENV= PROBO_AGENT_RELEASE_TAG="$(DEV_TAG)" \ PROBO_ENROLLMENT_TOKEN="$(PROBO_ENROLLMENT_TOKEN)" .PHONY: help all pkg install uninstall clean clean-build install-cli run -.PHONY: $(PROBO_AGENT_BIN) +.PHONY: $(PROBO_AGENT_BIN) $(FAT_BINARY) all: help @@ -122,8 +127,7 @@ clean: uninstall clean-build ## uninstall + wipe build caches clean-build: ## Wipe local build caches (no sudo) $(RMRF) "$(STATE_DIR)" "$(CACHE_ROOT)" "$(ENROLL_UI_BUILD)" - @# Unquoted globs so the shell can expand dist artifacts. - -$(RMRF) $(REPO_ROOT)/dist/probo-agent_*.pkg + -$(RMRF) "$(PKG)" "$(FAT_BINARY)" "$(THIN_ARM64)" "$(THIN_AMD64)" @# Native binary under /usr/local is owned by root after install; leave it @# to `uninstall`. Never remove it here without sudo. @@ -131,7 +135,20 @@ clean-build: ## Wipe local build caches (no sudo) pkg: $(PKG) ## Build signed .pkg into dist/ -$(PKG): $(PROBO_AGENT_BIN) +$(FAT_BINARY): +ifeq ($(UNAME_S),Darwin) + @$(MKDIR) "$(dir $(FAT_BINARY))" + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build $(AGENT_LDFLAGS) \ + -o "$(THIN_ARM64)" "$(REPO_ROOT)/cmd/probo-agent" + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build $(AGENT_LDFLAGS) \ + -o "$(THIN_AMD64)" "$(REPO_ROOT)/cmd/probo-agent" + lipo -create "$(THIN_ARM64)" "$(THIN_AMD64)" -output "$(FAT_BINARY)" +else + @echo 'error: fat binary target is macOS-only' >&2 + @exit 1 +endif + +$(PKG): $(FAT_BINARY) ifeq ($(UNAME_S),Darwin) @if [ -z "$(CODESIGN_IDENTITY)" ]; then \ echo 'error: CODESIGN_IDENTITY is required' >&2; exit 2; \ @@ -139,9 +156,6 @@ ifeq ($(UNAME_S),Darwin) @if [ -z "$(APPLE_TEAM_ID)" ]; then \ echo 'error: APPLE_TEAM_ID is required' >&2; exit 2; \ fi - @if [ -z "$(BUILD_ARCH)" ]; then \ - echo 'error: unsupported arch $(UNAME_M)' >&2; exit 2; \ - fi @$(MKDIR) "$(dir $(PKG))" @CODESIGN_IDENTITY="$(CODESIGN_IDENTITY)" \ APPLE_TEAM_ID="$(APPLE_TEAM_ID)" \ @@ -150,8 +164,7 @@ ifeq ($(UNAME_S),Darwin) APPLE_ID_PASSWORD="$(APPLE_ID_PASSWORD)" \ NOTARYTOOL_KEYCHAIN_PROFILE="$(NOTARYTOOL_KEYCHAIN_PROFILE)" \ sh "$(MACOS_BUILD_SCRIPT)" \ - --binary "$(PROBO_AGENT_BIN)" \ - --arch "$(BUILD_ARCH)" \ + --binary "$(FAT_BINARY)" \ --version "$(VERSION)" \ --output "$(PKG)" else diff --git a/cmd/probo-agent/installer/macos/Distribution.xml.tmpl b/cmd/probo-agent/installer/macos/Distribution.xml.tmpl index d4df3185b..22a4c244c 100644 --- a/cmd/probo-agent/installer/macos/Distribution.xml.tmpl +++ b/cmd/probo-agent/installer/macos/Distribution.xml.tmpl @@ -6,10 +6,9 @@ Placeholders are substituted by build.sh: @@VERSION@@ agent version, e.g. 0.1.0 - @@PKG_ARCH@@ reserved (legacy; host filter uses @@HOST_ARCHS@@) - @@HOST_ARCHS@@ host arch filter used by Installer.app - (e.g. arm64 or arm64,x86_64 for universal) @@IDENTIFIER@@ package identifier (default com.probo.agent) + + hostArchitectures is fixed to arm64,x86_64 (fat binary installer). --> Probo Device Posture Agent @@VERSION@@ @@ -22,7 +21,7 @@ + hostArchitectures="arm64,x86_64"/>