diff --git a/scripts/create-update-feed.mjs b/scripts/create-update-feed.mjs index 6a2f8da..663d030 100644 --- a/scripts/create-update-feed.mjs +++ b/scripts/create-update-feed.mjs @@ -68,6 +68,8 @@ const verifyWithExecutable = (verifier, artifact, signature) => { execFileSync(resolve(verifier), [artifact, signature], { stdio: "pipe" }); }; +const githubReleaseAssetName = (path) => basename(path).replaceAll(" ", "."); + export const createUpdateFeed = ({ root, version, tag, output, verifier, verifySignature }) => { if (!SEMVER.test(version)) throw new Error("Invalid semantic version."); if (tag !== `v${version}`) throw new Error(`Release tag ${tag} does not match v${version}.`); @@ -86,7 +88,7 @@ export const createUpdateFeed = ({ root, version, tag, output, verifier, verifyS verify(path, signaturePath); return { signature, - url: `https://github.com/switchifyapp/switchify-pc/releases/download/${encodeURIComponent(tag)}/${encodeURIComponent(basename(path))}`, + url: `https://github.com/switchifyapp/switchify-pc/releases/download/${encodeURIComponent(tag)}/${encodeURIComponent(githubReleaseAssetName(path))}`, }; }; diff --git a/scripts/create-update-feed.node-test.mjs b/scripts/create-update-feed.node-test.mjs index 87b31cf..e729f17 100644 --- a/scripts/create-update-feed.node-test.mjs +++ b/scripts/create-update-feed.node-test.mjs @@ -18,8 +18,8 @@ const fixtures = () => { const windowsDirectory = join(root, "windows-release"); mkdirSync(macDirectory); mkdirSync(windowsDirectory); - const mac = join(macDirectory, "Switchify.PC.app.tar.gz"); - const windows = join(windowsDirectory, "Switchify.PC_1.0.0_x64-setup.exe"); + const mac = join(macDirectory, "Switchify PC.app.tar.gz"); + const windows = join(windowsDirectory, "Switchify PC_1.0.0_x64-setup.exe"); writeFileSync(mac, gzipSync("archive fixture")); const pe = Buffer.alloc(128); pe.write("MZ", 0, "ascii"); @@ -48,6 +48,18 @@ describe("createUpdateFeed", () => { assert.equal(feed.platforms["windows-x86_64"].signature, "windows-signature"); }); + it("uses the dot-normalized names GitHub assigns to release assets", () => { + const feed = createUpdateFeed(options(fixtures())); + assert.equal( + feed.platforms["darwin-aarch64"].url, + "https://github.com/switchifyapp/switchify-pc/releases/download/v1.0.0-beta.1/Switchify.PC.app.tar.gz", + ); + assert.equal( + feed.platforms["windows-x86_64"].url, + "https://github.com/switchifyapp/switchify-pc/releases/download/v1.0.0-beta.1/Switchify.PC_1.0.0_x64-setup.exe", + ); + }); + it("refuses a non-empty signature that fails cryptographic verification", () => { const fixture = fixtures(); assert.throws(