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
86 changes: 72 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,55 @@
name: Release

# Two ways in:
# - Pushing a tag vX.Y.Z builds the release and creates a *draft* GitHub Release.
# - Running it by hand (workflow_dispatch) builds the same release and only uploads dist/
# as an Actions artifact, for review: no tag, no release, no change to the update feed.
# Both run the same `build` job (scripts/release.sh). See docs/releasing.md.
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
workflow_dispatch:

permissions:
contents: write
contents: read

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
name: Release
build:
name: Build
runs-on: macos-26
timeout-minutes: 60
# Read-only token: this job holds the signing secrets, so it gets no write access.
permissions:
contents: read
env:
HAS_SIGNING: ${{ secrets.DEVELOPER_ID_CERT_P12_BASE64 != '' }}
HAS_NOTARY: ${{ secrets.NOTARY_KEY_P8_BASE64 != '' }}
outputs:
artifact: ${{ steps.version.outputs.artifact }}
signed: ${{ steps.version.outputs.signed }}
steps:
- uses: actions/checkout@v7

- name: Check tag matches app version
- name: Read app version
id: version
run: |
version=$(sed -n 's/^MARKETING_VERSION = //p' apps/macos/Config/Version.xcconfig)
if [[ "v$version" != "$GITHUB_REF_NAME" ]]; then
echo "::error::Tag $GITHUB_REF_NAME does not match MARKETING_VERSION $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "artifact=TokenBar-$version-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
echo "signed=$HAS_SIGNING" >> "$GITHUB_OUTPUT"
echo "::notice::Building TokenBar $version from $GITHUB_REF_NAME (${GITHUB_SHA::7}), triggered by $GITHUB_EVENT_NAME"

- name: Check tag matches app version
if: github.event_name == 'push'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
if [[ "v$VERSION" != "$GITHUB_REF_NAME" ]]; then
echo "::error::Tag $GITHUB_REF_NAME does not match MARKETING_VERSION $VERSION"
exit 1
fi

Expand Down Expand Up @@ -63,20 +86,55 @@ jobs:
NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
NOTARY_ISSUER_ID: ${{ secrets.NOTARY_ISSUER_ID }}
NOTARY_KEY_PATH: ${{ runner.temp }}/notary.p8
run: scripts/release.sh
# EdDSA private key that signs the update archive for Sparkle. Required.
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: |
if [[ -z "$SPARKLE_PRIVATE_KEY" ]]; then
echo "::error::The SPARKLE_PRIVATE_KEY secret is missing (docs/releasing.md › Sparkle)"
exit 1
fi
scripts/release.sh

# dist/: TokenBar-<version>[-unsigned].zip (the signed update archive), .dmg,
# appcast.xml and SHA256SUMS.txt. The draft release below is made from this same artifact.
- name: Upload dist/ as an artifact
uses: actions/upload-artifact@v7
with:
name: ${{ steps.version.outputs.artifact }}
path: dist/
if-no-files-found: error
retention-days: 14

- name: Clean up signing material
if: always()
run: |
security delete-keychain "$RUNNER_TEMP/signing.keychain-db" 2>/dev/null || true
rm -f "$RUNNER_TEMP/notary.p8"

draft-release:
name: Draft GitHub Release
# Tag pushes only. A manual run ends after the build job uploads its artifact.
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v7

- uses: actions/download-artifact@v8
with:
name: ${{ needs.build.outputs.artifact }}
path: dist

