botpress / botpress-electron

This converts the Botpress binaries into a binary downloader / installer / runner
MIT License
0 stars 2 forks source link

(feature) Dynamically loaded botpress.com/download links #11

Closed ptrckbp closed 2 years ago

ptrckbp commented 2 years ago

Add this to website so that the download links automatically points to first non-pre-release version.

const url = "https://api.github.com/repos/botpress/botpress-electron/releases"
axios.get(url).then(({data})=>{
  const legitReleases = data.filter(({draft,prerelease})=>{
    return draft === false && prerelease === false
  })
  legitReleases.sort((a,b)=>{
    return a.published_at > b.published_at ? -1 : a.published_at < b.published_at 
  })

  const firstLegitRelease = legitReleases[0]

  const dmgUrl = firstLegitRelease.assets.find(({name})=>{
    return name.slice(-4) === ".dmg" 
  }).browser_download_url

  const snapUrl = firstLegitRelease.assets.find(({name})=>{
    return name.slice(-5) === ".snap" 
  }).browser_download_url

   const exeUrl = firstLegitRelease.assets.find(({name})=>{
    return name.slice(-4) === ".exe" 
  }).browser_download_url

   console.log({
     dmgUrl,snapUrl,exeUrl
   })
})
ptrckbp commented 2 years ago

This is solved. You can see the new download links on botpress.com/download. Also, I just pushed a new release, and the changes were propagated to the download page as expected! Thanks Janin!