diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2f26a94 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy to Negative Games Nexus (Gradle) + +on: + push: + branches: + - release + - snapshot + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Configure Gradle / Nexus credentials + run: | + mkdir -p ~/.gradle + cat << 'EOF' > ~/.gradle/gradle.properties + nexusUsername=${{ secrets.NEXUS_USERNAME }} + nexusPassword=${{ secrets.NEXUS_PASSWORD }} + nexusSnapshotsUrl=https://repo.negative.games/repository/maven-snapshots + nexusReleasesUrl=https://repo.negative.games/repository/maven-releases + EOF + + # Modify version for release branch (remove -SNAPSHOT) + - name: Modify version for release + if: github.ref == 'refs/heads/release' + run: | + find . -name "build.gradle.kts" -type f -exec sed -i "s/\\(var apiVersion = \\\"[^\\\"]*\\)-SNAPSHOT\\\"/\\1\\\"/" {} + + + # Modify version for snapshot branch (add -SNAPSHOT if not present) + - name: Modify version for snapshot + if: github.ref == 'refs/heads/snapshot' + run: | + find . -name "build.gradle.kts" -type f -exec sed -i "/var apiVersion = \\\".*-SNAPSHOT\\\"/! s/\\(var apiVersion = \\\"[^\\\"]*\\)\\\"/\\1-SNAPSHOT\\\"/" {} + + + # Make gradlew executable + - name: Make gradlew executable + run: chmod +x ./gradlew + + # Deploy to RELEASES on release branch + - name: Build and deploy release + if: github.ref == 'refs/heads/release' + run: ./gradlew clean publish -PisRelease=true + + # Deploy to SNAPSHOTS on snapshot branch + - name: Build and deploy snapshot + if: github.ref == 'refs/heads/snapshot' + run: ./gradlew clean publish -PisRelease=false diff --git a/build.gradle.kts b/build.gradle.kts index 76f114a..1836acd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("java") + id("maven-publish") } subprojects { @@ -23,3 +24,27 @@ subprojects { tasks.withType() { enabled = false } + + +subprojects { + plugins.withId("maven-publish") { + configure { + repositories { + maven { + name = "nexus" + + val snapshotsUrl = findProperty("nexusSnapshotsUrl") as String? ?: "https://repo.negative.games/repository/maven-snapshots" + val releasesUrl = findProperty("nexusReleasesUrl") as String? ?: "https://repo.negative.games/repository/maven-releases" + + val isRelease = (findProperty("isRelease") == "true") + url = uri(if (isRelease) releasesUrl else snapshotsUrl) + + credentials { + username = findProperty("nexusUsername") as String? + password = findProperty("nexusPassword") as String? + } + } + } + } + } +} \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 1ed51f2..5435a1f 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,7 +1,13 @@ plugins { id("java") + id("maven-publish") + id("com.gradleup.shadow") version("9.2.2") } +var id = "plugin-engine-common" +var domain = "games.negative.engine" +var apiVersion = "1.0.0" + repositories { mavenCentral() } @@ -33,4 +39,50 @@ dependencies { // Lombok compileOnly("org.projectlombok:lombok:1.18.32") annotationProcessor("org.projectlombok:lombok:1.18.32") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + +tasks.shadowJar { + archiveBaseName.set(id) + archiveVersion.set(apiVersion) + archiveClassifier.set("") +} + +publishing { + publications { + create("mavenJava") { + artifact(tasks.shadowJar) { + builtBy(tasks.shadowJar) + } + + groupId = domain + artifactId = id + version = apiVersion + + pom { + name.set(id) + description.set(project.description) + url.set("https://github.com/negative-games/plugin-engine") + + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("ericlmao") + name.set("Eric") + } + } + } + } + } } \ No newline at end of file diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index fcdf873..49a3616 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -1,7 +1,13 @@ plugins { id("java") + id("maven-publish") + id("com.gradleup.shadow") version("9.2.2") } +var id = "plugin-engine-paper" +var domain = "games.negative.engine" +var apiVersion = "1.0.0" + repositories { mavenCentral() } @@ -33,4 +39,54 @@ dependencies { // Lombok compileOnly("org.projectlombok:lombok:1.18.32") annotationProcessor("org.projectlombok:lombok:1.18.32") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + +tasks.jar { + enabled = false +} + +tasks.shadowJar { + archiveBaseName.set(id) + archiveVersion.set(apiVersion) + archiveClassifier.set("") +} + +publishing { + publications { + create("mavenJava") { + artifact(tasks.shadowJar) { + builtBy(tasks.shadowJar) + } + + groupId = domain + artifactId = id + version = apiVersion + + pom { + name.set(id) + description.set(project.description) + url.set("https://github.com/negative-games/plugin-engine") + + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("ericlmao") + name.set("Eric") + } + } + } + } + } } \ No newline at end of file