commit
aaa
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index eabcef4..bd38d56 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -252,6 +252,67 @@ jobs:
echo "Patched AppImage: $DIR/$NAME"
gh release upload "$TAG" "$NAME" --clobber
+ # appimagetool is itself an .AppImage sitting in the bundle
+ # directory; the rename step below globs that directory by
+ # extension, so both it and the extracted tree have to go.
+ rm -rf squashfs-root appimagetool
+
+ # Republish the desktop artifacts under version-less asset names.
+ #
+ # Tauri names bundles from `productName` plus tauri.conf.json's
+ # `version` — which is still 1.0.0 and is not bumped per release — so
+ # they land as Doughmination.Music_1.0.0_x64-setup.exe: a version that
+ # is both wrong and, if it ever were bumped, unstable. Stable names are
+ # what let the site's /download?platform=windows point at a release
+ # without hardcoding a filename per version (see
+ # apps/server/src/lib/downloads.json).
+ #
+ # tauri-action has already attached the versioned names to the draft
+ # release, so each file is re-uploaded under its stripped name and the
+ # versioned asset then deleted.
+ - name: republish artifacts under version-less names
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAG: ${{ inputs.version || github.ref_name }}
+ run: |
+ set -eu
+
+ STAGE=$(mktemp -d)
+ found=0
+
+ # /usr/bin/find explicitly: on the Windows runner a bare `find` can
+ # resolve to Windows' FIND.EXE, which takes none of these flags.
+ while IFS= read -r f; do
+ [ -n "$f" ] || continue
+ found=1
+ old=$(basename "$f")
+ # Strips a _1.2.3_ / -1.2.3- segment wherever the bundler put it:
+ # Doughmination.Music_1.0.0_x64-setup.exe
+ # -> Doughmination.Music_x64-setup.exe
+ # Doughmination.Music-1.0.0-1.x86_64.rpm
+ # -> Doughmination.Music-1.x86_64.rpm
+ new=$(printf '%s' "$old" | sed -E 's/([._-])[0-9]+\.[0-9]+\.[0-9]+[._-]/\1/')
+ if [ "$new" = "$old" ]; then
+ echo "unchanged: $old"
+ continue
+ fi
+ echo "$old -> $new"
+ cp "$f" "$STAGE/$new"
+ gh release upload "$TAG" "$STAGE/$new" --clobber
+ gh release delete-asset "$TAG" "$old" --yes
+ done <<EOF
+ $(/usr/bin/find apps/desktop/src-tauri/target -type f -path '*/bundle/*' \
+ \( -name '*.exe' -o -name '*.msi' -o -name '*.dmg' \
+ -o -name '*.AppImage' -o -name '*.deb' -o -name '*.rpm' \
+ -o -name '*.app.tar.gz' \))
+ EOF
+
+ if [ "$found" = 0 ]; then
+ echo "::error::No bundled artifacts found to rename"
+ exit 1
+ fi
+
android:
# Builds and publishes the SIGNED native Android APK (apps/android): a
# WebView shell around the site plus a native Media3 playback service
@@ -324,8 +385,10 @@ jobs:
exit 1
fi
echo "Signed APK: $APK"
- cp "$APK" "doughmination-music-$TAG-android.apk"
- gh release upload "$TAG" "doughmination-music-$TAG-android.apk" --clobber
+ # Version-less, like the desktop artifacts — see the "republish
+ # artifacts under version-less names" step in the build job.
+ cp "$APK" "doughmination-music-android.apk"
+ gh release upload "$TAG" "doughmination-music-android.apk" --clobber
gh release edit "$TAG" --draft=false --latest
aur:
diff --git a/apps/server/src/lib/downloads.json b/apps/server/src/lib/downloads.json
new file mode 100644
index 0000000..3d55f59
--- /dev/null
+++ b/apps/server/src/lib/downloads.json
@@ -0,0 +1,38 @@
+{
+ "repo": "Clove-Web/pocket-id-music-player",
+
+ "latest": "willow",
+
+ "platforms": {
+ "windows": "Doughmination.Music_x64-setup.exe",
+ "mac": "Doughmination.Music_universal.dmg",
+ "linux": "Doughmination.Music_amd64.AppImage",
+ "deb": "Doughmination.Music_amd64.deb",
+ "android": "doughmination-music-android.apk"
+ },
+
+ "aliases": {
+ "win": "windows",
+ "exe": "windows",
+ "macos": "mac",
+ "osx": "mac",
+ "dmg": "mac",
+ "appimage": "linux",
+ "debian": "deb",
+ "ubuntu": "deb",
+ "apk": "android"
+ },
+
+ "versions": {
+ "willow": {
+ "tag": "v2.2.0",
+ "files": {
+ "windows": "Doughmination.Music_1.0.0_x64-setup.exe",
+ "mac": "Doughmination.Music_1.0.0_universal.dmg",
+ "linux": "Doughmination.Music_1.0.0_amd64.AppImage",
+ "deb": "Doughmination.Music_1.0.0_amd64.deb",
+ "android": "doughmination-music-v2.2.0-android.apk"
+ }
+ }
+ }
+}
diff --git a/apps/server/src/lib/downloads.ts b/apps/server/src/lib/downloads.ts
new file mode 100644
index 0000000..4075e36
--- /dev/null
+++ b/apps/server/src/lib/downloads.ts
@@ -0,0 +1,97 @@
+// Resolves /download?version=&platform= to a GitHub release URL.
+//
+// Everything that changes per release lives in downloads.json, not here:
+// which codename maps to which tag, which file each platform ships, and
+// which codename is currently "latest". Cutting a release means editing
+// that file — no code change.
+//
+// A version entry may override the per-platform filenames. That exists
+// because releases up to and including v2.2.0 ("Willow") carry the Tauri
+// version in their asset names (Doughmination.Music_1.0.0_x64-setup.exe),
+// while the release workflow now strips it. Old releases keep working by
+// naming their own files; new ones inherit the defaults and need only a
+// `tag`.
+
+import manifest from "./downloads.json" with { type: "json" };
+
+type Platform = string;
+
+interface VersionEntry {
+ tag: string;
+ files?: Record<Platform, string>;
+}
+
+const repo: string = manifest.repo;
+const platforms: Record<Platform, string> = manifest.platforms;
+const aliases: Record<string, string> = manifest.aliases;
+const versions: Record<string, VersionEntry> = manifest.versions;
+
+export const repoUrl = `https://github.com/${repo}`;
+
+/** Codenames a caller can pass as ?version=, for error messages. */
+export const versionNames = Object.keys(versions);
+
+/** Platform keys a caller can pass as ?platform=, aliases excluded. */
+export const platformNames = Object.keys(platforms);
+
+/**
+ * Looks up a version by codename ("willow") or by its literal tag
+ * ("v2.2.0"), so a link written against either keeps working.
+ */
+function findVersion(name: string): VersionEntry | undefined {
+ const direct = versions[name];
+ if (direct) return direct;
+ return Object.values(versions).find((v) => v.tag.toLowerCase() === name);
+}
+
+export type DownloadTarget =
+ | { kind: "repo"; url: string }
+ | { kind: "release"; url: string; tag: string }
+ | { kind: "asset"; url: string; tag: string; file: string }
+ | { kind: "unknown-version"; value: string }
+ | { kind: "unknown-platform"; value: string };
+
+/**
+ * Neither param -> the repo page. Version only -> that release's page.
+ * Platform only -> that platform's file from whichever version the
+ * manifest marks latest. Both -> that version's file for that platform.
+ */
+export function resolveDownload(
+ versionParam: string | undefined,
+ platformParam: string | undefined,
+): DownloadTarget {
+ const versionName = versionParam?.trim().toLowerCase();
+ const platformInput = platformParam?.trim().toLowerCase();
+
+ if (!versionName && !platformInput) return { kind: "repo", url: repoUrl };
+
+ const version = versionName
+ ? findVersion(versionName)
+ : findVersion(manifest.latest);
+ // A missing `latest` is a manifest bug, not a bad request — fall back to
+ // the repo page rather than 404ing a link that looks fine to the caller.
+ if (!version) {
+ return versionName
+ ? { kind: "unknown-version", value: versionName }
+ : { kind: "repo", url: repoUrl };
+ }
+
+ if (!platformInput) {
+ return {
+ kind: "release",
+ url: `${repoUrl}/releases/tag/${version.tag}`,
+ tag: version.tag,
+ };
+ }
+
+ const platform = aliases[platformInput] ?? platformInput;
+ const file = version.files?.[platform] ?? platforms[platform];
+ if (!file) return { kind: "unknown-platform", value: platformInput };
+
+ return {
+ kind: "asset",
+ url: `${repoUrl}/releases/download/${version.tag}/${file}`,
+ tag: version.tag,
+ file,
+ };
+}
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index cc1ef7a..271f85a 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -11,6 +11,11 @@ import {
isAdmin,
type AppEnv,
} from "./auth/middleware.ts";
+import {
+ resolveDownload,
+ versionNames,
+ platformNames,
+} from "./lib/downloads.ts";
import { ensureMediaDirs } from "./lib/media.ts";
import { startPocketIdGuard } from "./lib/pocketid-guard.ts";
import { authRoutes } from "./routes/auth.ts";
@@ -97,11 +102,34 @@ app.get("/app.js", () => serveFile(join(webDist, "app.js"), "no-cache"));
app.get("/styles.css", () => serveFile(join(webSrc, "styles.css"), "no-cache"));
app.get("/favicon.png", () => serveFile(join(serverPublic, "favicon.png")));
-// Vanity redirect to the source repo. Must sit before the SPA catch-all
-// below, or the `*` route would swallow it and serve index.html instead.
-app.get("/download", (c) =>
- c.redirect("https://github.com/doughmination/pocket-id-music-player/", 302),
-);
+// Vanity download redirect. Must sit before the SPA catch-all below, or
+// the `*` route would swallow it and serve index.html instead.
+//
+// /download -> the repo page
+// /download?version=willow -> that release's page
+// /download?platform=windows -> latest release's installer
+// /download?version=willow&platform=windows -> that release's installer
+//
+// The codename -> tag and platform -> filename tables live in
+// lib/downloads.json; see lib/downloads.ts.
+app.get("/download", (c) => {
+ const target = resolveDownload(c.req.query("version"), c.req.query("platform"));
+
+ switch (target.kind) {
+ case "unknown-version":
+ return c.text(
+ `Unknown version "${target.value}". Available: ${versionNames.join(", ")}`,
+ 404,
+ );
+ case "unknown-platform":
+ return c.text(
+ `Unknown platform "${target.value}". Available: ${platformNames.join(", ")}`,
+ 404,
+ );
+ default:
+ return c.redirect(target.url, 302);
+ }
+});
// SPA fallback: any non-API route returns index.html. Also no-cache, so a
// stale shell can't keep pointing the webview at an old asset.
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 7add213..d8e94d9 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -4,6 +4,7 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
+ "resolveJsonModule": true,
"strict": true,
"noUncheckedIndexedAccess": true,