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
4 changes: 3 additions & 1 deletion scripts/create-update-feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`);
Expand All @@ -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))}`,
};
};

Expand Down
16 changes: 14 additions & 2 deletions scripts/create-update-feed.node-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(
Expand Down