Skip to content

Instantly share code, notes, and snippets.

@zml2008
Created October 13, 2022 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zml2008/bb7e66004ac66e145c1a81546dafa788 to your computer and use it in GitHub Desktop.
Save zml2008/bb7e66004ac66e145c1a81546dafa788 to your computer and use it in GitHub Desktop.
Automated Plugin Publishing

With the latest release of SpongeGradle, it is now easy to perform automated publishing of Sponge plugins!

Set up

First, create an API key that allows uploading versions:

  1. Navigate to the API key screen from your profile on Ore The profile page header, with the key icon highlighted
  2. Create a new API key with at least the create_version permission The API key selected
  3. Click "Create key", and copy the created key The keys table on Ore, with a red arrow pointing to the created API key

Now, modify your buildscript to apply the Ore plugin. The sponge-plugin-template example contains this setup, or alternatively:

  1. Apply the plugin. At the top of your build.gradle[.kts], add the plugin declaration:
    plugins {
      // [... existing  ...]
      id("org.spongepowered.gradle.ore") version "2.1.0"
      // [... existing ...]
    }
  2. Optionally, add a block to the buildscript reading from a changelog:
    oreDeployment.defaultDeployment {
      if (project.hasProperty("changelog")) {
        versionBody.set(file(project.property("changelog")!!).readText(Charsets.UTF_8))
      }
    }

To put everything all together, you'll need to pass your API key to Gradle. SpongeGradle will read this API key from the oreToken Gradle property, or if that is unset $ORE_TOKEN environment variable by default. To set this for all Gradle builds, add the following line to your ~/.gradle/gradle.properties:

oreToken=<the token created earlier in this tutorial>

You can test authentication by running the ./gradlew orePermissions command. If successful, this task will perform a basic query to the Ore API.

Publish

Now, when you are ready to publish a release, simply run ./gradlew publishToOre to publish your plugin.

Additional logic can be added to upload changelogs, or choose different channels for beta/RC versions -- we hope you'll share any interesting solutions on the forums!

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