Skip to content

Commit

Permalink
Utilize gradle nexus publish plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
nightm4re94 committed Mar 15, 2023
1 parent 83de67d commit 735d30c
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 103 deletions.
66 changes: 41 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
name: Release LITIENGINE

on:
workflow_dispatch
workflow_dispatch:
inputs:
incrementVersion:
type: choice
description: "increment version?"
required: true
default: 'none'
options:
- none
- patch
- minor
- major
schedule:
# Midnight every day
- cron: "0 0 * * *"

jobs:
gradle:
Expand All @@ -13,36 +27,38 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
fetch-depth: 0
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 19

- name: Prepare & publish release
- name: Print project version
uses: gradle/gradle-build-action@v2
with:
arguments: printGitSemVer
- name: Increment patch version
if: inputs.incrementVersion == 'patch'
uses: gradle/gradle-build-action@v2
with:
arguments: incrementPatchVersion
- name: Increment minor version
if: inputs.incrementVersion == 'minor'
uses: gradle/gradle-build-action@v2
with:
arguments: incrementMinorVersion
- name: Increment major version
if: inputs.incrementVersion == 'major'
uses: gradle/gradle-build-action@v2
with:
arguments: incrementMajorVersion
- name: Publish
uses: gradle/gradle-build-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
NEXUS_USERNAME: ${{ secrets.OSSRH_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSPHRASE }}
with:
arguments: |
prepareVote
publishRelease
--info
-x test
-Prc=1
-Pgh
-Prelease=true
-PskipJavadoc
-PskipSpotless
-PghGitSourceUsername=gurkenlabs
-PghGitSourcePassword=$GITHUB_TOKEN
-PghNexusUsername=$NEXUS_USERNAME
-PghNexusPassword=$NEXUS_PASSWORD
-PuseInMemoryKey=true
-Psigning.inMemoryKey=$GPG_SIGNING_KEY
-Psigning.password=$GPG_PASSPHRASE
publishToSonatype closeSonatypeStagingRepository
55 changes: 0 additions & 55 deletions .github/workflows/snapshot.yml

This file was deleted.

16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
plugins {
id "java"
alias libs.plugins.spotless
alias libs.plugins.versions
alias libs.plugins.dependencyCheck
alias libs.plugins.grgit
alias libs.plugins.semanticVersioning
id "java"
alias libs.plugins.nexusPublish
}

apply from: "$rootDir/gradle/licensing.gradle"
apply from: "$rootDir/gradle/versioning.gradle"

subprojects {
project.version = rootProject.version
}

group = gurkenlabs_group

