| 1 | name: Build Cage for Apple Silicon |
| 2 | on: |
| 3 | workflow_call: |
| 4 | inputs: |
| 5 | ref: |
| 6 | description: Exact source commit SHA to build |
| 7 | required: true |
| 8 | type: string |
| 9 | release: |
| 10 | description: Build signed and notarized release files after checks |
| 11 | required: false |
| 12 | type: boolean |
| 13 | default: false |
| 14 | artifact_name: |
| 15 | description: Name of the resulting workflow artifact |
| 16 | required: true |
| 17 | type: string |
| 18 | permissions: |
| 19 | contents: read |
| 20 | |
| 21 | jobs: |
| 22 | checks: |
| 23 | |
| 24 | runs-on: macos-15 |
| 25 | timeout-minutes: 45 |
| 26 | defaults: |
| 27 | run: |
| 28 | shell: bash |
| 29 | steps: |
| 30 | - uses: actions/checkout@v4 |
| 31 | with: |
| 32 | ref: ${{ inputs.ref }} |
| 33 | persist-credentials: false |
| 34 | - name: Verify the exact source and Apple Silicon runner |
| 35 | env: |
| 36 | BUILD_REF: ${{ inputs.ref }} |
| 37 | RELEASE_BUILD: ${{ inputs.release }} |
| 38 | run: | |
| 39 | [[ "$BUILD_REF" =~ ^[0-9a-f]{40}$ ]] || { echo 'Pass an exact commit SHA.' >&2; exit 1; } |
| 40 | [[ "$(git rev-parse HEAD)" == "$BUILD_REF" ]] |
| 41 | [[ "$(uname -s)" == Darwin && "$(uname -m)" == arm64 ]] |
| 42 | if [[ "$RELEASE_BUILD" == true && "$GITHUB_EVENT_NAME" != workflow_dispatch ]]; then |
| 43 | echo 'Release candidates require an explicit release dispatch.' >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | - uses: actions/setup-go@v5 |
| 47 | with: |
| 48 | go-version-file: go.mod |
| 49 | - uses: actions/setup-node@v4 |
| 50 | with: |
| 51 | node-version: 24 |
| 52 | cache: npm |
| 53 | cache-dependency-path: ui/package-lock.json |
| 54 | - uses: astral-sh/[email protected] |
| 55 | - name: Application version consistency |
| 56 | run: | |
| 57 | node scripts/check-version.mjs |
| 58 | node --test scripts/macos-sshfs-sources.test.mjs |
| 59 | - name: Install SSHFS build dependencies |
| 60 | run: | |
| 61 | brew install glib gettext pcre2 |
| 62 | brew upgrade glib gettext pcre2 |
| 63 | - name: Build the macOS application without release credentials |
| 64 | env: |
| 65 | CAGE_SIGNING_IDENTITY: '-' |
| 66 | run: bash scripts/build-app.sh |
| 67 | - name: Workbench checks |
| 68 | run: | |
| 69 | npm run --prefix ui lint |
| 70 | npm test --prefix ui |
| 71 | node --test internal/cage/clipboard.test.cjs internal/cage/browser-audit.test.mjs internal/cage/browser-downloads.test.mjs internal/cage/browser-uploads.test.mjs internal/cage/browser-login.test.mjs internal/cage/browser-clipboard.test.mjs internal/cage/native-input.test.mjs internal/cage/display-density.test.mjs |
| 72 | uv run internal/cage/claude-account.test.py |
| 73 | uv run internal/cage/display-governor.test.py |
| 74 | uv run internal/cage/save-download.test.py |
| 75 | uv run internal/cage/editor-migrate.test.py |
| 76 | - name: Go tests and vet |
| 77 | run: | |
| 78 | make test-go |
| 79 | go test -race ./internal/cage ./internal/managedproxy ./internal/workbench |
| 80 | go vet ./cmd/cage ./internal/cage ./internal/managedproxy ./internal/workbench |
| 81 | - name: Native application updater |
| 82 | run: bash scripts/test-app-updates.sh |
| 83 | - name: External Agent CLI with an isolated profile |
| 84 | run: node scripts/agent-cli-smoke.mjs "$PWD/_output/Cage.app/Contents/Resources/cage" |
| 85 | - name: Native account credential status |
| 86 | run: bash scripts/test-account-device.sh |
| 87 | - name: Patched networking and shared files |
| 88 | run: go test github.com/containers/gvisor-tap-vsock/pkg/services/dns github.com/lima-vm/lima/v2/pkg/hostagent/dns github.com/lima-vm/lima/v2/pkg/networks/usernet github.com/lima-vm/sshocker/pkg/reversesshfs |
| 89 | - name: Dependency licenses |
| 90 | run: bash scripts/licenses --check |
| 91 | - name: Verify the application bundle |
| 92 | run: | |
| 93 | codesign --verify --deep --strict _output/Cage.app |
| 94 | _output/Cage.app/Contents/Resources/cage --help |
| 95 | _output/Cage.app/Contents/Resources/mihomo -v |
| 96 | [[ "$(lipo -archs _output/Cage.app/Contents/MacOS/Cage)" == arm64 ]] |
| 97 | - name: Archive a complete development App with executable permissions |
| 98 | if: ${{ !inputs.release }} |
| 99 | run: | |
| 100 | version=$(tr -d '\r\n' < VERSION) |
| 101 | mkdir -p _output/ci-macos-test |
| 102 | archive="$PWD/_output/ci-macos-test/Cage-$version-macos-arm64-test.tar.gz" |
| 103 | tar -czf "$archive" -C _output Cage.app |
| 104 | check=$(mktemp -d "$RUNNER_TEMP/cage-app-archive.XXXXXX") |
| 105 | trap 'rm -rf "$check"' EXIT |
| 106 | tar -xzf "$archive" -C "$check" |
| 107 | codesign --verify --deep --strict "$check/Cage.app" |
| 108 | for executable in Contents/MacOS/Cage Contents/Resources/cage Contents/Resources/mihomo Contents/Resources/CageUpdateInstaller; do |
| 109 | test -x "$check/Cage.app/$executable" |
| 110 | done |
| 111 | (cd _output/ci-macos-test && shasum -a 256 "${archive##*/}" > SHA256SUMS) |
| 112 | - uses: actions/upload-artifact@v4 |
| 113 | if: ${{ !inputs.release }} |
| 114 | with: |
| 115 | name: ${{ inputs.artifact_name }} |
| 116 | path: _output/ci-macos-test/ |
| 117 | if-no-files-found: error |
| 118 | overwrite: true |
| 119 | compression-level: 0 |
| 120 | retention-days: 14 |
| 121 | |
| 122 | release: |
| 123 | if: ${{ inputs.release && github.event_name == 'workflow_dispatch' }} |
| 124 | needs: checks |
| 125 | runs-on: macos-15 |
| 126 | environment: cage-release |
| 127 | timeout-minutes: 75 |
| 128 | defaults: |
| 129 | run: |
| 130 | shell: bash |
| 131 | steps: |
| 132 | - uses: actions/checkout@v4 |
| 133 | with: |
| 134 | ref: ${{ inputs.ref }} |
| 135 | persist-credentials: false |
| 136 | - name: Verify the exact source and Apple Silicon runner |
| 137 | env: |
| 138 | BUILD_REF: ${{ inputs.ref }} |
| 139 | run: | |
| 140 | [[ "$BUILD_REF" =~ ^[0-9a-f]{40}$ ]] |
| 141 | [[ "$(git rev-parse HEAD)" == "$BUILD_REF" ]] |
| 142 | [[ "$(uname -s)" == Darwin && "$(uname -m)" == arm64 ]] |
| 143 | - uses: actions/setup-go@v5 |
| 144 | with: |
| 145 | go-version-file: go.mod |
| 146 | - uses: actions/setup-node@v4 |
| 147 | with: |
| 148 | node-version: 24 |
| 149 | cache: npm |
| 150 | cache-dependency-path: ui/package-lock.json |
| 151 | - name: Build, sign, notarize and verify using a temporary keychain |
| 152 | env: |
| 153 | CAGE_MACOS_P12_BASE64: ${{ secrets.CAGE_MACOS_P12_BASE64 }} |
| 154 | CAGE_MACOS_P12_PASSWORD: ${{ secrets.CAGE_MACOS_P12_PASSWORD }} |
| 155 | CAGE_MACOS_SIGNING_IDENTITY: ${{ secrets.CAGE_MACOS_SIGNING_IDENTITY }} |
| 156 | CAGE_MACOS_NOTARY_KEY_BASE64: ${{ secrets.CAGE_MACOS_NOTARY_KEY_BASE64 }} |
| 157 | CAGE_MACOS_NOTARY_KEY_ID: ${{ secrets.CAGE_MACOS_NOTARY_KEY_ID }} |
| 158 | CAGE_MACOS_NOTARY_ISSUER_ID: ${{ secrets.CAGE_MACOS_NOTARY_ISSUER_ID }} |
| 159 | CAGE_MACOS_PROVISIONING_PROFILE_BASE64: ${{ secrets.CAGE_MACOS_PROVISIONING_PROFILE_BASE64 }} |
| 160 | run: bash scripts/ci-macos-signing.sh run |
| 161 | - name: Remove temporary signing credentials |
| 162 | if: ${{ always() }} |
| 163 | run: bash scripts/ci-macos-signing.sh cleanup |
| 164 | - name: Stage only public release files |
| 165 | run: | |
| 166 | version=$(tr -d '\r\n' < VERSION) |
| 167 | source_version=$(sed -n 's/^version=//p' scripts/fetch-proxy-core.sh) |
| 168 | release="$PWD/_output/releases/$version" |
| 169 | node scripts/release-version.mjs metadata macos "$release/build-metadata.json" |
| 170 | mkdir -p _output/ci-macos-release |
| 171 | cp "$release/Cage-$version-macos-arm64.dmg" "$release/mihomo-$source_version-source.tar.gz" "$release/cage-macos-guest-$version-source.tar.gz" "$release/SHA256SUMS" "$release/build-metadata.json" _output/ci-macos-release/ |
| 172 | (cd _output/ci-macos-release && shasum -a 256 --check SHA256SUMS) |
| 173 | - uses: actions/upload-artifact@v4 |
| 174 | with: |
| 175 | name: ${{ inputs.artifact_name }} |
| 176 | path: _output/ci-macos-release/ |
| 177 | if-no-files-found: error |
| 178 | overwrite: true |
| 179 | compression-level: 0 |
| 180 | retention-days: 14 |