Skip to content

Commit a7a328b

Browse files
committed
Initial version, with automated publishing workflow.
1 parent b5d7aea commit a7a328b

5 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish snapshot
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and test (on commits and PRs)"]
6+
types: [completed]
7+
branches: [main]
8+
9+
jobs:
10+
publish:
11+
name: Publish snapshot to Sonatype
12+
runs-on: ubuntu-latest
13+
14+
if: >
15+
github.event.workflow_run.conclusion == 'success' &&
16+
github.event.workflow_run.head_branch == 'main' &&
17+
github.repository == 'randomizedtesting/randomizedtesting-jupiter' &&
18+
secrets.NEXUS_USERNAME != '' &&
19+
secrets.NEXUS_PASSWORD != ''
20+
21+
steps:
22+
- uses: carrotsearch/infra-public/.github/actions/prepare-git-clone@master
23+
with:
24+
token: ${{ secrets.GH_ACCESS_TOKEN }}
25+
26+
- uses: carrotsearch/infra-public/.github/actions/prepare-gradle-build@master
27+
with:
28+
jdk-version: '21'
29+
30+
- name: Publish snapshot
31+
run: |
32+
VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}')
33+
if [[ "$VERSION" == *-SNAPSHOT ]]; then
34+
./gradlew publishToSonatype
35+
else
36+
echo "Not a snapshot version ($VERSION), skipping publish."
37+
fi
38+
env:
39+
ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }}
40+
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ for current features, their requirement descriptions and migration from junit4.
1111
See [LICENSE.txt](LICENSE.txt) to make your company's lawyer happy.
1212

1313
See [CHANGES.txt](CHANGES.txt) for API changes and updates.
14+
15+
## Snapshot artifacts and releases
16+
17+
We publish snapshots to sonatype central snapshots repository. [This
18+
document here](https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-snapshot-releases-for-your-project)
19+
explains how to set up your project to download snapshot releases.

build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
plugins {
22
alias(libs.plugins.spotless) apply false
3+
alias(libs.plugins.nexus.publish)
34
}
45

6+
apply from: file('gradle/scripts/publishing-sonatype-central.gradle')
7+
58
allprojects {
69
group = 'com.carrotsearch.randomizedtesting'
710
version = '0.1.0-SNAPSHOT'
811
}
912

13+
nexusPublishing {
14+
repositories {
15+
sonatype {
16+
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
17+
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
18+
username = findProperty("nexusUsername") ?: ""
19+
password = findProperty("nexusPassword") ?: ""
20+
}
21+
}
22+
}
23+
1024
subprojects {
1125
apply plugin: 'java-library'
1226
apply plugin: 'com.diffplug.spotless'

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
assertj = "3.27.7"
33
googleJavaFormat = "1.34.1"
44
junit = "6.0.3"
5+
nexus-publish = "2.0.0"
56
spotless = "8.3.0"
67

78
[libraries]
@@ -12,4 +13,5 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher
1213
junit-platform-testkit = { module = "org.junit.platform:junit-platform-testkit", version.ref = "junit" }
1314

1415
[plugins]
16+
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" }
1517
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
def published = [
2+
":randomizedtesting-jupiter"
3+
]
4+
5+
configure(subprojects.findAll { it.path in published }) {
6+
apply plugin: 'maven-publish'
7+
apply plugin: 'signing'
8+
9+
// Hack: do not generate or publish gradle metadata files.
10+
tasks.withType(GenerateModuleMetadata).configureEach {
11+
enabled = false
12+
}
13+
14+
plugins.withType(JavaPlugin).configureEach {
15+
java {
16+
withSourcesJar()
17+
withJavadocJar()
18+
}
19+
20+
publishing {
21+
def configurePom = {
22+
name = "${project.name}"
23+
description = "${project.name}"
24+
url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter'
25+
inceptionYear = "2026"
26+
27+
licenses {
28+
license {
29+
name = 'ASL 2.0 License'
30+
url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter/blob/main/LICENSE.txt'
31+
}
32+
}
33+
34+
organization {
35+
name = "Carrot Search s.c."
36+
url = "https://www.carrotsearch.com"
37+
}
38+
39+
developers {
40+
developer {
41+
id = 'dawid.weiss'
42+
name = 'Dawid Weiss'
43+
email = 'dawid.weiss@carrotsearch.com'
44+
}
45+
}
46+
scm {
47+
connection = 'scm:git:git@github.com:randomizedtesting/randomizedtesting-jupiter.git'
48+
developerConnection = 'scm:git:git@github.com:randomizedtesting/randomizedtesting-jupiter.git'
49+
url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter'
50+
}
51+
}
52+
53+
publications {
54+
jars(MavenPublication) {
55+
from components.java
56+
groupId = project.group
57+
artifactId = project.base.archivesName.get()
58+
59+
pom(configurePom)
60+
}
61+
}
62+
}
63+
64+
signing {
65+
required = { !project.version.endsWith('-SNAPSHOT') }
66+
sign publishing.publications.jars
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)