fix(release): repair ota and desktop update flows
This commit is contained in:
@@ -15,6 +15,10 @@ const DEFAULT_MOBILE_PROJECT_DIR = join(REPO_ROOT, "apps", "mobile")
|
||||
const DEFAULT_DESKTOP_PROJECT_DIR = join(REPO_ROOT, "apps", "desktop")
|
||||
const OTA_PLATFORMS = ["ios", "android"]
|
||||
const DESKTOP_PLATFORMS = new Set(["macos", "windows", "linux"])
|
||||
const DESKTOP_DEFAULT_CHANNEL = "stable"
|
||||
const DESKTOP_MAC_APP_STORE_URL =
|
||||
"https://apps.apple.com/us/app/folo-follow-everything/id6739802604"
|
||||
const DESKTOP_MICROSOFT_STORE_URL = "https://apps.microsoft.com/detail/9nvfzpv0v0ht?mode=direct"
|
||||
const CONTENT_TYPES = new Map([
|
||||
[".aac", "audio/aac"],
|
||||
[".bmp", "image/bmp"],
|
||||
@@ -247,6 +251,7 @@ export async function buildDesktopReleaseAssets(options = {}) {
|
||||
const [owner, repo] = resolveRepository(options)
|
||||
const releaseKind = releaseConfig.mode === "ota" ? "ota" : "binary"
|
||||
const runtimeVersion = releaseConfig.mode === "ota" ? releaseConfig.runtimeVersion : null
|
||||
const channel = releaseConfig.channel ?? DESKTOP_DEFAULT_CHANNEL
|
||||
const desktopApp =
|
||||
releaseConfig.mode === "binary-policy"
|
||||
? null
|
||||
@@ -277,7 +282,7 @@ export async function buildDesktopReleaseAssets(options = {}) {
|
||||
const otaMetadata = {
|
||||
schemaVersion: 2,
|
||||
product,
|
||||
channel: releaseConfig.channel ?? null,
|
||||
channel,
|
||||
releaseVersion,
|
||||
releaseKind,
|
||||
runtimeVersion,
|
||||
@@ -290,9 +295,13 @@ export async function buildDesktopReleaseAssets(options = {}) {
|
||||
required: releaseConfig.required ?? false,
|
||||
minSupportedBinaryVersion: process.env.OTA_MIN_SUPPORTED_BINARY_VERSION ?? releaseVersion,
|
||||
message: releaseConfig.message ?? null,
|
||||
distributions: Object.fromEntries(
|
||||
(releaseConfig.distributions ?? []).map((distribution) => [distribution, {}]),
|
||||
),
|
||||
distributions: resolveDesktopPolicyDistributions({
|
||||
mode: releaseConfig.mode,
|
||||
distributions: releaseConfig.distributions ?? [],
|
||||
owner,
|
||||
repo,
|
||||
gitTag,
|
||||
}),
|
||||
},
|
||||
desktop: {
|
||||
renderer: desktopRenderer,
|
||||
@@ -844,6 +853,53 @@ function buildGitHubAssetUrl({ owner, repo, tag, filename }) {
|
||||
return `https://github.com/${owner}/${repo}/releases/download/${tag}/${filename}`
|
||||
}
|
||||
|
||||
function buildGitHubReleaseUrl({ owner, repo, tag }) {
|
||||
return `https://github.com/${owner}/${repo}/releases/tag/${tag}`
|
||||
}
|
||||
|
||||
function resolveDesktopPolicyDistributions({ mode, distributions, owner, repo, gitTag }) {
|
||||
const normalizedDistributions =
|
||||
mode === "build" && distributions.length === 0 ? ["direct"] : distributions
|
||||
|
||||
return Object.fromEntries(
|
||||
normalizedDistributions.map((distribution) => {
|
||||
switch (distribution) {
|
||||
case "direct": {
|
||||
return [
|
||||
distribution,
|
||||
{
|
||||
downloadUrl: buildGitHubReleaseUrl({
|
||||
owner,
|
||||
repo,
|
||||
tag: gitTag,
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
case "mas": {
|
||||
return [
|
||||
distribution,
|
||||
{
|
||||
storeUrl: DESKTOP_MAC_APP_STORE_URL,
|
||||
},
|
||||
]
|
||||
}
|
||||
case "mss": {
|
||||
return [
|
||||
distribution,
|
||||
{
|
||||
storeUrl: DESKTOP_MICROSOFT_STORE_URL,
|
||||
},
|
||||
]
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported desktop distribution "${distribution}"`)
|
||||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
function resolveRepository(options) {
|
||||
if (options.owner && options.repo) {
|
||||
return [options.owner, options.repo]
|
||||
|
||||
@@ -344,8 +344,13 @@ releaseDate: 2026-04-11T10:00:00.000Z
|
||||
expect(result.otaMetadata.product).toBe("desktop")
|
||||
expect(result.otaMetadata.releaseKind).toBe("binary")
|
||||
expect(result.otaMetadata.runtimeVersion).toBeNull()
|
||||
expect(result.otaMetadata.channel).toBeNull()
|
||||
expect(result.otaMetadata.channel).toBe("stable")
|
||||
expect(result.otaMetadata.desktop.renderer).toBeNull()
|
||||
expect(result.otaMetadata.policy.distributions).toEqual({
|
||||
direct: {
|
||||
downloadUrl: "https://github.com/RSSNext/Folo/releases/tag/desktop/v1.5.1",
|
||||
},
|
||||
})
|
||||
expect(result.otaMetadata.desktop.app.platforms.windows).toEqual(
|
||||
expect.objectContaining({
|
||||
platform: "windows-x64",
|
||||
@@ -471,8 +476,12 @@ releaseDate: 2026-04-11T10:00:00.000Z
|
||||
minSupportedBinaryVersion: "1.5.1",
|
||||
message: "Install the latest desktop app.",
|
||||
distributions: {
|
||||
mas: {},
|
||||
mss: {},
|
||||
mas: {
|
||||
storeUrl: "https://apps.apple.com/us/app/folo-follow-everything/id6739802604",
|
||||
},
|
||||
mss: {
|
||||
storeUrl: "https://apps.microsoft.com/detail/9nvfzpv0v0ht?mode=direct",
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(result.otaMetadata.desktop).toEqual({
|
||||
@@ -517,6 +526,11 @@ releaseDate: 2026-04-11T10:00:00.000Z
|
||||
repo: "Folo",
|
||||
})
|
||||
|
||||
expect(result.otaMetadata.policy.distributions).toEqual({
|
||||
direct: {
|
||||
downloadUrl: "https://github.com/RSSNext/Folo/releases/tag/desktop/v1.5.1",
|
||||
},
|
||||
})
|
||||
expect(result.otaMetadata.desktop.app).toBeNull()
|
||||
expect(result.archivePath).toBeNull()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user