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
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-node@v7
with:
node-version: 22

- name: Detect exact beta release preparation
id: beta-release-prep
if: github.event_name == 'pull_request'
continue-on-error: true
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
git show "${BASE_SHA}:scripts/classify-beta-release-prep.mjs" > "$RUNNER_TEMP/classify-beta-release-prep.mjs"
node "$RUNNER_TEMP/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"
trusted_root="$RUNNER_TEMP/openalice-release-policy"
mkdir -p "$trusted_root"
git archive "$BASE_SHA" scripts/classify-beta-release-prep.mjs packages/update-lifecycle/src/release-policy.ts | tar -x -C "$trusted_root"
node "$trusted_root/scripts/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"

- uses: pnpm/action-setup@v6

Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/cli-installer-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-node@v7
with:
node-version: 22

- name: Detect exact beta release preparation
id: beta-release-prep
if: github.event_name == 'pull_request'
continue-on-error: true
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
git show "${BASE_SHA}:scripts/classify-beta-release-prep.mjs" > "$RUNNER_TEMP/classify-beta-release-prep.mjs"
node "$RUNNER_TEMP/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"
trusted_root="$RUNNER_TEMP/openalice-release-policy"
mkdir -p "$trusted_root"
git archive "$BASE_SHA" scripts/classify-beta-release-prep.mjs packages/update-lifecycle/src/release-policy.ts | tar -x -C "$trusted_root"
node "$trusted_root/scripts/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"

bun-cli-feasibility:
needs: release-prep-scope
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/desktop-package-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-node@v7
with:
node-version: 22

- name: Detect exact beta release preparation
id: beta-release-prep
if: github.event_name == 'pull_request'
continue-on-error: true
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
git show "${BASE_SHA}:scripts/classify-beta-release-prep.mjs" > "$RUNNER_TEMP/classify-beta-release-prep.mjs"
node "$RUNNER_TEMP/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"
trusted_root="$RUNNER_TEMP/openalice-release-policy"
mkdir -p "$trusted_root"
git archive "$BASE_SHA" scripts/classify-beta-release-prep.mjs packages/update-lifecycle/src/release-policy.ts | tar -x -C "$trusted_root"
node "$trusted_root/scripts/classify-beta-release-prep.mjs" --github-output "$GITHUB_OUTPUT"

- uses: pnpm/action-setup@v6
if: steps.beta-release-prep.outcome != 'success' || steps.beta-release-prep.outputs.beta_release_prep != 'true'
Expand Down
103 changes: 49 additions & 54 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ jobs:
previous_tag: ${{ steps.plan.outputs.previous_tag }}
source_sha: ${{ steps.plan.outputs.source_sha }}
verifier_sha: ${{ steps.verifier.outputs.verifier_sha }}
channel_head_sha256: ${{ steps.plan.outputs.channel_head_sha256 }}

steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # full history for release tag validation and channel selection

- uses: actions/setup-node@v7
with:
node-version: 22

- name: Validate release intent and version authority
id: plan
env:
Expand All @@ -134,6 +139,7 @@ jobs:
RELEASE_CHANNEL: ${{ inputs.channel }}
SOURCE_REF: ${{ github.ref }}
SOURCE_SHA: ${{ github.sha }}
DOWNLOAD_BASE_URL: ${{ secrets.DOWNLOAD_BASE_URL }}
run: |
set -euo pipefail

Expand All @@ -146,28 +152,30 @@ jobs:
exit 1
fi

VERSION="${RELEASE_TAG#v}"
if [ "$RELEASE_TAG" != "v${VERSION}" ]; then
echo "Release tag must start with v" >&2
exit 1
fi
if [ "$RELEASE_CHANNEL" = "stable" ]; then
TAG_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+$'
PREVIOUS_TAG_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+$'
MANIFEST_PATH="manifest.json"
elif [ "$RELEASE_CHANNEL" = "beta" ]; then
TAG_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+-beta(\.[1-9][0-9]*)?$'
PREVIOUS_TAG_PATTERN='^v[0-9]+\.[0-9]+\.[0-9]+-beta(\.[1-9][0-9]*)?$'
MANIFEST_PATH="beta/manifest.json"
else
echo "Release channel must be beta or stable, got: $RELEASE_CHANNEL" >&2
exit 1
fi

