Permanent link to latest release?

I'm writing an install script for a system that uses Arduinos, and would like to automatically download the latest released version of the Arduino IDE. The Software page gets updated to link to the latest release by number (e.g. 1.8.5 today), but I can't find a link that is always for the latest release, regardless of what that release is. For example, instead of this link:

https://www.arduino.cc/download_handler.php?f=/arduino-**1.8.5**-linux64.tar.xz

It would be most convenient if this link existed:

https://www.arduino.cc/download_handler.php?f=/arduino-**latest-release**-linux64.tar.xz

Does such a thing exist that I've not discovered?

Thanks,
James

Whenever a new release is made they create a tag of that name in the arduino/Arduino repository on GitHub. If you have Git installed on the system you can determine the name of the latest tag and then use that name to generate the URL of the latest IDE version. You should be able to adapt the following to that purpose:
https://stackoverflow.com/a/7261049
The trouble is that would require you to have first cloned the arduino/Arduino repository, which is huge. You can do a shallow clone with --depth 1 and that should reduce the size greatly.

I know it's not an ideal solution but it's the only one I could think of.

Thank you, that is a clever idea.

jamessynge's issue report:

If you do manage to find a workable solution to this please give us an update here. This is something I've considered. I have a script I use with Travis CI and I just update it whenever there is a new IDE release but it would be nice if the list of releases could be automatically generated.

There may be some nifty Git tricks for doing this efficiently or it's also probably possible to get a list of tags/releases via the GitHub API.

I did some more looking into this. Even a shallow clone of the arduino/Arduino repo is still huge but luckily there is a better solution, the git ls-remote --tags command allows you to get tags from a remote, no need to clone! Here's a script I threw together to get the version of the latest release:

git init Arduino  # create empty local repo
cd Arduino
git remote add origin https://github.com/arduino/Arduino.git
git ls-remote --quiet --tags --refs --sort=version:refname | grep --regexp='refs/tags/[0-9]\+\.[0-9]\+\.[0-9]\+\(\(-.*$\)\|$\)' | tail -1 | cut -d '/' -f 3 # get the last of a list of all lightweight tags in semver format in the remote repo

It might be a bit fragile but I think it will continue to work as long as Arduino doesn't do anything weird with their tags. I'm very much an amateur at this stuff so I welcome any suggestions for improvement. I think I prefer this approach to messing with the GitHub API.

In theory you could get the latest version number from
https://www.arduino.cc/latest.txt

In practice ... New IDE update notice missing? · Issue #5496 · arduino/Arduino · GitHub :frowning:

ETA:

Well, you could grab the version number from https://www.arduino.cc/en/Main/ReleaseNotes

Yep, that latest.txt fiasco is really sad. What a dysfunctional operation operation is this where it takes 1.5 months for an obvious, uncontroversial 5 character fix to be made to a text file, then the fix gets somehow reverted and we still can't get anything done about it after 8.5 months. Luckily most of the Arduino team are very professional, but unfortunately there seems to be a weak link in the chain.

That's a good suggestion about the release notes. That might avoid the potential problem of the download not being available immediately after the tag is created (since it takes time for the IDE build and then the upload). I don't know at what point in the release process the release notes are added to the website. Still, the release notes are not intended to be machine readable so I feel that would be a more fragile system than using git tags. Actually I know that at least once the release notes were not published until some time after the release:

facchinm's comment on that issue indicates that, at least at that time, release notes were manually published to the website rather than being part of an automated build process so that's definitely not something to rely on. Of course the git tag is also probably done manually. I would hope tag creation is the trigger for the release build process and so is not possible to forget but that's merely speculation.