ReviewOS

also looking at this

stacks/uplink

fix(release): derive the app version instead of copying it

#53
Merged glennmichael123 wants to merge fix/one-version-source into main
5 files +73 -2

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

app/Commands/Uplink.tsmodified+15-1
Changes to app/Commands/Uplink.ts
@@ -234,13 +234,27 @@ export default defineCommand((cli) => {
234234 const built = `${appDir}/storage/framework/desktop-dmg/Uplink-${version}.dmg`
235235 const stable = `${appDir}/storage/framework/desktop-dmg/Uplink.dmg`
236236 copyFileSync(built, stable)
237 // The homepage's download button states the version and size; commit this.
237 // What the homepage's download button reads.
238238 await Bun.write(`${appDir}/resources/data/release.json`, `${JSON.stringify({
239239 version,
240240 bytes: Bun.file(built).size,
241241 minimumMacOS: '13',
242242 url: 'https://github.com/stacksjs/uplink/releases/latest/download/Uplink.dmg',
243243 }, null, 2)}\n`)
244
245 // Committed and pushed here rather than left as a note to whoever is
246 // releasing. `gh` cuts the tag from the remote tip, so this has to land
247 // first or the tagged commit does not contain its own release metadata,
248 // and the site keeps advertising the previous version until somebody
249 // remembers. Skipped when nothing changed, so re-running a release for
250 // the same version is not an error.
251 const pending = Bun.spawnSync(['git', 'status', '--porcelain', 'resources/data/release.json'], { cwd: appDir }).stdout.toString().trim()
252 if (pending) {
253 step(['git', 'add', 'resources/data/release.json'])
254 step(['git', 'commit', '-m', `chore: Uplink ${version} is out`])
255 step(['git', 'push'])
256 }
257
244258 step(['gh', 'release', 'create', `v${version}`, stable, built, '--title', `Uplink ${version}`, '--notes', `Uplink ${version} for macOS 13 or later. Signed with a Developer ID and notarized by Apple.`, ...(options.draft ? ['--draft'] : [])])
245259 process.exit(0)
246260 })
app/Uplink/service.tsmodified+8-1
Changes to app/Uplink/service.ts
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, rmSync } from 'node:fs'
22import { homedir } from 'node:os'
33import { join } from 'node:path'
44import process from 'node:process'
5import pkg from '../../package.json'
56
67/**
78 * Installs Uplink as a login item that stays running: an `Uplink.app` bundle
@@ -43,6 +44,12 @@ function xml(value: string): string {
4344 return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
4445}
4546
47/**
48 * The bundle `buddy uplink:install` writes, from source. Its version comes from
49 * package.json for the same reason the launcher's does: a second copy is a
50 * copy that goes stale, and this one had, so an install from a 0.1.4 tree
51 * reported itself as 0.1.0 to macOS and to anyone reading Get Info.
52 */
4653export function infoPlist(): string {
4754 return `<?xml version="1.0" encoding="UTF-8"?>
4855<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -53,7 +60,7 @@ export function infoPlist(): string {
5360 <key>CFBundleDisplayName</key><string>Uplink (source)</string>
5461 <key>CFBundleExecutable</key><string>Uplink</string>
5562 <key>CFBundlePackageType</key><string>APPL</string>
56 <key>CFBundleShortVersionString</key><string>0.1.0</string>
63 <key>CFBundleShortVersionString</key><string>${xml(pkg.version)}</string>
5764 <key>CFBundleVersion</key><string>1</string>
5865 <key>LSUIElement</key><true/>
5966 <key>LSBackgroundOnly</key><true/>