diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..ea52b0c --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,32 @@ +name: Publish Plugin Release +on: + workflow_dispatch: {} + release: + types: [published] + +permissions: + contents: write + +jobs: + publish-maven-central: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Validate Gradle + uses: gradle/actions/wrapper-validation@v4 + + - name: Change Wrapper Permissions + run: chmod +x ./gradlew + + - name: Publish Plugin Release + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew publish closeAndReleaseStagingRepositories \ No newline at end of file diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..2fe8f71 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,17 @@ +name: Generate Release PR + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..3d2ac0b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} \ No newline at end of file diff --git a/README.md b/README.md index c0c6692..7043dbf 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ under the hood. If you attempt to place the plugin in your typical `build.gradle ```kotlin // settings.gradle.kts plugins { - id("xyz.atrius.compositor") version "<>" + id("xyz.atrius.compositor") version "0.1.0" } ``` @@ -59,7 +59,7 @@ plugins { ```groovy // settings.gradle plugins { - id 'xyz.atrius.compositor' version "<>" + id 'xyz.atrius.compositor' version '0.1.0' } ``` diff --git a/build.gradle.kts b/build.gradle.kts index f913659..5b8c7e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,12 +2,13 @@ plugins { `java-gradle-plugin` `maven-publish` + signing kotlin("jvm") version "2.2.0" id("io.kotest.multiplatform") version "5.9.1" + id("io.github.gradle-nexus.publish-plugin") version "2.0.0" } group = "xyz.atrius" -version = "0.1.0" repositories { mavenCentral() @@ -32,6 +33,9 @@ kotlin { } gradlePlugin { + // Since we provide two plugins together that we want deployed as a single plugin, we should disable this to avoid + // publishing either of them separately when running through deployment pipelines. + isAutomatedPublishing = false plugins { // This is the main plugin. Unlike others, it needs to be applied under the settings.gradle file. @@ -50,4 +54,65 @@ gradlePlugin { implementationClass = "$group.CompositorProjectAuto" } } +} + +publishing { + // Maven Central repository configuration + repositories { + maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + name = "MavenCentral" + + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } + } + } + // Both plugins should be deployed as a single artifact to ensure they can be setup automatically + publications { + + val projectWebsite: String by project + val license: String by project + val licenseLink: String by project + + create("Compositor") { + from(components["java"]) + + groupId = group.toString() + artifactId = rootProject.name + version = property("version") as String + + pom { + name = rootProject.name + url = projectWebsite + + licenses { + license { + name = license + url = licenseLink + } + } + } + } + } +} +// Maven Central requires artifacts to be signed for upload +signing { + val signingKey = System.getenv("SINGING_KEY") + val signingPassword = System.getenv("SIGNING_PASSWORD") + + if (!signingKey.isNullOrEmpty()) { + useInMemoryPgpKeys(signingKey, signingPassword) + sign(publishing.publications) + } +} +// Maven Central apparently requires staging repositories to be closed before a release can be published +// This should configure the plugin which will automate this process in the deployment pipeline +nexusPublishing { + repositories { + sonatype { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7fc6f1f..63bd1f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,5 @@ kotlin.code.style=official +projectWebsite=https://github.com/AtriusX/Compositor +license=MIT License +licenseLink=https://github.com/AtriusX/Compositor/blob/main/LICENSE +version=0.1.0 diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..deb309d --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,23 @@ +{ + "packages": { + ".": { + "release-type": "go", + "extra-files": [ + { + "type": "generic", + "path": "README.md", + "regex": "id\\(\"xyz.atrius.compositor\"\\) version \"(?.*)\"" + }, + { + "type": "generic", + "path": "README.md", + "regex": "id 'xyz.atrius.compositor' version '(?.*)'" + }, + { + "type": "gradle-properties", + "path": "gradle.properties" + } + ] + } + } +} \ No newline at end of file