Enhancement Request: Use GitHub as addon codebase, with AnkiWeb addon page copying that GitHub data

I’ve been working on some addons for Anki, and I host the code on GitHub. Publishing the addon to AnkiWeb involves basically copying over all the information I have in the README on the GitHub addon page, and then copying over the files I have in the GitHub repository. Making changes to the addon involves repeating all that process. The only unique action I’m taking on the upload addon page is specifying the versions.

It would be very nice if I could create a GitHub repository for my addon and maintain the code there, and uploading the addon to AnkiWeb would just involve providing the link to that GitHub page.

In this proposed solution, an addon developer would maintain their addon repository on GitHub, and would simply link the repo with the addon page on AnkiWeb. Updating the addon would just be specifying which revisions should be considered “released” in the repository via a template file. Anki users who are navigating the addons page would still see the information, but it would just be pulled from GitHub instead of using the information that would have otherwise been copied over into AnkiWeb during the addon process. Downloading the addon would be, instead of pulling from AnkiWeb’s code, pulling the code from GitHub through the specified “released” version from the aforementioned template file.

Overall, what I’m imagining is a template GitHub repository that developers can clone, containing:

  • src folder, where they put the code that will be pulled when downloading or updating addons
  • README file, which is what is shown to users on AnkiWeb
  • file that specifies the revisions that are “released” to users
  • file that specifies which versions of Anki the addon supports
    AnkiWeb addon uploading would involve specifying a link to the GitHub repo.

Downloading the addon would work the same:

  • A user navigates to an addon page on AnkiWeb, which appears the same to them as before. On that page:
    • Existing addon pages continue to work as before
    • GitHub addons: display information from GitHub through the specified revision for the README.
  • Downloading the addon: behind the scenes, AnkiWeb pulls the code through the specified revision from GitHub and sends it over to the Anki client that’s requesting it.

Pros:

  • MUCH easier maintenance and uploading for addons. Only have to maintain the GitHub repo.
  • Versioning for addons, where a developer can release versions of the addon that correspond to different anki versions
  • No change for Anki users.

Cons:

  • Requires a sizable update to AnkiWeb
2 Likes

I like this! I do have some nifty code on some of my repos that a couple devs helped with that auto creates releases and auto uploads to ankiweb. I can’t remember which repos off the top of my head. I think “Field Autocomplete” is one of them

Interesting - I think there’s a way to combine our two thoughts on this to arrive at a more lightweight solution. An official AnkiWeb API could be developed and released alongside an official Anki addon GitHub template repository (to be cloned by addon developers) that calls that API as part of a post-commit or pre-push hook. The hook would accomplish the things I outlined above - checking the revisions in the repo and comparing it to the specified “released” revision head, and sending the corresponding version of the addon source and README to AnkiWeb via the official API. Assuming that such an API and call from a suitable hook is possible, that would probably be much easier than making extensive changes to AnkiWeb. The API would need authentication of some kind (with AnkiWeb credentials stored outside the repository) to ensure that only the addon developer can modify the source that’s uploaded to AnkiWeb.

1 Like

An API to upload add-ons may come in the future. Directly pulling from git repos is unlikely to happen - it adds a whole bunch of extra complexity, and forces developers to use git even if it’s not their preferred VCS.

2 Likes