From fee1edf80fe9459c2e4b75a11c5687aa708b1569 Mon Sep 17 00:00:00 2001 From: Grayson Adams Date: Thu, 26 Nov 2026 16:31:52 -0500 Subject: [PATCH] ci: attach universal macos builds of the mac tools to releases --- .github/workflows/mac-tools.yml | 106 ++++++++++++++++++++++++++++++++ CHANGELOG.md | 2 + NOTICE.md | 16 +++-- README.md | 17 +++-- docs/overview.md | 6 +- docs/setup.md | 26 +++++++- 6 files changed, 159 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/mac-tools.yml diff --git a/.github/workflows/mac-tools.yml b/.github/workflows/mac-tools.yml new file mode 100644 index 0000000..0312419 --- /dev/null +++ b/.github/workflows/mac-tools.yml @@ -0,0 +1,106 @@ +name: Mac tools + +# Builds universal (arm64 + x86_64) binaries of nac-relay and extract-key and +# attaches them to a release. These two tools are AGPL-3.0 and contain no +# rustpush code, so unlike the bridge they can be distributed as binaries +# (see NOTICE.md). Pull requests that touch this file build without +# publishing. + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: Existing release tag to build and attach the tools to + required: true + pull_request: + paths: + - .github/workflows/mac-tools.yml + +permissions: + contents: read + +jobs: + build: + name: Build universal binaries + runs-on: macos-15 + env: + TAG: ${{ inputs.tag || github.event.release.tag_name || 'test' }} + # The supported macOS range starts at 13. + MACOSX_DEPLOYMENT_TARGET: "13.0" + CGO_ENABLED: "1" + steps: + - uses: actions/checkout@v5 + with: + ref: ${{ inputs.tag || github.ref }} + - uses: actions/setup-go@v6 + with: + go-version-file: tools/macoun-relay/go.mod + - name: Build both architectures + run: | + set -euo pipefail + out="$PWD/out"; mkdir -p "$out" + for a in arm64:arm64 amd64:x86_64; do + goarch=${a%%:*}; clangarch=${a##*:} + export GOARCH=$goarch CGO_CFLAGS="-arch $clangarch" CGO_LDFLAGS="-arch $clangarch" + (cd tools/macoun-relay && go build -trimpath -o "$out/nac-relay-$goarch" ./tools/nac-relay) + (cd tools/extract-key && go build -trimpath -o "$out/extract-key-$goarch" .) + done + - name: Merge into universal binaries and check them + run: | + set -euo pipefail + cd out + for t in nac-relay extract-key; do + lipo -create -output "$t" "$t-arm64" "$t-amd64" + archs=$(lipo -archs "$t") + echo "$t: $archs" + [ "$archs" = "x86_64 arm64" ] || [ "$archs" = "arm64 x86_64" ] + for s in arm64 x86_64; do + lipo "$t" -thin "$s" -output "/tmp/$t-$s" + otool -l "/tmp/$t-$s" | grep -A3 LC_BUILD_VERSION | grep -q 'minos 13.0' + done + done + # Both slices start. nac-relay -h prints its flags and exits 0; + # the x86_64 slice runs under Rosetta on this runner. + ./nac-relay -h + arch -x86_64 ./nac-relay -h + - name: Package + run: | + set -euo pipefail + name="macoun-mac-tools-$TAG" + mkdir -p "pkg/$name" + cp out/nac-relay out/extract-key "pkg/$name/" + cp tools/macoun-relay/launchd/dev.macoun.relay.plist.template "pkg/$name/" + cp tools/macoun-relay/LICENSE "pkg/$name/LICENSE" + cat > "pkg/$name/SOURCE.txt" < sha256sums-mac-tools.txt + cat sha256sums-mac-tools.txt + - uses: actions/upload-artifact@v4 + with: + name: mac-tools + path: | + macoun-mac-tools-*.tar.gz + sha256sums-mac-tools.txt + + publish: + name: Attach to the release + needs: build + if: github.event_name != 'pull_request' + runs-on: ubuntu-24.04 + permissions: + contents: write + env: + TAG: ${{ inputs.tag || github.event.release.tag_name }} + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/download-artifact@v4 + with: + name: mac-tools + - run: gh release upload "$TAG" macoun-mac-tools-*.tar.gz sha256sums-mac-tools.txt --clobber --repo "${{ github.repository }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf6684..ddb01be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* Added universal macOS binaries of `nac-relay` and `extract-key` to releases + (`macoun-mac-tools-.tar.gz`). The bridge stays source only. * Added bubble and screen effects in both directions, through the `com.beeper.imessage.effect` content key. Outbound effects are sent on text messages only. See [docs/effects.md](docs/effects.md). diff --git a/NOTICE.md b/NOTICE.md index c4ef5e2..64d3313 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -46,12 +46,18 @@ compatible with this as a Larger Work, MPL section 3.3). ## Binaries -This repository publishes source only. A built binary links MPL-2.0, AGPL-3.0 +The bridge is published as source only. A built bridge links MPL-2.0, AGPL-3.0 and SSPL v1 code. Building and running it for your own account is the intended -use. Distributing a binary, or offering it to third parties as a service, -brings SSPL obligations that this combination with AGPL and MPL code cannot -satisfy, so the project does not publish binaries and asks that you do not -either. +use. Distributing a bridge binary, or offering it to third parties as a +service, brings SSPL obligations that this combination with AGPL and MPL code +cannot satisfy, so the project does not publish bridge binaries and asks that +you do not either. + +The Mac tools are different. `nac-relay` (`tools/macoun-relay/`) and +`extract-key` (`tools/extract-key/`) are AGPL-3.0, have no Go dependencies and +contain no rustpush code. Releases carry universal macOS binaries of the two +(`macoun-mac-tools-.tar.gz`, built by `.github/workflows/mac-tools.yml`), +with the AGPL-3.0 text and the source commit in the archive. ## corten-matrix parts that are not in its public source diff --git a/README.md b/README.md index 655b1a3..5fe7dcf 100644 --- a/README.md +++ b/README.md @@ -67,10 +67,10 @@ Mac does not interrupt messaging. Details: The full walk-through is [docs/setup.md](docs/setup.md). In short: -1. **On the Mac:** build `tools/macoun-relay`, install it as a LaunchAgent +1. **On the Mac:** download or build `nac-relay`, install it as a LaunchAgent bound to the Mac's private address, and note the relay token and certificate fingerprint. -2. **On the Mac:** run `tools/extract-key` once to get the hardware key the +2. **On the Mac:** run `extract-key` once to get the hardware key the bridge logs in with. 3. **On Linux:** build the bridge. @@ -99,7 +99,11 @@ The full walk-through is [docs/setup.md](docs/setup.md). In short: `MACOUN_NAC_RELAY_CERT_FP`), then log in from Matrix through the bridge bot with the hardware key, your Apple ID password and a 2FA code. -There are no binary releases; see [Licence](#licence) for why. +The bridge has no binary releases; see [Licence](#licence) for why. The two +Mac tools do: each [release](https://github.com/312-dev/macoun-matrix/releases) +carries `macoun-mac-tools-.tar.gz` with universal `nac-relay` and +`extract-key` binaries for macOS 13 and later, so the Mac needs no Go +toolchain. ## Configuration @@ -175,9 +179,10 @@ open code and a Mac you own. Almost all of the bridge is their work; thank you. it in `third_party/patches/rustpush/`. [NOTICE.md](NOTICE.md) has the file-level map. Because a built binary links -AGPL and SSPL code together, this project publishes source only: build the -bridge for your own account, and do not redistribute binaries or run it as a -service for other people. +AGPL and SSPL code together, this project publishes the bridge as source only: +build it for your own account, and do not redistribute bridge binaries or run +it as a service for other people. The Mac tools contain no SSPL code, which is +why their binaries can be published. ## Disclaimer diff --git a/docs/overview.md b/docs/overview.md index 6ecac41..bcf48df 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -28,8 +28,10 @@ AGPL-3.0 or SSPL v1 is included, linked, loaded at run time or required. Because AGPL code is linked into the binary, treat a built binary as AGPL-3.0. SSPL rustpush makes it unsuitable for distribution or for offering to other people as a service: build it for your own account and do not hand out -binaries. The project publishes source only for the same reason. [NOTICE.md](../NOTICE.md) has the file-level map and the source -commits. +binaries. The project publishes the bridge as source only for the same reason. +The two Mac tools contain no rustpush code, so releases do carry macOS +binaries of them. [NOTICE.md](../NOTICE.md) has the file-level map and the +source commits. ## Architecture diff --git a/docs/setup.md b/docs/setup.md index 16a04ca..eca14d0 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -37,6 +37,25 @@ defaults read /Library/Preferences/com.apple.SoftwareUpdate ## 2. Build and run the relay on the Mac +Either download the release build (macOS 13 and later, Intel or Apple +Silicon): + +```bash +mkdir -p /bin /logs /state +cd +T= # for example v0.1.0 +curl -fsSLO "https://github.com/312-dev/macoun-matrix/releases/download/$T/macoun-mac-tools-$T.tar.gz" +curl -fsSL "https://github.com/312-dev/macoun-matrix/releases/download/$T/sha256sums-mac-tools.txt" | shasum -a 256 -c +tar -xzf "macoun-mac-tools-$T.tar.gz" +cp "macoun-mac-tools-$T/nac-relay" bin/ +``` + +Download with `curl` as above rather than a browser: a browser marks the file +as quarantined and Gatekeeper refuses to run an unsigned binary. The archive +also holds `extract-key` (step 3) and the LaunchAgent template. + +Or build it from source: + ```bash git clone https://github.com/312-dev/macoun-matrix.git mkdir -p /bin /logs /state @@ -49,8 +68,10 @@ Install it as a LaunchAgent from the template. **Never run `nac-relay all interfaces. ```bash +# The template is in the release archive, or at +# tools/macoun-relay/launchd/ in a source checkout. sed -e 's#@RELAY_DIR@##g' -e 's#@LISTEN_IP@##g' \ - tools/macoun-relay/launchd/dev.macoun.relay.plist.template \ + /dev.macoun.relay.plist.template \ > ~/Library/LaunchAgents/dev.macoun.relay.plist launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/dev.macoun.relay.plist launchctl print gui/$(id -u)/dev.macoun.relay | grep -E 'state|pid' @@ -95,6 +116,9 @@ Only needed for a new login. The key must come from the same Mac that runs the relay, so the identity matches the NAC data and anisette. ```bash +# From the release archive of step 2: +HOME=/state /macoun-mac-tools-/extract-key +# Or from source: cd macoun-matrix/tools/extract-key ./build.sh # or: go build -o extract-key . HOME=/state ./extract-key