Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: Java CI with Gradle and JReleaser

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [created]
workflow_call:

jobs:
build:
Expand All @@ -28,13 +23,3 @@ jobs:

- name: Run tests
run: ./gradlew test

- name: Release with JReleaser
if: github.event_name == 'release'
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_NEXUS2_USERNAME: ${{ secrets.OSSRH_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew jreleaserFullRelease
30 changes: 30 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: pipeline.yml
on:
push:
branches: ["main"]
tags:
- "*"
pull_request:
branches: ["main"]
workflow_dispatch:
inputs:
type:
description: 'Release Library'
required: true
default: '...no release'
type: choice
options:
- '...no release'
- major
- minor
- patch

jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
publish_sonatype:
name: Publish artifact (Maven Central)
uses: ./.github/workflows/publish-sonatype.yml
secrets: inherit
needs: build
40 changes: 40 additions & 0 deletions .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: publish-sonatype.yml
on:
workflow_call:

jobs:
publish:
name: gradle publish (Maven Central)
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4

- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- uses: gradle/actions/wrapper-validation@v3

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/[email protected]
with:
cache-read-only: true

- name: Publish SNAPSHOT to Sonatype (Maven Central)
run: ./gradlew publishMavenJavaPublicationToOSSRHRepository
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SECRET_KEY }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
- name: Publish RELEASE to Sonatype (Maven Central)
run: ./gradlew publishMavenJavaPublicationToOSSRHRepository
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SECRET_KEY }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
82 changes: 17 additions & 65 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id 'java-library'
id 'java'
id 'maven-publish'
id 'signing'
id 'org.jreleaser' version '1.3.1'
}

group = 'io.agodadev'
Expand All @@ -23,17 +22,16 @@ repositories {

dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}

test {
useJUnitPlatform()
implementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.12.4'
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from components.java
pom {
name = 'TestMetrics'
Expand All @@ -60,67 +58,21 @@ publishing {
}
}
}
}

signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

jreleaser {
project {
website = 'https://github.com/yourusername/testmetrics'
authors = ['Your Name']
license = 'Apache-2.0'
extraProperties.put('inceptionYear', '2023')
}
release {
github {
owner = 'yourusername'
name = 'testmetrics'
tagName = "v{{projectVersion}}"
releaseName = "{{projectName}} {{projectVersion}}"
changelog {
formatted = "ALWAYS"
format = "- {{commitShortHash}} {{commitTitle}}"
categorize = true
labelers {
label("feature", "Implemented enhancements:", "feat")
label("bug fix", "Fixed bugs:", "fix")
label("documentation", "Improved documentation:", "docs")
label("maintenance", "Other changes:", "chore", "refactor", "test", "build")
}
}
}
}
deploy {
repositories {
maven {
nexus2 {
create("maven-central") {
active = "RELEASE"
url = "https://s01.oss.sonatype.org/service/local"
snapshotUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
closeRepository = true
releaseRepository = true
stagingRepositories = ["build/staging-deploy"]
}
name = "OSSRH"
url = version.endsWith('SNAPSHOT') ?
uri("https://s01.oss.sonatype.org/content/repositories/snapshots") :
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("MAVEN_USERNAME") ?: System.getenv('OSSRH_USERNAME')
password = System.getenv("MAVEN_PASSWORD") ?: System.getenv('OSSRH_PASSWORD')
}
}
}
}

jreleaserConfig {
environments {
env {
properties = [
"ORG_GRADLE_PROJECT_signingKey": project.findProperty("signingKey") ?: "",
"ORG_GRADLE_PROJECT_signingPassword": project.findProperty("signingPassword") ?: "",
"JRELEASER_NEXUS2_USERNAME": project.findProperty("ossrhUsername") ?: "",
"JRELEASER_NEXUS2_PASSWORD": project.findProperty("ossrhPassword") ?: "",
"JRELEASER_GITHUB_TOKEN": project.findProperty("githubToken") ?: ""
]
}
}
signing {
useInMemoryPgpKeys(System.getenv("GPG_PUBLIC_KEY"), System.getenv("GPG_SECRET_KEY"))
sign publishing.publications.mavenJava
}
2 changes: 2 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
signingKey=YOUR_GPG_KEY_ID
signingPassword=YOUR_GPG_PASSWORD
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rootProject.name = 'testmetrics'

include("testmetrics")