Skip to content

Commit

Permalink
fix: 'latest' gets latest version, else get specific version
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Mar 24, 2024
1 parent 99ae9d5 commit edd1c10
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions apps/web/app/api/releases/tauri/[version]/[target]/[arch]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ export async function GET(
}
) {
try {
const { data: release } = await octokit.repos.getLatestRelease({
owner: "capsoftware",
repo: "cap",
});
let release;
if (params.version === "latest") {
const { data } = await octokit.repos.getLatestRelease({
owner: "capsoftware",
repo: "cap",
});
release = data;
} else {
const { data } = await octokit.repos.getReleaseByTag({
owner: "capsoftware",
repo: "cap",
tag: `cap-v${params.version}`,
});
release = data;
}

const version = release.tag_name.replace("cap-v", "");
const notes = release.body;
Expand All @@ -31,22 +42,11 @@ export async function GET(
: null;

const asset = release.assets.find((asset) => {
const isVersionMatch = asset.name.includes(version);
const isArchMatch = asset.name.includes(params.arch);
let isTargetMatch = false;

switch (params.target) {
case "mac":
isTargetMatch = asset.name.endsWith(".dmg");
break;
case "linux":
isTargetMatch = asset.name.endsWith(".tar.gz");
break;
case "windows":
isTargetMatch = asset.name.endsWith(".exe");
}
const isTargetMatch =
asset.name.endsWith(".tar.gz") && !asset.name.endsWith(".tar.gz.sig");

return isVersionMatch && isArchMatch && isTargetMatch;
return isArchMatch && isTargetMatch;
});

if (!asset) {
Expand Down

1 comment on commit edd1c10

@vercel
Copy link

@vercel vercel bot commented on edd1c10 Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.