Automatic mod uploading by mod authors possible?
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Automatic mod uploading by mod authors possible?
I was wondering if anyone has (recently?) tried or succeeded in uploading mods to the portal via the API. In the factorian spirit of "automate everything" i would like to integerate an automatic update function into my build script. But as i'm entirely unfamilar with the portal API and have vague memories of ancient rumors that it's not possible *cough*... i figured i'd try asking. Dev comments are also very welcome ;).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Fast Inserter
- Posts: 128
- Joined: Thu Feb 08, 2018 8:25 am
- Contact:
Re: Automatic mod uploading by mod authors possible?
Yup, got something working. It's what I'd consider brittle - the mod API doesn't have upload endpoints that are designed for programmatic access as far as I know, so the automation has a few hoops to jump through to act like a proper web browser .. and some of those hoops involve grepping the body of HTML responses for CSRF tokens. (I saw this post because I came here to ask about a programmatic endpoint for it where we could auth with a user's account token instead of their password and upload directly instead of emulating the upload form, which would be fantastic)
At the moment there's some outstanding issues that I need to fix like slightly messing up whitespace on the changelog when echoing it back to the upload form, but overall it seems to work.
It's implemented using GitHub Actions to automatically build and release tagged versions, which is a beta feature on GitHub's end; to use it directly you would first need to get the feature turned on for your GitHub account - but the actual automation is just a bash script (see entrypoint.sh) so you should be able to adapt it to your needs.
https://github.com/shanemadden/factorio ... al-publish
The web request process it's taking to complete an upload:
At the moment there's some outstanding issues that I need to fix like slightly messing up whitespace on the changelog when echoing it back to the upload form, but overall it seems to work.
It's implemented using GitHub Actions to automatically build and release tagged versions, which is a beta feature on GitHub's end; to use it directly you would first need to get the feature turned on for your GitHub account - but the actual automation is just a bash script (see entrypoint.sh) so you should be able to adapt it to your needs.
https://github.com/shanemadden/factorio ... al-publish
The web request process it's taking to complete an upload:
- Load the login URL, store the CSRF token and session cookie
- Login using the user, password, and CSRF token, getting a properly authenticated session
- Load the mod info from the mod API, verifying that it's not trying to release a version that exists
- Load the mod download edit form, store the CSRF token for the file upload
- Upload the zip file using the CSRF token
- Post the edit to the downloads to finish the release
Re: Automatic mod uploading by mod authors possible?
It's awesome you've figured out how to do that, but I think it would be niftier to be able to post a notification on release, and have the mod portal pull the zip from github.
Re: Automatic mod uploading by mod authors possible?
I've also been working on creating CI scripts for my mods and have some success with the browser mocking, but the error detection leaves a lot to be desired (e.g. login error detection).
Therefore I would also like to request an API endpoint to upload a mod to the portal one can sue with the tokens from the web authentication API.
Especially with a proper JSON response one can parse to trigger corresponding actions (e.g. version already exists)
Therefore I would also like to request an API endpoint to upload a mod to the portal one can sue with the tokens from the web authentication API.
Especially with a proper JSON response one can parse to trigger corresponding actions (e.g. version already exists)
Re: Automatic mod uploading by mod authors possible?
This would be amazing. We clearly need more automation here
Re: Automatic mod uploading by mod authors possible?
I am in the process of updating my GitHub Action for uploading mods (https://github.com/Roang-zero1/factorio-mod-actions) and this feature would still improve the workflow quite a bit.
So I am giving it a push
So I am giving it a push
Re: Automatic mod uploading by mod authors possible?
Is there any chance of this getting implemented? Currently my GitHub action is broken due to captcha.
I would rather replace it with a robust upload API.
I would rather replace it with a robust upload API.