Skip to content

Instantly share code, notes, and snippets.

  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Determine latest release asset download URL from site.github in GitHub user pages
Copy link

Considering there are several assets and the asset file name is created the same way for every release but includes the version number (e.g. foo-X.Y.Z-setup.exe or foo-X.Y.Z-src.tar.gz), there is also another approach, that might be to used. One can process

{{ site.github.latest_release.tag_name }}

and create the download URL like this

{{ site.github.releases_url }}/download/latest/foo-{{ site.github.latest_release.tag_name | strip | remove 'v' }}-setup.exe
{{ site.github.releases_url }}/download/latest/foo-{{ site.github.latest_release.tag_name | strip | remove 'v' }}-src.tar.gz

(because it is common to tag the version as vX.Y.Z the leading v is removed from the version tag in the above examples)

Copy link

{% assign msi = site.github.latest_release.assets | where: "content_type", "application/x-msdownload" %}

then iterate over it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment