Skip to content

Commit

Permalink
Prep for making maven central releases
Browse files Browse the repository at this point in the history
  • Loading branch information
compscidr committed Aug 8, 2024
1 parent b58f031 commit 7e3434f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Deploy

on:
push:
# Pattern matched against refs/tags
tags:
- '*' # Push events to every tag not containing /

jobs:
build:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- run: echo "Build status report=${{ job.status }}."
- name: Deploy to Sonatype / Maven Central
# see signing variable names here: https://github.com/vanniktech/gradle-maven-publish-plugin/blob/da599468864f7be7f0c694f174baa797ba8bf189/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt#L229
run: ./gradlew -PcentralPortalToken='${{ secrets.CENTRAL_PORTAL_TOKEN }}' -PcentralPortalPassword='${{ secrets.CENTRAL_PORTAL_PASSWORD }}' -PsigningInMemoryKeyId='${{ secrets.SIGNING_KEY_ID }}' -PsigningInMemoryKeyPassword='${{ secrets.SIGNING_KEY_PASSWORD }}' -PsigningInMemoryKey='${{ secrets.SIGNING_KEY_IN_MEMORY }}' publishAllPublicationsToCentralPortal
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
test = ["junit-jupiter-api", "mockk"]

[plugins]
git-version = { id = "me.qoomon.git-versioning", version = "6.4.3" }
jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
sonatype-maven-central = { id = "com.vanniktech.maven.publish", version = "0.28.0" }
gradleup-nmcp = { id = "com.gradleup.nmcp", version = "0.0.9"}
55 changes: 55 additions & 0 deletions packetdumper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ plugins {
alias(libs.plugins.jetbrains.kotlin.jvm)
alias(libs.plugins.kotlinter)
id("jacoco")
alias(libs.plugins.git.version) // https://stackoverflow.com/a/71212144
alias(libs.plugins.sonatype.maven.central)
alias(libs.plugins.gradleup.nmcp)
}

java {
Expand Down Expand Up @@ -36,3 +39,55 @@ dependencies {
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(libs.logback.classic)
}

version = "0.0.0-SNAPSHOT"
gitVersioning.apply {
refs {
branch(".+") { version = "\${ref}-SNAPSHOT" }
tag("v(?<version>.*)") { version = "\${ref.version}" }
}
}

// see: https://github.com/vanniktech/gradle-maven-publish-plugin/issues/747#issuecomment-2066762725
// and: https://github.com/GradleUp/nmcp
nmcp {
val props = project.properties
publishAllPublications {
username = props["centralPortalToken"] as String? ?: ""
password = props["centralPortalPassword"] as String? ?: ""
// or if you want to publish automatically
publicationType = "AUTOMATIC"
}
}

// see: https://vanniktech.github.io/gradle-maven-publish-plugin/central/#configuring-the-pom
mavenPublishing {
coordinates("com.jasonernst.packetdumper", "packetdumper", version.toString())
pom {
name = "PacketDumper"
description = "A kotlin / android compatible buffer / packet dumper."
inceptionYear = "2024"
url = "https://github.com/compscidr/packetdumper"
licenses {
license {
name = "GPL-3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
distribution = "repo"
}
}
developers {
developer {
id = "compscidr"
name = "Jason Ernst"
url = "https://www.jasonernst.com"
}
}
scm {
url = "https://github.com/compscidr/packetdumper"
connection = "scm:git:git://github.com/compscidr/packetdumper.git"
developerConnection = "scm:git:ssh://[email protected]/compscidr/packetdumper.git"
}
}

signAllPublications()
}

0 comments on commit 7e3434f

Please sign in to comment.