Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Desktop

# Lens.app for macOS (desktop/README.md): a Tauri menu-bar app that carries microsandbox, built as a .dmg on a Mac
# runner and attached to each release, through the release event or, for a release the Release workflow publishes
# with GITHUB_TOKEN (which fires no release event), through workflow_dispatch with `tag`. On a pull request that
# changes it, it's built and kept with the run.
#
# Signed and notarized when the repository has the secrets for it (APPLE_CERTIFICATE, APPLE_CERTIFICATE_PASSWORD,
# APPLE_SIGNING_IDENTITY, and APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID to notarize); else unsigned.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag to attach Lens.app to (the Release workflow passes it); blank: build this ref"
default: ""
pull_request:
paths:
- desktop/**
- installer/**
- .github/workflows/desktop.yml

permissions:
contents: read

jobs:
check:
name: Check the desktop app's helper
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check lens-app.sh
run: |
sh -n desktop/resources/lens-app.sh
test -x desktop/resources/lens-app.sh
shellcheck -s sh desktop/resources/lens-app.sh desktop/resources/check-lens-app.sh
- name: Run its checks (as `nx test desktop` does)
run: sh desktop/resources/check-lens-app.sh

macos:
name: Build Lens.app
runs-on: macos-latest # Apple silicon
permissions:
contents: write # to attach it to the release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: desktop/package-lock.json
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: desktop/src-tauri
- name: Get microsandbox (the latest release, checked against its checksums)
env:
GH_TOKEN: ${{ github.token }}
working-directory: desktop/resources
run: |
gh release download --repo superradcompany/microsandbox \
--pattern microsandbox-darwin-aarch64.tar.gz --pattern checksums.sha256 --clobber
grep -F microsandbox-darwin-aarch64.tar.gz checksums.sha256 | shasum -a 256 -c -
rm checksums.sha256
gh release view --repo superradcompany/microsandbox --json tagName -q .tagName
- name: The bundled msb runs
run: |
s="$(mktemp -d)"
HOME="$s" LENS_MSB_BUNDLE="$PWD/desktop/resources/microsandbox-darwin-aarch64.tar.gz" \
sh desktop/resources/lens-app.sh setup-msb
"$s/.microsandbox/bin/msb" --version
- name: Lint
working-directory: desktop/src-tauri
run: |
cargo fmt --check
cargo clippy --locked -- -D warnings
- name: Signing, when the secrets are there
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
# Tauri signs when these are set, so only the ones that have a value are passed on
for k in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_SIGNING_IDENTITY APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID; do
eval "v=\${$k:-}"
if [ -n "$v" ]; then
{
echo "$k<<LENS_EOF"
echo "$v"
echo "LENS_EOF"
} >>"$GITHUB_ENV"
fi
done
[ -n "$APPLE_SIGNING_IDENTITY" ] && echo "Signed as the repository's identity" || echo "Unsigned: no signing secrets"
- name: Build
working-directory: desktop
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: |
npm ci --include=dev
# a release build takes the release's version
config='{"bundle":{"resources":{"../resources/microsandbox-darwin-aarch64.tar.gz":"microsandbox-darwin-aarch64.tar.gz"}}}'
if [ -n "$TAG" ]; then
config="$(echo "$config" | python3 -c 'import json,sys; c=json.load(sys.stdin); c["version"]=sys.argv[1].lstrip("v"); print(json.dumps(c))' "$TAG")"
fi
npx tauri build --config "$config" --bundles app,dmg
mkdir -p ../dist/desktop
cp src-tauri/target/release/bundle/dmg/*.dmg ../dist/desktop/Lens-macOS-arm64.dmg
ls -l ../dist/desktop
- name: The app carries its helper and microsandbox
run: |
r="desktop/src-tauri/target/release/bundle/macos/Lens.app/Contents/Resources"
test -f "$r/lens-app.sh"
test -f "$r/microsandbox-darwin-aarch64.tar.gz"
codesign -dv "desktop/src-tauri/target/release/bundle/macos/Lens.app" 2>&1 | head -5 || true
- uses: actions/upload-artifact@v7
with:
name: lens-macos
path: dist/desktop/*
- name: Attach to the release
if: github.event_name == 'release' || inputs.tag != ''
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: gh release upload "$TAG" dist/desktop/* --clobber --repo "${{ github.repository }}"
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ name: Release
# section as its notes (.github/scripts/release.py). Pushing a vX.Y.Z tag yourself publishes that tag the same way,
# without the commit.
#
# Publishing starts the package workflows (cloudron.yml, qnap.yml, synology.yml). A release published with the
# workflow's own token doesn't trigger `release: published` in other workflows, so this one starts them itself,
# for the tag (`gh workflow run <file> --ref vX.Y.Z -f tag=vX.Y.Z`). With a RELEASE_TOKEN secret (a fine-grained
# token with Contents: write on this repository) the release is published with it instead, `release: published`
# fires as usual, and nothing is started here. RELEASE_TOKEN is also what pushes past branch protection on main.
# Publishing starts the package workflows (cloudron.yml, qnap.yml, synology.yml, launchers.yml, browser-extension.yml,
# safari-clipper.yml, browser-extension-firefox.yml, desktop.yml). A release published with the workflow's own token
# doesn't trigger `release: published` in other workflows, so this one starts them itself, for the tag (`gh workflow run
# <file> --ref vX.Y.Z -f tag=vX.Y.Z`). With a RELEASE_TOKEN secret (a fine-grained token with Contents: write on this
# repository) the release is published with it instead, `release: published` fires as usual, and nothing is started
# here. RELEASE_TOKEN is also what pushes past branch protection on main.
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -152,7 +153,7 @@ jobs:
# RELEASE_TOKEN's release fires `release: published` in them already
if: env.EXISTING != 'true' && env.HAS_RELEASE_TOKEN != 'true'
run: |
for workflow in cloudron.yml qnap.yml synology.yml launchers.yml browser-extension.yml safari-clipper.yml browser-extension-firefox.yml; do
for workflow in cloudron.yml qnap.yml synology.yml launchers.yml browser-extension.yml safari-clipper.yml browser-extension-firefox.yml desktop.yml; do
if [ ! -f ".github/workflows/$workflow" ]; then
echo "$workflow isn't in $TAG; skipped"
elif gh workflow run "$workflow" --ref "$TAG" -f tag="$TAG"; then
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version

## Unreleased

- **A Mac app.** Lens.app (`Lens-macOS-arm64.dmg`, Apple silicon) installs Lens in the web installer shown in its
window, with microsandbox inside it so no Docker is needed, then lives in the menu bar: open, start, stop and update
Lens, and show its logs. Lens itself opens in the browser, where passkeys work
([Get started](docs/get-started.md#the-mac-app)).

- **Slack, built in.** Settings › Slack creates a Slack app from Lens's manifest in one click; paste its two tokens
and the assistant answers direct messages, what's said to it in channels and `/lens …`, over Socket Mode: no
Matterbridge, no public address. Voice clips are heard, files are held for the assistant to import, and everything
Expand Down
4 changes: 4 additions & 0 deletions desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
src-tauri/target/
src-tauri/gen/
resources/microsandbox-*.tar.gz
54 changes: 54 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Lens for macOS

A menu-bar app around Lens, built with [Tauri](https://tauri.app): `Lens-macOS-arm64.dmg` in each release, for Macs
with Apple silicon. It carries [microsandbox](../docs/microsandbox.md), so Lens runs without Docker.

**Status: built, early.** Unsigned unless the repository has signing secrets (see below).

## What it does

- **First launch:** puts the microsandbox it carries in `~/.microsandbox` (where `install.microsandbox.dev` would),
then runs `install.sh` with the web installer, shown in the app's window with microsandbox chosen. When the install
is done, Lens opens in the browser.
- **After that:** starts Lens if it isn't running (`~/lens/.lens-sandbox`, or Docker Compose for a Docker install)
and opens it in the browser.
- **Menu bar:** Open Lens, Start Lens, Stop Lens, Update Lens (runs the install line again: the secrets, the database
and the archive are kept), Show Window, Show Logs, Quit. Closing the window leaves it in the menu bar.

Lens opens in the browser, not in the app's window, because Lens signs in with passkeys and macOS lets an app's web
view use them only for its own associated web domains.

## How it's built

- `src-tauri/src/main.rs`: the window, the menu-bar item, and what the helper's output asks for.
- `resources/lens-app.sh`: the helper that does the work (`launch`, `start`, `stop`, `update`, `url`, `setup-msb`). It
talks to the app on its output (`@status`, `@show`, `@open`, `@error`) and logs to `~/Library/Logs/Lens/app.log`.
- `ui/index.html`: the status page the window shows while Lens starts.

The [Desktop workflow](../.github/workflows/desktop.yml) builds it on a Mac runner: it downloads the latest
microsandbox release for `darwin-aarch64`, checks it against the release's checksums, puts it in the app's resources,
and builds the `.app` and the `.dmg`. Each release gets the `.dmg` attached.

Build it yourself on a Mac (Rust, Node 22):

```bash
cd desktop
npm ci
gh release download --repo superradcompany/microsandbox --pattern microsandbox-darwin-aarch64.tar.gz -D resources
npx tauri build --config '{"bundle":{"resources":{"../resources/microsandbox-darwin-aarch64.tar.gz":"microsandbox-darwin-aarch64.tar.gz"}}}'
```

Without the microsandbox bundle it still builds (`npx tauri build`); `install.sh` then downloads microsandbox itself.

## Signing

With these repository secrets the workflow signs and notarizes the app: `APPLE_CERTIFICATE` (a base64 Developer ID
Application `.p12`), `APPLE_CERTIFICATE_PASSWORD`, `APPLE_SIGNING_IDENTITY`, and for notarizing `APPLE_ID`,
`APPLE_PASSWORD` (an app-specific password) and `APPLE_TEAM_ID`. Without them the app is unsigned: right-click it and
choose **Open** the first time.

## Not yet

- Starting with the Mac (install.sh's LaunchAgent already starts the sandbox at sign-in).
- Intel Macs (microsandbox needs Apple silicon; a Docker-only build could follow).
- Windows and Linux builds of the same app.
Loading
Loading