if [[ ! "$RELEASE_TAG" =~ $TAG_PATTERN ]]; then
echo "Release tag $RELEASE_TAG does not match channel $RELEASE_CHANNEL" >&2
echo "Release channel must be beta or stable" >&2
exit 1
fi
BASE_URL="${DOWNLOAD_BASE_URL:-https://download.openalice.ai}"
curl -fsSL "${BASE_URL%/}/${MANIFEST_PATH}" -o "$RUNNER_TEMP/openalice-intent-head.json"
HEAD_SHA256=$(node scripts/prepare-desktop-release-assets.mjs check-publication \
--head-path "$RUNNER_TEMP/openalice-intent-head.json" --version "$VERSION" \
--channel "$RELEASE_CHANNEL" --operation "$OPERATION")
echo "channel_head_sha256=$HEAD_SHA256" >> "$GITHUB_OUTPUT"

VERSION="${RELEASE_TAG#v}"
if [ "$OPERATION" = "release" ]; then
PACKAGE_VERSION=$(node -p "require('./package.json').version")
CLI_VERSION=$(node -p "require('./packages/cli/package.json').version")
if [ "$PACKAGE_VERSION" != "$VERSION" ] || [ "$CLI_VERSION" != "$VERSION" ]; then
echo "Release tag $RELEASE_TAG requires package versions $VERSION; root=$PACKAGE_VERSION cli=$CLI_VERSION" >&2
if [ "$PACKAGE_VERSION" != "$VERSION" ]; then
echo "Release tag $RELEASE_TAG requires root product version $VERSION; root=$PACKAGE_VERSION" >&2
exit 1
fi

Expand All @@ -189,13 +197,9 @@ jobs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "channel=$RELEASE_CHANNEL" >> "$GITHUB_OUTPUT"
PREVIOUS_TAG=$(
git for-each-ref --merged="$SOURCE_SHA" --sort=-version:refname \
--format='%(refname:short)' refs/tags \
| grep -E "$PREVIOUS_TAG_PATTERN" \
| head -n 1 \
|| true
)
git for-each-ref --merged="$SOURCE_SHA" --format='%(refname:short)' refs/tags > "$RUNNER_TEMP/openalice-reachable-tags.txt"
PREVIOUS_TAG=$(node scripts/prepare-desktop-release-assets.mjs previous-tag \
--tags-path "$RUNNER_TEMP/openalice-reachable-tags.txt" --channel "$RELEASE_CHANNEL")
if [ "$OPERATION" = "release" ] && [ -z "$PREVIOUS_TAG" ]; then
echo "No previous $RELEASE_CHANNEL release tag is reachable from $SOURCE_SHA" >&2
exit 1
Expand Down Expand Up @@ -1117,9 +1121,7 @@ jobs:
gh api "repos/$GITHUB_REPOSITORY/releases/latest" > release.json
jq -e --arg tag "$RELEASE_TAG" '.tag_name == $tag and .draft == false and .prerelease == false' release.json
git merge-base --is-ancestor "$RELEASE_TAG^{commit}" origin/master
for manifest in package.json packages/cli/package.json; do
test "$(git show "$RELEASE_TAG:$manifest" | jq -r .version)" = "${RELEASE_TAG#v}"
done
test "$(git show "$RELEASE_TAG:package.json" | jq -r .version)" = "${RELEASE_TAG#v}"

