feat(updater): add hourly dev channel and build switching (#11250)

* feat(updater): add hourly dev channel and build switching

Adds an hourly macOS build channel plus a dev-only surface for switching
update channels and jumping to any published build, including older ones.

Hourly builds publish to a separate stablyai/orca-hourly repo. The routine
update path resolves tags from the main repo's releases atom feed, which
exposes only its 10 newest entries — 24 hourly tags a day would evict every
stable/RC entry there and leave real users with nothing to update to.

Hourly artifacts carry the release bundle id and Developer ID signature so
Squirrel.Mac can swap them in place; only notarization is skipped, which
in-place updates never check.

Version tails are stripped to the base (1.4.160-hourly.<stamp>, not
1.4.160-rc.3-hourly.<stamp>) so hourlies sort below both rc.N and stable and
are reachable only by an explicit pinned jump, never by an ordinary check.

The picker is revealed by Option-clicking the Updates header, matching the
Help menu's existing hidden admin affordance. Pinned jumps set allowDowngrade
and release the feed on every settle path so a jump can never leave background
checks permanently deferred.

* chore(hourly): create orca-hourly and add token provisioning script

Adds setup-hourly-release-token.sh, which provisions HOURLY_RELEASE_TOKEN
without the value ever reaching stdout, argv, or shell history: it is read
with `read -rs`, passed to gh through GH_TOKEN in the environment rather than
as an argument (argv is world-readable via ps), piped into `gh secret set` on
stdin, and scrubbed by an EXIT trap.

Verification creates and deletes a draft release in orca-hourly to prove
Contents:write for real rather than trusting the permission checkbox. Drafts
are absent from the releases atom feed, so the probe cannot disturb users.

Refuses to run without a controlling terminal instead of falling through
having set nothing, and refuses to run under xtrace, which would echo the
token on every expansion.

* fix(updater): address review feedback on the hourly channel

Renderer:
- Guard listBuilds against out-of-order responses. activeChannel flips once
  getVersion resolves, and rapid channel clicks stack requests, so a slower
  earlier load could land last and fill the list with builds from a channel
  the picker was no longer showing.
- Selecting the running build's own channel now clears the override instead
  of pinning it. There was previously no way back to "follow this build's
  channel", so merely opening the panel left background checks pinned.
- Validate releaseChannelOverride on hydration, matching every other
  enum-like field in that function.

Main:
- Exclude pinned jumps from recordCompletedUpdateCheck() in update-available.
  A dev browsing the picker was persisting lastUpdateCheckAt and suppressing
  the next real background check for a full day.
- parseHourlyVersionStamp now anchors on the whole version and round-trips
  the parsed fields. It accepted garbage prefixes, and Date.UTC rolled
  impossible dates forward, so ...hourly.202602300000 rendered as March 2.

Workflow:
- Publish into a draft and flip it live only after the manifest check. The
  window between creating the release and verifying its assets previously
  exposed a tag the picker would offer and the download would 404 on; a
  draft is invisible to listReleaseBuilds, so a job that dies in that
  window — including a hard kill by the job timeout, which runs no cleanup
  step — leaves nothing user-visible behind.
- Add a failure handler that discards the draft, gated on the publish step
  not having succeeded so a later prune failure cannot delete a live release.
- Align retry budgets with the job timeout (was 60min against a worst case
  of ~185min, so a mid-retry kill skipped the cleanup that step exists for).
- Exclude drafts from the freshness and retention queries.
- persist-credentials: false; the job only reads this repo and never pushes.

* refactor(hourly): authenticate with a GitHub App instead of a PAT

A fine-grained PAT expires, and the hourly build would then fail silently on
a schedule nobody watches. A GitHub App's private key has no expiry, so this
is set up once. It is also owned by the org rather than by the person who
created it, so the credential survives that person leaving.

The workflow mints a short-lived installation token via
actions/create-github-app-token and passes it as GH_TOKEN. Installation
tokens live one hour, which is ample: this job runs no tests, no
notarization, and no Windows signing, so it is pack + upload. The retry
budgets and job timeout are re-sized to that reality rather than copied from
the release pipeline, whose 3x45 publish budget exists for notarization and
SignPath.

setup-hourly-release-token.sh now provisions HOURLY_RELEASE_APP_ID and
HOURLY_RELEASE_APP_PRIVATE_KEY. The key is redirected from a file straight
into `gh secret set` on stdin, so its contents never enter a shell variable,
argv, or the terminal.

* fix(hourly): make the xtrace guard fire and cover cancelled runs

The xtrace guard disabled tracing before testing for it, so `[[ -o xtrace ]]`
read the state the previous line had just cleared and never fired. `bash -x`
ran straight through, tracing exactly the key handling the guard exists to
prevent. Test first, then disable.

The draft cleanup only ran on failure(), but a run stopped from the Actions
UI is cancelled(), not failed — a manual cancel mid-publish stranded the
draft. Cover both.
This commit is contained in:
Neil
2026-07-30 22:53:02 -07:00
committed by GitHub
parent 0ffdb79d34
commit f998f7ec62
22 changed files with 1536 additions and 40 deletions
+95
View File
@@ -0,0 +1,95 @@
import { describe, expect, it } from 'vitest'
import {
formatHourlyVersion,
getReleaseRepoForChannel,
getVersionChannel,
isHourlyVersion,
isReleaseChannel,
parseHourlyVersionStamp,
sortReleaseBuildsNewestFirst,
type ReleaseBuild
} from './release-channel'
import { compareAppVersions } from './app-version'
describe('release channel', () => {
it('classifies versions by channel', () => {
expect(getVersionChannel('1.4.160')).toBe('stable')
expect(getVersionChannel('v1.4.160')).toBe('stable')
expect(getVersionChannel('1.4.160-rc.3')).toBe('rc')
expect(getVersionChannel('1.4.160-hourly.202607281400')).toBe('hourly')
expect(getVersionChannel('not-a-version')).toBeNull()
})
// Why: hourly tags must never resolve to the main repo — the releases atom feed
// exposes only 10 entries, so 24 hourly tags a day would evict every stable/RC
// entry and leave real users with nothing to update to.
it('keeps hourly builds out of the main release repo', () => {
expect(getReleaseRepoForChannel('hourly')).toBe('stablyai/orca-hourly')
expect(getReleaseRepoForChannel('stable')).toBe('stablyai/orca')
expect(getReleaseRepoForChannel('rc')).toBe('stablyai/orca')
})
it('round-trips an hourly version stamp as UTC', () => {
const version = formatHourlyVersion('1.4.160', '202607281405')
expect(isHourlyVersion(version)).toBe(true)
expect(parseHourlyVersionStamp(version)?.toISOString()).toBe('2026-07-28T14:05:00.000Z')
})
it('rejects malformed hourly identifiers', () => {
expect(isHourlyVersion('1.4.160-hourly')).toBe(false)
expect(isHourlyVersion('1.4.160-hourly.2026')).toBe(false)
expect(isHourlyVersion('1.4.160-rc.3')).toBe(false)
expect(parseHourlyVersionStamp('1.4.160-rc.3')).toBeNull()
})
// Why: an unanchored tail match also accepted garbage prefixes, and Date.UTC
// rolls impossible dates forward, so `...hourly.202602300000` rendered as
// March 2 rather than being rejected.
it('rejects a bad base version and impossible calendar stamps', () => {
expect(parseHourlyVersionStamp('not-a-version-hourly.202601010000')).toBeNull()
expect(parseHourlyVersionStamp('1.4-hourly.202601010000')).toBeNull()
expect(parseHourlyVersionStamp('1.4.160-hourly.202602300000')).toBeNull()
expect(parseHourlyVersionStamp('1.4.160-hourly.202613010000')).toBeNull()
expect(parseHourlyVersionStamp('1.4.160-hourly.202601012500')).toBeNull()
// Leap day 2028 is real and must still parse.
expect(parseHourlyVersionStamp('1.4.160-hourly.202802290000')?.toISOString()).toBe(
'2028-02-29T00:00:00.000Z'
)
})
it('accepts only known channels', () => {
expect(isReleaseChannel('hourly')).toBe(true)
expect(isReleaseChannel('stable')).toBe(true)
expect(isReleaseChannel('nightly')).toBe(false)
expect(isReleaseChannel(null)).toBe(false)
expect(isReleaseChannel(undefined)).toBe(false)
})
// Why: consecutive hourlies differ only in the timestamp tail, so semver
// ordering must follow the clock or the picker offers them out of order.
it('sorts consecutive hourly builds newest first', () => {
const build = (version: string): ReleaseBuild => ({
tag: `v${version}`,
version,
channel: 'hourly',
publishedAt: null,
releaseUrl: `https://github.com/stablyai/orca-hourly/releases/tag/v${version}`
})
const sorted = sortReleaseBuildsNewestFirst([
build('1.4.160-hourly.202607280900'),
build('1.4.160-hourly.202607281400'),
build('1.4.160-hourly.202607281000')
])
expect(sorted.map((entry) => entry.version)).toEqual([
'1.4.160-hourly.202607281400',
'1.4.160-hourly.202607281000',
'1.4.160-hourly.202607280900'
])
})
// Why: an hourly is cut from main and must not read as newer than the stable it
// is based on, or stable users would be offered it by an ordinary check.
it('orders an hourly below its own stable release', () => {
expect(compareAppVersions('1.4.160-hourly.202607281400', '1.4.160')).toBeLessThan(0)
})
})
+84
View File
@@ -0,0 +1,84 @@
import { compareAppVersions, isValidAppVersion } from './app-version'
export type ReleaseChannel = 'stable' | 'rc' | 'hourly'
export const RELEASE_CHANNELS: readonly ReleaseChannel[] = ['stable', 'rc', 'hourly']
/** Hourly builds live in their own repo so their tags never enter the main
* releases atom feed, which only exposes the 10 newest entries — 24 hourly
* tags a day would evict every stable/RC entry and strand real users. */
export const HOURLY_RELEASE_REPO = 'stablyai/orca-hourly'
export const MAIN_RELEASE_REPO = 'stablyai/orca'
export const HOURLY_PRERELEASE_IDENTIFIER = 'hourly'
export function isReleaseChannel(value: unknown): value is ReleaseChannel {
return typeof value === 'string' && RELEASE_CHANNELS.includes(value as ReleaseChannel)
}
export function getReleaseRepoForChannel(channel: ReleaseChannel): string {
return channel === 'hourly' ? HOURLY_RELEASE_REPO : MAIN_RELEASE_REPO
}
export function normalizeTagToVersion(tag: string): string {
return tag.replace(/^v/i, '')
}
/** `1.4.160-hourly.202607281400` — a timestamp identifier keeps every build
* uniquely versioned so electron-updater never reads one as "same version". */
export function isHourlyVersion(version: string): boolean {
return /^\d+\.\d+\.\d+-hourly\.\d{12}$/.test(normalizeTagToVersion(version))
}
export function formatHourlyVersion(baseVersion: string, stamp: string): string {
return `${baseVersion}-${HOURLY_PRERELEASE_IDENTIFIER}.${stamp}`
}
/** Returns the build's UTC timestamp, or null when the version isn't hourly. */
export function parseHourlyVersionStamp(version: string): Date | null {
const normalized = normalizeTagToVersion(version)
// Why anchored on the whole version: an unanchored tail match also accepts
// garbage prefixes, so `not-a-version-hourly.202601010000` would parse.
const match = normalized.match(/^\d+\.\d+\.\d+-hourly\.(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})$/)
if (!match) {
return null
}
const [year, month, day, hour, minute] = match.slice(1).map(Number)
const parsed = new Date(Date.UTC(year, month - 1, day, hour, minute))
// Why the round-trip: Date.UTC silently rolls impossible dates forward, so a
// corrupt `...hourly.202602300000` would render as March 2 rather than fail.
if (
parsed.getUTCFullYear() !== year ||
parsed.getUTCMonth() !== month - 1 ||
parsed.getUTCDate() !== day ||
parsed.getUTCHours() !== hour ||
parsed.getUTCMinutes() !== minute
) {
return null
}
return parsed
}
export function getVersionChannel(version: string): ReleaseChannel | null {
const normalized = normalizeTagToVersion(version)
if (!isValidAppVersion(normalized)) {
return null
}
if (isHourlyVersion(normalized)) {
return 'hourly'
}
return normalized.includes('-') ? 'rc' : 'stable'
}
export type ReleaseBuild = {
tag: string
version: string
channel: ReleaseChannel
publishedAt: string | null
releaseUrl: string
}
/** Newest first, so the picker's first row is always the channel's current tip. */
export function sortReleaseBuildsNewestFirst(builds: ReleaseBuild[]): ReleaseBuild[] {
return [...builds].sort((left, right) => compareAppVersions(right.version, left.version))
}
+11 -1
View File
@@ -3,6 +3,7 @@ import type { ExecutionHostId } from './execution-host'
import type { RemovedSshTargetTombstone, SshRemotePtyLease, SshTarget } from './ssh-types'
import type { Automation, AutomationExecutionTargetType, AutomationRun } from './automations-types'
import type { WorkspaceSource } from './workspace-source'
import type { ReleaseBuild, ReleaseChannel } from './release-channel'
import type { GitHubProjectSettings } from './github-project-types'
import type {
AgentStatusState,
@@ -2373,9 +2374,12 @@ export type UpdateCheckOptions = {
includePrerelease?: boolean
includePerfPrerelease?: boolean
localBuild?: boolean
/** Dev channel switching; `targetTag` pins an exact build, including older ones. */
channel?: ReleaseChannel
targetTag?: string
}
export type UpdateSource = 'local'
export type UpdateSource = 'local' | 'hourly'
export type UpdateStatus = (
| { state: 'idle' }
@@ -2402,6 +2406,10 @@ export type UpdateStatus = (
| { state: 'error'; message: string; userInitiated?: boolean; activeNudgeId?: string }
) & { source?: UpdateSource }
export type ReleaseBuildListResult =
| { ok: true; channel: ReleaseChannel; builds: ReleaseBuild[] }
| { ok: false; channel: ReleaseChannel; message: string }
// ─── Settings ────────────────────────────────────────────────────────
export type NotificationSettings = {
enabled: boolean
@@ -3377,6 +3385,8 @@ export type PersistedUIState = {
statusBarUsageMode?: StatusBarUsageMode
dismissedUpdateVersion: string | null
lastUpdateCheckAt: number | null
/** Dev-only update channel override; absent means the build's own channel. */
releaseChannelOverride?: ReleaseChannel | null
pendingUpdateNudgeId?: string | null
dismissedUpdateNudgeId?: string | null
/** Whether Orca already tried triggering the macOS notification permission dialog; prevents re-firing every launch. */