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
48 changes: 46 additions & 2 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ name: Desktop
#
# 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.
#
# Updates itself when the repository has an update key: the secret TAURI_SIGNING_PRIVATE_KEY (and
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD if it has one) and the variable LENS_UPDATER_PUBKEY, its public half, which is
# built into the app. Each release then also carries Lens-macOS-arm64.app.tar.gz, its signature, and latest.json, which
# the app checks (desktop/README.md#updates). Without them the app is built without updates.
on:
release:
types: [published]
Expand Down Expand Up @@ -81,6 +86,9 @@ jobs:
cargo clippy --locked -- -D warnings
- name: Signing, when the secrets are there
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
LENS_UPDATER_PUBKEY: ${{ vars.LENS_UPDATER_PUBKEY }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
Expand All @@ -89,7 +97,8 @@ jobs:
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
for k in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_SIGNING_IDENTITY APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID \
TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PASSWORD LENS_UPDATER_PUBKEY; do
eval "v=\${$k:-}"
if [ -n "$v" ]; then
{
Expand All @@ -99,7 +108,13 @@ jobs:
} >>"$GITHUB_ENV"
fi
done
[ -n "$APPLE_SIGNING_IDENTITY" ] && echo "Signed as the repository's identity" || echo "Unsigned: no signing secrets"
if [ -n "$APPLE_SIGNING_IDENTITY" ]; then echo "Signed as the repository's identity"; else echo "Unsigned: no signing secrets"; fi
if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ] && [ -n "$LENS_UPDATER_PUBKEY" ]; then
echo "LENS_UPDATES=1" >>"$GITHUB_ENV"
echo "Updates itself: the update key is there"
else
echo "Doesn't update itself: no TAURI_SIGNING_PRIVATE_KEY secret and LENS_UPDATER_PUBKEY variable"
fi
- name: Build
working-directory: desktop
env:
Expand All @@ -111,9 +126,38 @@ jobs:
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
if [ "${LENS_UPDATES:-0}" = 1 ]; then # the signed .app.tar.gz the updater downloads
config="$(echo "$config" | python3 -c 'import json,sys; c=json.load(sys.stdin); c["bundle"]["createUpdaterArtifacts"]=True; print(json.dumps(c))')"
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
if [ "${LENS_UPDATES:-0}" = 1 ]; then
cp src-tauri/target/release/bundle/macos/Lens.app.tar.gz ../dist/desktop/Lens-macOS-arm64.app.tar.gz
cp src-tauri/target/release/bundle/macos/Lens.app.tar.gz.sig ../dist/desktop/Lens-macOS-arm64.app.tar.gz.sig
# what the app checks: releases/latest/download/latest.json
python3 - "${TAG:-}" "${{ github.repository }}" <<'PY'
import datetime, json, sys
tag, repo = sys.argv[1], sys.argv[2]
conf = json.load(open("src-tauri/tauri.conf.json"))
version = tag.lstrip("v") if tag else conf["version"]
ref = tag or "unreleased"
sig = open("../dist/desktop/Lens-macOS-arm64.app.tar.gz.sig").read().strip()
manifest = {
"version": version,
"notes": f"https://github.com/{repo}/releases/tag/{ref}",
"pub_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"platforms": {
"darwin-aarch64": {
"signature": sig,
"url": f"https://github.com/{repo}/releases/download/{ref}/Lens-macOS-arm64.app.tar.gz",
}
},
}
json.dump(manifest, open("../dist/desktop/latest.json", "w"), indent=2)
PY
cat ../dist/desktop/latest.json
fi
ls -l ../dist/desktop
- name: The app carries its helper and microsandbox
run: |
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version
- **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)).
([Get started](docs/get-started.md#the-mac-app)). It updates itself from each release, checking the update's
signature, once the repository has an update key ([desktop/README.md](desktop/README.md#updates)).

- **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
Expand Down
20 changes: 20 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ Application `.p12`), `APPLE_CERTIFICATE_PASSWORD`, `APPLE_SIGNING_IDENTITY`, and
`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.

## Updates

The app updates itself with [Tauri's updater](https://v2.tauri.app/plugin/updater/): a minute after it starts and
every six hours, it reads `latest.json` from the latest release, and when that names a newer version it downloads
`Lens-macOS-arm64.app.tar.gz`, checks its signature against the public key built into the app, replaces itself and
restarts quietly in the menu bar (Lens keeps running meanwhile). **Check for App Updates** in the menu does the same
now. It doesn't update while the web installer is open. Lens itself is updated separately, with **Update Lens**.

The Desktop workflow signs the update and writes `latest.json` on each release when the repository has an update key.
Make one once, on any computer with Node and the GitHub CLI:

```bash
npx @tauri-apps/cli signer generate --ci -p "" -w lens-updater.key &&
gh secret set TAURI_SIGNING_PRIVATE_KEY -R adeelahmad/lense < lens-updater.key &&
gh variable set LENS_UPDATER_PUBKEY -R adeelahmad/lense < lens-updater.key.pub
```

Keep `lens-updater.key` somewhere safe: an app built with its public key accepts only updates signed with it. Without
the key, the app is built without updates and its menu says so.

## Not yet

- Starting with the Mac (install.sh's LaunchAgent already starts the sandbox at sign-in).
Expand Down
Loading
Loading