- name: Create draft GitHub Release
env:
GH_TOKEN: ${{ github.token }}
SIGNED: ${{ needs.build.outputs.signed }}
run: |
flags=(--draft --title "TokenBar ${GITHUB_REF_NAME#v}")
notes="docs/release-notes/$GITHUB_REF_NAME.md"
if [[ -f "$notes" ]]; then flags+=(--notes-file "$notes"); else flags+=(--generate-notes); fi
if [[ "$HAS_SIGNING" != "true" ]]; then flags+=(--prerelease); fi
if [[ "$SIGNED" != "true" ]]; then flags+=(--prerelease); fi
gh release create "$GITHUB_REF_NAME" dist/* "${flags[@]}"

- name: Clean up signing material
if: always()
run: |
security delete-keychain "$RUNNER_TEMP/signing.keychain-db" 2>/dev/null || true
rm -f "$RUNNER_TEMP/notary.p8"
47 changes: 43 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ directly to the providers. There is no TokenBar server and no account.
- **Honest when data is old.** If a refresh fails, you keep the last values with an
"outdated" mark instead of an error screen.
- **Opens at login**, if you want it to.
- **Updates itself when you ask** (from the first release after 0.1.0). Gear menu ›
**Check for Updates…** installs a new version and relaunches TokenBar. It never checks
on its own.
- **English and Portuguese (Brazil).**
- **Native and light.** SwiftUI and AppKit, no Electron, no web views, no third-party code.
- **Native and light.** SwiftUI and AppKit, no Electron. The only third-party code is
[Sparkle](https://sparkle-project.org), the standard Mac framework for in-app updates.

## Supported providers

Expand Down Expand Up @@ -95,6 +99,37 @@ Because the build is unsigned, macOS may ask again for access to Claude Code's K
item after you install an update. Signing and notarization are planned after 0.1.0
([roadmap](docs/roadmap.md)).

### Updating

> [!NOTE]
> In-app updates are not in a release yet. TokenBar 0.1.0 has no updater; the first
> release after 0.1.0 will be the first one that has it.

**Where it is:** click the TokenBar icon in the menu bar, then the **gear** button at the
bottom right of the popover, and choose **Check for Updates…** (**Buscar atualizações…**
in Portuguese), just above **Quit TokenBar**.

If a new version exists, TokenBar shows what changed. Click **Install Update** (**Instalar
Atualização**), then **Install and Relaunch** (**Instalar e Reabrir**). TokenBar quits,
installs the new version and opens again, with your preferences and enabled providers
kept. If you already have the latest version, it says so. TokenBar never checks on its
own; it only looks for updates when you choose this item.

**Coming from TokenBar 0.1.0?** 0.1.0 has no **Check for Updates…** and cannot update
itself. Install the first version with the updater by hand, once:

1. Quit TokenBar (gear menu › **Quit TokenBar**).
2. Download the new DMG from the [latest release](https://github.com/DerRafDev/tokenbar/releases/latest).
3. Open it and drag **TokenBar** to **Applications**, choosing **Replace**.
4. Open TokenBar. If that release is unsigned, approve it again with **Open Anyway** as in
the installation steps above.

Your preferences and enabled providers are kept. From then on, every new version installs
from the gear menu.

Updates are verified before they are installed: each one is signed with the project's
EdDSA key, and TokenBar refuses an update whose signature does not match.

### Enabling a provider

Every provider starts **disabled**. TokenBar reads nothing until you enable one, and it
Expand All @@ -116,8 +151,11 @@ sign-in on its next refresh. TokenBar never renews tokens or writes them to disk
**Your usage data stays on your Mac.**

- TokenBar sends requests only to `api.anthropic.com` (Claude) and `chatgpt.com` (Codex),
and only for the providers you enabled.
- No analytics, telemetry, crash reporting, tracking, or update checks.
and only for the providers you enabled, plus GitHub when you check for updates.
- No analytics, telemetry, crash reporting, or tracking.
- Update checks happen only when you choose **Check for Updates…**. TokenBar then
downloads the release feed from GitHub (`github.com` and its download servers), and
the update itself if you install it. No information about you or your Mac is sent.
- No database or history: usage is kept in memory and never written to disk. Network
responses are not cached and cookies are not stored.
- Sign-ins are read when a refresh needs them. TokenBar keeps the Claude Code token in
Expand All @@ -142,7 +180,8 @@ From the repository root:
scripts/test.sh # build and test TokenBarKit
scripts/format.sh # format all Swift sources in place
scripts/lint.sh # check formatting and lint rules (what CI runs)
scripts/release.sh # build the DMG and ZIP into dist/ (see docs/releasing.md)
scripts/release.sh # build the DMG, ZIP and appcast into dist/ (see docs/releasing.md)
scripts/test-update.sh build # local in-app update test (see docs/releasing.md)
```

Every build runs the real providers. To work on the UI without accounts, launch a Debug
Expand Down
19 changes: 19 additions & 0 deletions apps/macos/Config/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- Keys Xcode cannot generate from INFOPLIST_KEY_* settings. Xcode merges this file with the
generated Info.plist. Values come from build settings in TokenBar.xcconfig. -->
<dict>
<!-- Sparkle (in-app updates). See docs/releasing.md. -->
<key>SUFeedURL</key>
<string>$(SPARKLE_FEED_URL)</string>
<key>SUPublicEDKey</key>
<string>$(SPARKLE_PUBLIC_ED_KEY)</string>
<!-- Updates are checked only from the gear menu, never in the background. -->
<key>SUEnableAutomaticChecks</key>
<false/>
<!-- Check the EdDSA signature of the download before unpacking it. -->
<key>SUVerifyUpdateBeforeExtraction</key>
<true/>
</dict>
</plist>
12 changes: 12 additions & 0 deletions apps/macos/Config/TokenBar-AdHoc.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Ad-hoc signed release builds only (scripts/release.sh without DEVELOPER_ID_IDENTITY).
The hardened runtime loads only libraries signed by the app's own Team ID, and an ad-hoc
signature has none, so embedded Sparkle.framework would be refused at launch.
Developer ID builds sign Sparkle with their own Team ID and do not use this file. -->
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions apps/macos/Config/TokenBar-Debug.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
The hardened runtime blocks Apple Events without this entitlement. -->
<key>com.apple.security.automation.apple-events</key>
<true/>
<!-- Debug builds are ad-hoc signed: without this the hardened runtime refuses to load the
embedded Sparkle.framework (no Team ID to match). See TokenBar-AdHoc.entitlements. -->
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
16 changes: 16 additions & 0 deletions apps/macos/Config/TokenBar.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ INFOPLIST_KEY_LSUIElement = YES
INFOPLIST_KEY_CFBundleDisplayName = TokenBar
INFOPLIST_KEY_LSApplicationCategoryType = public.app-category.utilities
INFOPLIST_KEY_NSHumanReadableCopyright = © 2026 TokenBar contributors. MIT License.
// Extra keys (Sparkle) that have no INFOPLIST_KEY_ setting. Merged into the generated plist.
INFOPLIST_FILE = Config/Info.plist

// Sparkle in-app updates (docs/releasing.md). The feed is the appcast.xml attached to the
// latest published GitHub Release, so drafts and pre-releases are never offered.
// `/$()/` keeps `//` from starting an xcconfig comment.
SPARKLE_FEED_URL = https:/$()/github.com/DerRafDev/tokenbar/releases/latest/download/appcast.xml
// Public half of the EdDSA key that signs update archives. Not a secret. The private key is
// never in the repository: it lives in the release maintainer's Keychain and in the
// SPARKLE_PRIVATE_KEY Actions secret. scripts/release.sh refuses to run while this is empty.
SPARKLE_PUBLIC_ED_KEY =
// Sparkle.framework is embedded in Contents/Frameworks.
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks
// The only binary copied in a copy phase is Sparkle, which ships signed and cannot be
// stripped; leaving this on only produced a "not stripping binary" warning.
COPY_PHASE_STRIP = NO

// App icon: TokenBar/AppIcon.icon (Icon Composer). Xcode also derives the .icns used before
// macOS 26 from it. The original artwork is docs/assets/app-icon.png.
Expand Down
20 changes: 20 additions & 0 deletions apps/macos/TokenBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
7B0000000000000000000013 /* TokenBarCore in Frameworks */ = {isa = PBXBuildFile; productRef = 7B0000000000000000000011 /* TokenBarCore */; };
7B0000000000000000000014 /* TokenBarUI in Frameworks */ = {isa = PBXBuildFile; productRef = 7B0000000000000000000012 /* TokenBarUI */; };
7B0000000000000000000019 /* TokenBarProviders in Frameworks */ = {isa = PBXBuildFile; productRef = 7B0000000000000000000018 /* TokenBarProviders */; };
7B000000000000000000001C /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 7B000000000000000000001B /* Sparkle */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -34,6 +35,7 @@
7B0000000000000000000013 /* TokenBarCore in Frameworks */,
7B0000000000000000000014 /* TokenBarUI in Frameworks */,
7B0000000000000000000019 /* TokenBarProviders in Frameworks */,
7B000000000000000000001C /* Sparkle in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -89,6 +91,7 @@
7B0000000000000000000011 /* TokenBarCore */,
7B0000000000000000000012 /* TokenBarUI */,
7B0000000000000000000018 /* TokenBarProviders */,
7B000000000000000000001B /* Sparkle */,
);
productName = TokenBar;
productReference = 7B0000000000000000000004 /* TokenBar.app */;
Expand Down Expand Up @@ -116,6 +119,7 @@
minimizedProjectReferenceProxies = 1;
packageReferences = (
7B0000000000000000000010 /* XCLocalSwiftPackageReference "TokenBarKit" */,
7B000000000000000000001A /* XCRemoteSwiftPackageReference "Sparkle" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 7B0000000000000000000003 /* Products */;
Expand Down Expand Up @@ -233,6 +237,17 @@
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
7B000000000000000000001A /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.10.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
7B0000000000000000000011 /* TokenBarCore */ = {
isa = XCSwiftPackageProductDependency;
Expand All @@ -246,6 +261,11 @@
isa = XCSwiftPackageProductDependency;
productName = TokenBarProviders;
};
7B000000000000000000001B /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 7B000000000000000000001A /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 7B0000000000000000000001 /* Project object */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/macos/TokenBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let settings: AppSettings
let store: UsageStore
let launchAtLogin = LaunchAtLogin()
let updater = SoftwareUpdater()
/// Sessions waiting for the user. `nil` unless agent monitoring runs (Debug prototype).
let agents: AgentActivityStore?
/// Brings a waiting session's window to the front. `nil` with ``agents``.
Expand Down
33 changes: 33 additions & 0 deletions apps/macos/TokenBar/SoftwareUpdater.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import AppKit
import Observation
import Sparkle
import TokenBarUI

/// In-app updates with Sparkle's standard dialogs. Checks only when the user asks
/// (`SUEnableAutomaticChecks` is off in Config/Info.plist). The feed and the public EdDSA key
/// come from build settings; see docs/releasing.md.
@MainActor
@Observable
final class SoftwareUpdater: UpdateChecking {
private(set) var canCheckForUpdates = false

@ObservationIgnored private let controller: SPUStandardUpdaterController
@ObservationIgnored private var observation: NSKeyValueObservation?

init() {
controller = SPUStandardUpdaterController(
startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
canCheckForUpdates = controller.updater.canCheckForUpdates
// Sparkle changes this on the main thread.
observation = controller.updater.observe(\.canCheckForUpdates, options: [.new]) { [weak self] _, change in
guard let canCheck = change.newValue else { return }
MainActor.assumeIsolated { self?.canCheckForUpdates = canCheck }
}
}

func checkForUpdates() {
// TokenBar has no Dock icon, so bring it forward or Sparkle's window opens behind others.
NSApp.activate()
controller.checkForUpdates(nil)
}
}
Loading
Loading