nexusPublishing {
useStaging.set(!isSnapshotVersion())
repositories {
sonatype {
username = project.findProperty('sonatypeUsername') ?: project.findProperty('OSSRH_USERNAME') ?: ''
password = project.findProperty('sonatypePassword') ?: project.findProperty('OSSRH_PASSWORD') ?: ''
}
}
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ junit = ["junit-api", "junit-params", "junit-engine"]

[plugins]
beryxRuntime = "org.beryx.runtime:1.13.0"
nexusPublish = "io.github.gradle-nexus.publish-plugin:1.3.0"
sonarQube = "org.sonarqube:4.0.0.2929"
spotless = "com.diffplug.spotless:6.17.0"
versions = "com.github.ben-manes.versions:0.46.0"
Expand Down
34 changes: 18 additions & 16 deletions gradle/licensing.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
ext.LITIENGINE_artifact = "litiengine"
ext.LITIENGINE_name = "LITIENGINE"
ext.LITIENGINE_description = "The FOSS 2D Java game engine."
ext.LITIENGINE_url = "https://litiengine.com/"
ext.LITIENGINE_scm_url = "https://github.com/gurkenlabs/litiengine"
ext.LITIENGINE_scm_con = "scm:https://github.com/gurkenlabs/litiengine.git"
ext.LITIENGINE_scm_devCon = "scm:[email protected]:gurkenlabs/litiengine.git"

ext.MIT_name = "MIT"
ext.MIT_url = "https://mit-license.org/"

ext.utiLITI_artifact = "utiliti"
ext.utiLITI_name = "utiLITI"
ext.utiLITI_description = "$utiLITI_name is the official project / asset manager and map editor for $LITIENGINE_name."

ext.gurkenlabs_group = "de.gurkenlabs"
ext.gurkenlabs_name = "gurkenlabs"
ext.gurkenlabs_description = "Two Bavarian brothers, one goal: Create the purest, most comprehensible Java 2D game engine out there."
ext.gurkenlabs_url = "https://gurkenlabs.de/"
ext.copyright = "2014-${Calendar.getInstance().get(Calendar.YEAR)} $gurkenlabs_name"

tasks.register("createLicenseProperties") {
dependsOn processResources
doLast {
new File("$buildDir/resources/main/licensing.properties").withWriter { w ->
Properties p = new Properties()
p['copyright'] = copyright.toString()
p['website'] = gurkenlabs_url
p['version'] = version
p.store w, null
}
}
}
classes {
dependsOn createLicenseProperties
}

ext.steffen_id = "sQn"
ext.steffen_mail = "[email protected]"
ext.steffen_name = "Steffen Wilke"
ext.matthias_id = "nightm4re"
ext.matthias_mail = "[email protected]"
ext.matthias_name = "Matthias Wilke"
55 changes: 55 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apply plugin: "maven-publish"
apply plugin: "signing"

java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = gurkenlabs_group
artifactId = LITIENGINE_artifact
version = project.version
from components.java
pom {
name.set(LITIENGINE_name)
description.set(LITIENGINE_description)
url.set(LITIENGINE_url)
licenses {
license {
name.set(MIT_name)
url.set(MIT_url)
}
}
developers {
developer {
id.set(steffen_id)
name.set(steffen_name)
email.set(steffen_mail)
}
developer {
id.set(matthias_id)
name.set(matthias_name)
email.set(matthias_mail)
}
}
scm {
connection.set(LITIENGINE_scm_con)
developerConnection.set(LITIENGINE_scm_devCon)
url.set(LITIENGINE_scm_url)
}
}
}
}
}

signing {
if (project.hasProperty("signingKey")) {
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
} else {
useGpgCmd()
}
sign(publishing.publications.mavenJava)
}
2 changes: 1 addition & 1 deletion gradle/versioning.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def getLatestTag() {
getSortedGitTags().last().name
}

def isSnapshotVersion() {
ext.isSnapshotVersion = { ->
project.version.toString().contains("dev") || project.version.toString().contains("noTag")
}

Expand Down
5 changes: 2 additions & 3 deletions litiengine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
id "java-library"
id "signing"
id "maven-publish"
alias libs.plugins.sonarQube
}

Expand All @@ -15,5 +13,6 @@ dependencies {
}

apply from: "$rootDir/gradle/encoding.gradle"
apply from: "$rootDir/gradle/testing.gradle"
apply from: "$rootDir/gradle/publishing.gradle"
apply from: "$rootDir/gradle/sonarqube.gradle"
apply from: "$rootDir/gradle/testing.gradle"
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pluginManagement {
repositories {
gradlePluginPortal()
Expand Down
17 changes: 16 additions & 1 deletion utiliti/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
}

apply from: "$rootDir/gradle/encoding.gradle"
apply from: "$rootDir/gradle/licensing.gradle"
apply from: "$rootDir/gradle/testing.gradle"

sourceSets {
Expand Down Expand Up @@ -65,3 +64,19 @@ runtime {
}
}
}

tasks.register("createLicenseProperties") {
dependsOn processResources
doLast {
new File("$buildDir/resources/main/licensing.properties").withWriter { w ->
Properties p = new Properties()
p['copyright'] = copyright.toString()
p['website'] = gurkenlabs_url
p['version'] = version
p.store w, null
}
}
}
classes {
dependsOn createLicenseProperties
}

0 comments on commit 735d30c

Please sign in to comment.