⁨zml⁩ avatar
zml

Ore Publishing

Plugin publishing with the new org.spongepowered.gradle.ore plugin

public ⁨1⁩ ⁨file⁩ 2022-10-16 03:14:59 UTC

ore-publication.md

Raw

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.1"
      // [... 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 org.spongepowered.ore.apiToken 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:

org.spongepowered.ore.apiToken=<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!

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](https://cdn.stellardrift.ca/ss/2022/10/PRj7bIYPQT.png)
2.  Create a new API key with at least the `create_version` permission
    ![The API key selected](https://cdn.stellardrift.ca/ss/2022/10/79XZiQ7WEB.png)
3. Click "Create key", and copy the created key
   ![The keys table on Ore, with a red arrow pointing to the created API key](https://cdn.stellardrift.ca/ss/2022/10/bCPLhLWZRr.png)


Now, modify your buildscript to apply the Ore plugin. The [sponge-plugin-template](https://github.com/SpongePowered/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:
   ```kotlin
   plugins {
     // [... existing  ...]
     id("org.spongepowered.gradle.ore") version "2.1.1"
     // [... existing ...]
   }
   ```
2. Optionally, add a block to the buildscript reading from a changelog:
   ```kotlin
   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 `org.spongepowered.ore.apiToken` 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`:

```properties
org.spongepowered.ore.apiToken=<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!