From ff3ecefd247fba63b95b6a995a746a3b8e1e1d0f Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 15:37:44 -0400 Subject: [PATCH] fix(cli): sign macOS preview binaries (#40662) Co-authored-by: Ryan Vogel <89211796+R44VC0RP@users.noreply.github.com> --- .github/workflows/publish.yml | 57 +++++++++++++++++++++++++- packages/cli/script/entitlements.plist | 16 ++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 packages/cli/script/entitlements.plist diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9b02b1ff5b..102166a4df 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -124,12 +124,66 @@ jobs: - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: opencode-preview-cli + name: opencode-preview-cli-unsigned path: packages/cli/dist/cli-* outputs: version: ${{ needs.version.outputs.version }} + sign-cli-macos: + needs: build-cli + runs-on: macos-26 + if: github.repository == 'anomalyco/opencode' + steps: + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0 + with: + keychain: build + p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }} + p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: opencode-preview-cli-unsigned + path: packages/cli/dist + + - name: Sign macOS CLI binaries + run: | + identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1) + if [ -z "$identity" ]; then + echo "Developer ID Application identity not found" + exit 1 + fi + + found=0 + for file in packages/cli/dist/cli-darwin-*/bin/opencode2; do + if [ ! -f "$file" ]; then + continue + fi + found=1 + codesign \ + --force \ + --timestamp \ + --options runtime \ + --entitlements packages/cli/script/entitlements.plist \ + --sign "$identity" \ + "$file" + codesign --verify --deep --strict --verbose=4 "$file" + codesign --display --requirements - "$file" + done + + if [ "$found" -eq 0 ]; then + echo "No macOS CLI binaries found" + exit 1 + fi + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: opencode-preview-cli + path: packages/cli/dist/cli-* + if-no-files-found: error + build-node-cli: needs: version if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta' @@ -468,6 +522,7 @@ jobs: needs: - version - build-cli + - sign-cli-macos - build-node-cli - sign-cli-windows - build-electron diff --git a/packages/cli/script/entitlements.plist b/packages/cli/script/entitlements.plist new file mode 100644 index 0000000000..afa54db33b --- /dev/null +++ b/packages/cli/script/entitlements.plist @@ -0,0 +1,16 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-executable-page-protection + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.disable-library-validation + + +