These days I build my WordPress plugins for Composer install. I still provide standalone releases for people who don’t use it. Now and then people skip over install instructions and download the source of the plugin. Which does not work by itself.
I decided to improve this and provide a more visible direct download option in the readme files.
Latest release URL
To host standalone release I generate a zip archive and attach it to a GitHub release. Before I linked to the releases section, e.g.
That page can look very busy and in current design links to attached assets are tiny.
You can now use a link that will always go to the latest release, e.g.
But it still points to a page, not a direct download.
Latest binary URL
Direct download URL is available via GitHub API though. We need to get to it and a way to send a client to it.
The latest release API call will give us all the information about that, e.g.
GitHub readme files are very static and cannot retrieve this information. For that, I had added a simple WordPress redirect endpoint to my own site. It queries GitHub API and a sends client to the direct download. I have added a white list and caching to it, so that the whole Internet doesn’t start to pipe things through my site. :)
Now I had the link that would always go to the latest release download:
I already use Shields badges on readme pages. That looked like a good way to create a prominent image for the download button.
After some tinkering, I have made a button that queries GitHub API and extracts release file name from it:
And the result looks like this:
Now I combine the two and get a download button in the readme. It is completely static and GitHub is ok with it. But it will always show and send a client to the very latest release download.