Platforms
Forgejo

Basic example

See the following minimal example showing how to publish the remapJar task to Forgejo:

publishMods {
    file = remapJar.archiveFile
    changelog = "Changelog"
    type = STABLE
    modLoaders.add("fabric")
 
    forgejo {
        accessToken = providers.environmentVariable("FORGEJO_TOKEN")
        hostUrl(new URI("https://codeberg.org")) // This is the link for your Forgejo host.
        repository = "Example/MyMod"
        commitish = "main" // This is the branch the release tag will be created from
    }
}
 

Multiple releases

You can create multiple Forgejo destinations by specifying a name like so:

publishMods {
    forgejo("forgejoProjectA") {
        // Configure forgejo settings for project A here
    }
 
    forgejo("forgejoProjectB") {
        // Configure forgejo settings for project B here
    }
}

This will create 2 separate Forgejo releases.

Parent releases

If you wish to upload files to a Forgejo release created by another task either in the same project or another subproject, you can use the parent option. This is useful where you have multiple subprojects that you want to publish to a single release, the following example shows how a root project can create the release and subprojects can upload files to it:

Root project

publishMods {
    forgejo {
        accessToken = providers.environmentVariable("FORGEJO_TOKEN")
        repository = "Example/MyMod"
        commitish = "main"
        tagName = "release/1.0.0"
 
        // Allow the release to be initially created without any files.
        allowEmptyFiles = true
    }
}

Subproject

When using the parent option, only the accessToken and files are required, the other options are forcefully inherited from the parent task.

publishMods {
    forgejo {
        accessToken = providers.environmentVariable("FORGEJO_TOKEN")
 
        // Specify the root project's forgejo task to upload files to
        parent project(":").tasks.named("forgejo")
    }
}

All options

See the following example showing all the Forgejo specific options:

publishMods {
    forgejo {
        accessToken = providers.environmentVariable("FORGEJO_TOKEN")
        hostUrl(new URI("https://forgejo.example.com"))
        repository = "Example/MyMod"
        commitish = "main"
        tagName = "release/1.0.0"
 
        // Optionally set the announcement title used by the discord publisher
        announcementTitle = "Download from Forgejo"
		// Optionally set the display name for your host, which is used by the discord publisher if no custom title is set
		hostDisplayName = "Example"
        // Optionally set the brand color used by your host
        hostBrandColor = 0xff5500
 
        // Upload the files to a previously created release, by providing another forgejo publish task
        // This is useful in multi-project builds where you want to publish multiple subprojects to a single release
        parent tasks.named("publishForgejo")
 
        // Optionally allow the release to be created without any attached files.
        // This is useful when you have subprojects using the parent option that you want to publish a single release.
        allowEmptyFiles = true
    }
}