Jump to content

How to automatically download a new release of a project from GitHub?

HunterAP

There are a few projects on GitHub that I follow, but generally only for new releases, such as the RPCS3 program for emulating PS3 games. The issue is that following a repo on GitHub notifies you of everything, such as newly reported issues, comments, commits, etc., but for things that I'm not personally involved in, I just want to see if there is a new release, and if possible I also want to download that release. Normally I use something like Chocolatey (a Windows package manager) to handle updating programs for me through a batch script that's scheduled to run weekly through Task Scheduler, but some apps just aren't on Chocolatey for this to work.

 

I tried finding something like this online, but from I've found none of them are tailored to work in this specific scenario. Such programs I've looekd at:

  • nvcheckerNew Version Checker, does as the name implies. It has GitHub support and documentation, but it's throwing lots of errors for me.
  • GitPython: A Python wrapper for Git, can work with GitHub, but it's very prone to memory leaks and isn't recommended for what I plan to do with it.

I figure I can make a script in Python to accomplish, but I'm not sure how to go about it. For example, RPCS3 has a repo just for new windows releases, and they are all listed as the most recently uploaded with the most updated version being listed as "Latest Release", but the latest release is not always shown at the very beginning of the list. I'm not sure how to check what is the latest release.

 

The next issue is that I'm not well-versed in handling web scraping / downloading directly from websites through Python, and I have no idea how to go about it.

Link to comment
Share on other sites

Link to post
Share on other sites

Not really a complete idea, but I wouldn't bother scraping the text and what not for the repo, its a big mess and I'd say too much work.

 

If you append ".atom" to the end of the Github URLs you care about (ie https://github.com/RPCS3/rpcs3-binaries-win/releases.atom) you get an RSS feed for the releases of that repo.

 

It would then be a case of:

  1. It looks like RPCS3 deletes old releases and stuck all releases up in one block randomly. So use an RSS library to get all the RSS items into a list, and find the highest version entry there. (Ie compare the versions and take the highest)
  2. From there, you can get the link to a download page from the RSS entry. Parse the download link for the tag id (ie https://github.com/RPCS3/rpcs3-binaries-win/releases/tag/build-fb20c27e7b40a5209dc54c340e5daf32df67a82d transformed to fb20c27e).
  3. Use that tag id and the link to get the full download link. A download link is the link from before, followed by "rpcs3-",  the version number, the tag ID you just generated, and finally "_win64.7z". You can see that by just hovering over a download link.
  4. Using the full download link, download and save the file. You can find loads about doing that in python online.

Shouldn't be too hard I don't think. You'd probably want to add in some checks too, like check if you already have a version downloaded by checking what files you have in your download folder etc.

CPU: 6700k GPU: Zotac RTX 2070 S RAM: 16GB 3200MHz  SSD: 2x1TB M.2  Case: DAN Case A4

Link to comment
Share on other sites

Link to post
Share on other sites

44 minutes ago, geo3 said:

Is there a reason you can't just git pull Or am I not understanding what you are trying to do.

There are some programs that I can't build (such as RPCS3 for Windows), that and I don't want to pull an update for every new commit since each commit is probably small anyways. I'd rather pull new releases since the author handles creating the builds, and then I don't have to go through multiple repositories' commit history.

 

Tracking commits/updates and what not is already doable through GitHub natively, I'm trying to specifically get new prebuilt release binaries as they become available.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, HunterAP said:

There are some programs that I can't build (such as RPCS3 for Windows), that and I don't want to pull an update for every new commit since each commit is probably small anyways. I'd rather pull new releases since the author handles creating the builds, and then I don't have to go through multiple repositories' commit history.

 

Tracking commits/updates and what not is already doable through GitHub natively, I'm trying to specifically get new prebuilt release binaries as they become available.

One idea is to use something like this -> https://onwebchange.com/

 

Monitor the releases page on github and you will get notified when a release is posted.  

 

Not very streamline but no code required.  Don't know your setup but if it was me I would just setup a IFTTT applet that sends post request to a php script on the server that will process it and do a git pull to get the latest release.  Of course there are tons of different ways to do this so its really whatever your setup allows and how automated you want to make it

Link to comment
Share on other sites

Link to post
Share on other sites

If you don't have access to the repo to setup a webhook, you can just use Github's API to poll whether or not there is a new release. You can also retrieve the release through their API. Check out the documentation here: https://developer.github.com/v3/repos/releases/

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×