- name: Verify npm authority for this explicit publication
run: node scripts/preflight-public-cli-authority.mjs
Expand Down Expand Up @@ -1386,28 +1388,6 @@ jobs:
python3 -m pip install --user awscli
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- name: Keep mirror repair on the active channel release
if: needs.release.outputs.operation == 'mirror'
env:
DOWNLOAD_BASE_URL: ${{ secrets.DOWNLOAD_BASE_URL }}
RELEASE_CHANNEL: ${{ needs.release.outputs.channel }}
VERSION: ${{ needs.release.outputs.version }}
run: |
set -euo pipefail
BASE_URL="${DOWNLOAD_BASE_URL:-https://download.openalice.ai}"
BASE_URL="${BASE_URL%/}"
if [ "$RELEASE_CHANNEL" = "stable" ]; then
MANIFEST_PATH="manifest.json"
else
MANIFEST_PATH="beta/manifest.json"
fi
curl -fsSL "${BASE_URL}/${MANIFEST_PATH}" -o /tmp/openalice-active-channel.json
CHANNEL="$RELEASE_CHANNEL" VERSION="$VERSION" node -e '
const value = require("/tmp/openalice-active-channel.json");
if (value.version !== process.env.VERSION) process.exit(1);
if (value.channel !== undefined && value.channel !== process.env.CHANNEL) process.exit(1);
'

- name: Snapshot stable aliases before a beta mirror
if: needs.release.outputs.channel == 'beta'
env:
Expand All @@ -1432,12 +1412,17 @@ jobs:
R2_BUCKET: ${{ secrets.R2_BUCKET }}
RELEASE_CHANNEL: ${{ needs.release.outputs.channel }}
RELEASE_OPERATION: ${{ needs.release.outputs.operation }}
VERSION: ${{ needs.release.outputs.version }}
EXPECTED_HEAD_SHA256: ${{ needs.release.outputs.channel_head_sha256 }}
run: |
set -euo pipefail
ENDPOINT="https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com"
if [ "$RELEASE_CHANNEL" = "stable" ]; then
FEED_PREFIX="latest"
MANIFEST_PATH="manifest.json"
else
FEED_PREFIX="beta"
MANIFEST_PATH="beta/manifest.json"
fi

aws s3 cp dist/r2-upload "s3://${R2_BUCKET}/" \
Expand All @@ -1458,14 +1443,6 @@ jobs:
--cache-control "public, max-age=31536000, immutable" \
--endpoint-url "$ENDPOINT"

aws s3 cp dist/r2-upload "s3://${R2_BUCKET}/" \
--recursive \
--exclude "*" \
--include "${FEED_PREFIX}*.yml" \
--cache-control "no-cache" \
--content-type "text/yaml" \
--endpoint-url "$ENDPOINT"

for installer in \
dist/r2-upload/OpenAlice-*-install \
dist/r2-upload/OpenAlice-*-install.sha256 \
Expand All @@ -1486,6 +1463,24 @@ jobs:
fi
done

# The workflow's publication concurrency group owns all channel writes.
# Re-read the object store itself, after immutable uploads, before any
# mutable feed, installer alias, or manifest changes.
aws s3 cp "s3://${R2_BUCKET}/${MANIFEST_PATH}" "$RUNNER_TEMP/openalice-publish-head.json" \
--endpoint-url "$ENDPOINT" --only-show-errors
node scripts/prepare-desktop-release-assets.mjs check-publication \
--head-path "$RUNNER_TEMP/openalice-publish-head.json" --version "$VERSION" \
--channel "$RELEASE_CHANNEL" --operation "$RELEASE_OPERATION" \
--expected-sha256 "$EXPECTED_HEAD_SHA256"

aws s3 cp dist/r2-upload "s3://${R2_BUCKET}/" \
--recursive \
--exclude "*" \
--include "${FEED_PREFIX}*.yml" \
--cache-control "no-cache" \
--content-type "text/yaml" \
--endpoint-url "$ENDPOINT"

