Skip to content

Conversation

@AleksLitynski
Copy link

This adds support for installing plugins from .zip files hosted on the web.

This command would now work: plug("https://github.com/TokisanGames/Terrain3D/releases/download/v1.0.0-stable/terrain3D-1.0.0-stable-godot4.3.zip")

I noticed a lot of godot plugins are distributed as .zip files on github release pages, especially if they include compiled binaries. I figure it might be useful to let people install plugins that way.

I doubt this is of acceptable quality to merge, but I figured I would share my work in case it's interesting to you.

Other notes:

  • The download_zip function shells out to curl to download the zip file. Then it uses godot's builtin ZipReader to decompress.
  • download_zip was added to the _GitExecutable class. That's kind of weird, but _GitExecutable already had all the methods needed to shell out to an external command, so I just piggybacked off of it. Could maybe rename _GitExecutable to _ExternalExecutable or something.

There's also an unrelated change in here. I added a new field to plugins called on_updated_callable which works exactly like on_updated, but takes a callable instead of a string. Happy to back that out if it's weird to have both changes in the same PR.

- added support for installing plugins from zip files
@imjp94
Copy link
Owner

imjp94 commented May 17, 2025

Cool!
I always thought this feature should be implemented with Github API, now it just seem completely unnecessary.

I have only tested the example provided and godot-jolt, but they both works well without any problem.

Some suggestions:

  • Regarding the _ExternalExecutable, if you don't mind, can you help me to implement it and makes _GitExecutable inherits from it? The purpose of _GitExecutable is to provide convenient API to interact with git repo, like fetch, pull, clone, etc.
  • Rename on_updated_callable to updated.

Other than that, I think this PR is quite stable and ready to merge after cleaning the code.
Great job!

@goatchurchprime
Copy link

This needs a bit more work. The links in the assetlib generally contain an extra outer directory that needs to be trimmed off. And some of them need to have the addons directory name put back into them so they don't copy over to the top level of the project.

One such important core module is the WebRTC code:

plug("https://github.com/godotengine/webrtc-native/releases/download/1.0.6-stable/godot-extension-4.1-webrtc.zip", { "branch":"addons/webrtc"})

Not very happy with this hack to make it work, and I misused the branch value to set the extra directory levels of ldir, but I'm in a hurry.

var files = reader.get_files()
for file_path in files:
	var zip_file_path = file_path
	file_path = file_path.split("/", true, 1)[1]
	if ldir:
		file_path = ldir+"/"+file_path
	if file_path.ends_with("/"):
		root_dir.make_dir_recursive(file_path)
		continue
	root_dir.make_dir_recursive(root_dir.get_current_dir().path_join(file_path).get_base_dir())
	var file = FileAccess.open(root_dir.get_current_dir().path_join(file_path), FileAccess.WRITE)
	var buffer = reader.read_file(zip_file_path)
	file.store_buffer(buffer)

Maybe this would better be done in the install phase rather than the unpack phase, and I don't know how we're going to handle new versions that are just different zip file urls without any context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants