version_bump/plugins/forgejo
The Forgejo publish plugin (Codeberg and self-hosted Forgejo instances).
The Forgejo counterpart of the github plugin: authenticate with a
Forgejo token, resolve the target repository and instance, and create a
Forgejo release for the version semantic-release just determined. Forgejo
runs Codeberg, so plugins = [..., "forgejo"] with a
https://codeberg.org/... repository URL is the common setup.
Hooks implemented:
- verify_conditions: a
FORGEJO_TOKEN/GITEA_TOKENand a resolvable repository URL must be present, otherwise the pipeline aborts. - publish: create the Forgejo release and return it.
- success: log that the release was published.
Unlike GitHub, Forgejo is self-hostable, so the API base URL is derived
from the repository URL’s host — overridable with the url plugin option
or the FORGEJO_URL/GITEA_URL environment variables (useful when the git
remote host differs from the API host, e.g. an SSH alias or a custom port).
Effectful work (HTTP, environment access) is kept in the hook bodies; the
pure decision logic lives in helpers (resolve_token, resolve_api_base,
is_prerelease, verify) so it can be unit-tested without a network or
live environment.
Values
pub fn is_prerelease(next_release: release.NextRelease) -> Bool
Whether the upcoming release is a prerelease (i.e. its channel-tied version
carries a prerelease identifier such as -beta.1).
pub fn resolve_api_base(
explicit: option.Option(String),
host: String,
) -> String
The base URL of the Forgejo instance the release is created on.
PURE: an explicit override (the url plugin option or the
FORGEJO_URL/GITEA_URL environment variables) wins; otherwise the host
from the repository URL is assumed to serve the API over https.
pub fn verify(
token: option.Option(String),
config: config.Config,
) -> Result(Nil, error.ReleaseError)
PURE verification: given a resolved token (if any) and the config, decide whether the Forgejo plugin can run. Separated out so it can be tested without touching the process environment.