go-semantic-release / semantic-release

📦🚀 semantic-release written in Go
https://go-semantic-release.xyz
MIT License
395 stars 43 forks source link

feature request: provide context to plugins #162

Open superewald opened 10 months ago

superewald commented 10 months ago

Providing a context to the plugins would be useful to reduce code duplicates and maintainability of the plugins itself.

motivation

I'm currently writing a hook plugin which automates the distribution of release assets and publishing packages. That requires some information which are currently only available in the root config (which plugins by default have no access to) and initializing clients for github/gitlab myself. This produces alot of "duplicate" code (since the config and providers are initialized by semantic-release before) and is somehow a bit error prone.

(You can take a look into https://github.com/superewald/semantic-release-hooks-distributor for reference, it's not finished but shows clearly why a context would be useful)

proposal

In order to make it easier for plugins to access resources which are already initialized by semantic-release a context should be passed to the plugin. I would suggest the context should provide the following resources to the plugin:

considerations

I would be happy to implement this feature but beforehands I want to know if it would be integrated and need to have the considerations answered.