Feature Update checking & downloading

Rinn

Developer
This is for my own tracking, but it's trivial to get the latest release from the GitHub api, so I should be able to add an auto update check on mafia startup like the point releases were doing. I was thinking probably be best to put this behind a global property, but it would also be cool if there was like an --update flag to automatically download the latest release on the command line so all these custom auto-updaters wouldn't be necessary.

Code:
$curl --silent 'https://api.github.com/repos/kolmafia/kolmafia/releases/latest' | jq
{
  "url": "https://api.github.com/repos/kolmafia/kolmafia/releases/50413795",
  "assets_url": "https://api.github.com/repos/kolmafia/kolmafia/releases/50413795/assets",
  "upload_url": "https://uploads.github.com/repos/kolmafia/kolmafia/releases/50413795/assets{?name,label}",
  "html_url": "https://github.com/kolmafia/kolmafia/releases/tag/r25709",
  "id": 50413795,
  "author": {
    "login": "github-actions[bot]",
    "id": 41898282,
    "node_id": "MDM6Qm90NDE4OTgyODI=",
    "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/github-actions%5Bbot%5D",
    "html_url": "https://github.com/apps/github-actions",
    "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
    "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
    "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
    "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
    "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
    "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
    "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
    "type": "Bot",
    "site_admin": false
  },
  "node_id": "RE_kwDOFIi9Vc4DAUDj",
  "tag_name": "r25709",
  "target_commitish": "main",
  "name": "25709",
  "draft": false,
  "prerelease": false,
  "created_at": "2021-09-28T17:07:46Z",
  "published_at": "2021-09-28T17:09:30Z",
  "assets": [
    {
      "url": "https://api.github.com/repos/kolmafia/kolmafia/releases/assets/45798440",
      "id": 45798440,
      "node_id": "RA_kwDOFIi9Vc4CutQo",
      "name": "KoLmafia-25709.jar",
      "label": "",
      "uploader": {
        "login": "github-actions[bot]",
        "id": 41898282,
        "node_id": "MDM6Qm90NDE4OTgyODI=",
        "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/github-actions%5Bbot%5D",
        "html_url": "https://github.com/apps/github-actions",
        "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
        "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
        "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
        "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
        "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
        "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
        "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
        "type": "Bot",
        "site_admin": false
      },
      "content_type": "application/java-archive",
      "state": "uploaded",
      "size": 20748806,
      "download_count": 1,
      "created_at": "2021-09-28T17:09:31Z",
      "updated_at": "2021-09-28T17:09:31Z",
      "browser_download_url": "https://github.com/kolmafia/kolmafia/releases/download/r25709/KoLmafia-25709.jar"
    }
  ],
  "tarball_url": "https://api.github.com/repos/kolmafia/kolmafia/tarball/r25709",
  "zipball_url": "https://api.github.com/repos/kolmafia/kolmafia/zipball/r25709",
  "body": ""
}
$ curl --silent 'https://api.github.com/repos/kolmafia/kolmafia/releases/latest' | jq '.name'
"25709"
$ curl --silent 'https://api.github.com/repos/kolmafia/kolmafia/releases/latest' | jq '.assets[0].browser_download_url'
"https://github.com/kolmafia/kolmafia/releases/download/r25709/KoLmafia-25709.jar"
 

fronobulax

Developer
Staff member
I build my own jars. At some point in the distant past I was playing with someone else's tool to check for a newer jar and fetch. It was not smart enough to realize that r12345M was newer than r12344 and kept trying to download. Perhaps something to watch out for.

Since I am willing to build daily I await the gradle task that will also pull source but that has no relevance to this.
 

MCroft

Developer
Staff member
Might be nice to get and display the commit messages between the two versions. Some PRs I don't care if I get today or tomorrow
 
Top