if [ "$RELEASE_OPERATION" = "release" ]; then
aws s3 cp dist/r2-upload/install.ps1 "s3://${R2_BUCKET}/install.ps1" \
--cache-control "no-cache" --content-type "text/plain" --endpoint-url "$ENDPOINT"
Expand Down
4 changes: 0 additions & 4 deletions PLANS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ the durable truth after it changes. Git history is the archive.

## Active

- [[plans/version-lifecycle-convergence.md]] — Remove competing product identity,
upgrade eligibility, status translation, recovery routing, and release policy
entry points; acceptance follows the reproduced defects in #1721.

- [[plans/settings-machines-dialog.md]] — Move machine management into General / Machines and replace inline SSH setup with a reviewed dialog; Draft PR only.

- [[plans/review-updates-shared-plan.md]] — Share automatic/manual update review
Expand Down
61 changes: 52 additions & 9 deletions apps/desktop/src/auto-update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mocks = vi.hoisted(() => {
},
autoUpdater: {
checkForUpdates: vi.fn(),
downloadUpdate: vi.fn(async () => []),
quitAndInstall: vi.fn(),
on: vi.fn((event: string, listener: (...args: unknown[]) => unknown) => {
listeners.set(event, listener)
Expand Down Expand Up @@ -81,17 +82,15 @@ describe('configureAutoUpdate', () => {

expect([...mocks.handlers.keys()]).toEqual([
'openalice:updater:get-status',
'openalice:updater:install-and-restart',
'openalice:updater:open-release',
])
expect(mocks.autoUpdater.checkForUpdates).not.toHaveBeenCalled()

const getStatus = mocks.handlers.get('openalice:updater:get-status')
const install = mocks.handlers.get('openalice:updater:install-and-restart')
const openRelease = mocks.handlers.get('openalice:updater:open-release')
expect(await getStatus?.()).toBeNull()
await expect(controls.discover()).resolves.toMatchObject({ status: 'unsupported', message: 'not-packaged', currentVersion: '0.94.1-beta.2', channel: 'dev' })
await expect(install?.()).rejects.toThrow('No downloaded update is ready to install.')
await expect(controls.install()).rejects.toThrow('No downloaded update is ready to install.')
await openRelease?.({}, undefined)
expect(mocks.shell.openExternal)
.toHaveBeenCalledWith('https://github.com/TraderAlice/OpenAlice/releases')
Expand Down Expand Up @@ -122,6 +121,52 @@ describe('configureAutoUpdate', () => {
expect(mocks.autoUpdater.checkForUpdates).toHaveBeenCalledOnce()
})

it.each([
['0.94.1', '0.94.0', 'blocked', 'older-release'],
['0.94.1-beta.10', '0.94.1-beta.2', 'blocked', 'older-release'],
['0.94.1+local.7', '0.94.1', 'current', 'same-release'],
['0.94.1-beta.2', '0.94.1-beta.10', 'available', 'newer-release'],
['0.94.1', '0.95.0', 'available', 'newer-release'],
['0.94.1', '0.94.1-beta.2', 'unknown', 'invalid-identity'],
['0.94.1', 'invalid', 'unknown', 'invalid-identity'],
])('uses policy for native event %s -> %s (%s)', async (current, candidate, status, reason) => {
mocks.app.isPackaged = true
mocks.capability = { enabled: true, configPath: '/fixture/app-update.yml' }
const beforeInstall = vi.fn()
const controls = configureAutoUpdate({ isDestroyed: () => false, webContents: { send: vi.fn() } } as never, { beforeInstall }, current)
// Transport intentionally advertises every candidate as available.
mocks.autoUpdater.checkForUpdates.mockImplementationOnce(async () => { mocks.listeners.get('update-available')?.({ version: candidate }) })
await expect(controls.discover()).resolves.toMatchObject({ status, reason, latestVersion: candidate })
expect(mocks.autoUpdater.downloadUpdate).toHaveBeenCalledTimes(status === 'available' ? 1 : 0)
if (status !== 'available') {
mocks.listeners.get('update-downloaded')?.({ version: candidate })
expect(controls.downloaded()).toBeNull()
await expect(controls.install(candidate)).rejects.toThrow()
expect(beforeInstall).not.toHaveBeenCalled()
expect(mocks.autoUpdater.quitAndInstall).not.toHaveBeenCalled()
}
})

it('does not turn an older native no-update result into current', async () => {
mocks.app.isPackaged = true
mocks.capability = { enabled: true, configPath: '/fixture/app-update.yml' }
const controls = configureAutoUpdate({ isDestroyed: () => false, webContents: { send: vi.fn() } } as never, { beforeInstall: vi.fn() }, '0.94.1')
mocks.autoUpdater.checkForUpdates.mockImplementationOnce(async () => { mocks.listeners.get('update-not-available')?.({ version: '0.94.0' }) })
await expect(controls.discover()).resolves.toMatchObject({ status: 'blocked', reason: 'older-release' })
})

it('rejects a changed download after review and a stale response during installation', async () => {
mocks.app.isPackaged = true
mocks.capability = { enabled: true, configPath: '/fixture/app-update.yml' }
const controls = configureAutoUpdate({ isDestroyed: () => false, webContents: { send: vi.fn() } } as never, {
beforeInstall: async () => { mocks.listeners.get('update-downloaded')?.({ version: '0.96.0' }) },
}, '0.94.1')
mocks.listeners.get('update-downloaded')?.({ version: '0.95.0' })
await expect(controls.install('0.94.2')).rejects.toThrow('changed')
await expect(controls.install('0.95.0')).rejects.toThrow('changed')
expect(mocks.autoUpdater.quitAndInstall).not.toHaveBeenCalled()
})

it('reports visible install stages before handing off to the native updater', async () => {
mocks.app.isPackaged = true
mocks.capability = { enabled: true, configPath: '/Applications/OpenAlice.app/app-update.yml' }
Expand All @@ -132,7 +177,7 @@ describe('configureAutoUpdate', () => {
report('releasing-runtime')
})
const onInstallHandoff = vi.fn(async () => {})
configureAutoUpdate({
const controls = configureAutoUpdate({
isDestroyed: () => false,
setProgressBar,
webContents: { send },
Expand All @@ -141,8 +186,7 @@ describe('configureAutoUpdate', () => {
mocks.listeners.get('update-available')?.({ version: '0.88.0-beta' })
mocks.listeners.get('download-progress')?.({ percent: 42.4 })
mocks.listeners.get('update-downloaded')?.({ version: '0.88.0-beta' })
const install = mocks.handlers.get('openalice:updater:install-and-restart')!
await expect(install()).resolves.toEqual({ ok: true })
await expect(controls.install()).resolves.toEqual({ ok: true })

expect(beforeInstall).toHaveBeenCalledWith('0.88.0-beta', expect.any(Function))
expect(onInstallHandoff).toHaveBeenCalledWith('0.88.0-beta')
Expand All @@ -160,7 +204,7 @@ describe('configureAutoUpdate', () => {
mocks.app.isPackaged = true
mocks.capability = { enabled: true, configPath: '/Applications/OpenAlice.app/app-update.yml' }
const onInstallFailure = vi.fn(async () => {})
configureAutoUpdate({
const controls = configureAutoUpdate({
isDestroyed: () => false,
setProgressBar: vi.fn(),
webContents: { send: vi.fn() },
Expand All @@ -173,8 +217,7 @@ describe('configureAutoUpdate', () => {
throw new Error('ShipIt refused the update')
})

const install = mocks.handlers.get('openalice:updater:install-and-restart')!
await expect(install()).rejects.toThrow('ShipIt refused the update')
await expect(controls.install()).rejects.toThrow('ShipIt refused the update')
expect(onInstallFailure).toHaveBeenCalledOnce()
})
})
Loading
Loading