Skip to content

Commit 86173d1

Browse files
authored
Merge pull request #228 from jGleitz/ci/use-pnpm
improved ci setup with pnpm and jreleaser
2 parents 0400b45 + dcea752 commit 86173d1

File tree

8 files changed

+2379
-27
lines changed

8 files changed

+2379
-27
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@ jobs:
4646
steps:
4747
- name: Checkout
4848
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
- name: Setup pnpm
50+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
4951
- name: Setup Node.js
5052
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
5153
with:
52-
node-version: lts/*
54+
node-version-file: .nvmrc
55+
cache: pnpm
56+
- name: Install Dependencies
57+
run: pnpm install --frozen-lockfile
5358
- name: Release Check
5459
env:
5560
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
56-
run: npx semantic-release
61+
run: pnpm release
5762

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
env:
88
ORG_GRADLE_PROJECT_version: ${{ github.event.release.tag_name }}
99
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
10-
GRADLE_OPTS: -Dorg.gradle.configuration-cache=false
1110

1211
jobs:
1312
release:
@@ -30,11 +29,12 @@ jobs:
3029
- name: Release Artefacts
3130
run: ./gradlew release
3231
env:
32+
GRADLE_OPTS: -Dorg.gradle.configuration-cache=false
3333
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PACKAGE_SIGNING_KEY }}
3434
ORG_GRADLE_PROJECT_signingKeyPassword: ${{ secrets.PACKAGE_SIGNING_KEY_PASSWORD }}
3535
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUB_TOKEN }}
36-
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
37-
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
36+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
37+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
3838

3939
docs:
4040
name: Publish Documentation

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ build/
77

88
### Kotlin
99
/.kotlin/
10+
11+
### Node.JS
12+
/node_modules/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v24.11.0

build.gradle.kts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import io.github.gradlenexus.publishplugin.NexusRepository
21
import org.gradle.kotlin.dsl.*
2+
import org.jreleaser.model.Active.ALWAYS
3+
34

45
plugins {
56
kotlin("jvm") version "2.2.21"
67
id("org.jetbrains.dokka-javadoc") version "2.1.0"
78
id("org.jetbrains.dokka") version "2.1.0"
89
`maven-publish`
910
signing
10-
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
11+
id("org.jreleaser") version "1.21.0"
1112
}
1213

1314
group = "de.joshuagleitze"
@@ -52,8 +53,7 @@ tasks.withType<Test>().configureEach {
5253
}
5354
}
5455

55-
val ossrhUsername: String? by project
56-
val ossrhPassword: String? by project
56+
5757
val githubRepository: String? by project
5858
val githubOwner = githubRepository?.split("/")?.get(0)
5959
val githubToken: String? by project
@@ -84,7 +84,7 @@ val dokkaJar by tasks.registering(Jar::class) {
8484

8585
lateinit var publication: MavenPublication
8686
lateinit var githubPackages: ArtifactRepository
87-
lateinit var mavenCentral: NexusRepository
87+
lateinit var mavenCentralStaging: MavenArtifactRepository
8888

8989
publishing {
9090
publications {
@@ -128,6 +128,9 @@ publishing {
128128
}
129129
}
130130
repositories {
131+
mavenCentralStaging = maven(layout.buildDirectory.dir("publish/maven-central-staging")) {
132+
name = "MavenCentralStaging"
133+
}
131134
githubPackages = maven("https://maven.pkg.github.com/$githubRepository") {
132135
name = "GitHubPackages"
133136
credentials {
@@ -138,31 +141,41 @@ publishing {
138141
}
139142
}
140143

141-
nexusPublishing {
142-
repositories {
143-
mavenCentral = sonatype {
144-
username = ossrhUsername
145-
password = ossrhPassword
144+
signing {
145+
useInMemoryPgpKeys(
146+
providers.gradleProperty("signingKey").orNull,
147+
providers.gradleProperty("signingKeyPassword").orNull
148+
)
149+
sign(publication)
150+
}
151+
152+
jreleaser {
153+
deploy {
154+
maven {
155+
mavenCentral {
156+
register("sonatype") {
157+
url = "https://central.sonatype.com/api/v1/publisher"
158+
active = ALWAYS
159+
stagingRepository(mavenCentralStaging.url.toString())
160+
}
161+
}
146162
}
147163
}
148164
}
149165

150-
signing {
151-
val signingKey: String? by project
152-
val signingKeyPassword: String? by project
153-
useInMemoryPgpKeys(signingKey, signingKeyPassword)
154-
sign(publication)
155-
}
166+
val jreleaserConfig by tasks
167+
val jreleaserDeploy by tasks
156168

157-
val closeAndReleaseStagingRepositories by project.tasks
158-
closeAndReleaseStagingRepositories.mustRunAfter(mavenCentral.publishTask)
169+
jreleaserDeploy.mustRunAfter(jreleaserConfig)
170+
jreleaserDeploy.mustRunAfter(mavenCentralStaging.publishTask)
159171

160172
val release by tasks.registering {
161173
group = "release"
162-
description = "Releases the project to Maven Central"
163-
dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepositories)
174+
description = "Releases the project to all repositories"
175+
dependsOn(jreleaserConfig, githubPackages.publishTask, mavenCentralStaging.publishTask, jreleaserDeploy)
164176
}
165177

166178
fun String.drop(prefix: String) = if (this.startsWith(prefix)) this.drop(prefix.length) else this
167179
val ArtifactRepository.publishTask get() = tasks["publishAllPublicationsTo${this.name}Repository"]
168-
val NexusRepository.publishTask get() = "publishTo${this.name.replaceFirstChar { it.titlecase() }}"
180+
fun ProviderFactory.requiredGradleProperty(name: String): Provider<String> = gradleProperty(name)
181+
.orElse(provider { throw InvalidUserDataException("required project property `$name` was not set!")})

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.gradle.parallel=true
2-
org.gradle.configuration-cache=true
2+
org.gradle.configuration-cache=false
33
org.gradle.configuration-cache.parallel=true
44

55
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "string-notation",
3+
"description": "",
4+
"keywords": [],
5+
"author": {
6+
"name": "Joshua Gleitze",
7+
"url": "https://joshuagleitze.de"
8+
},
9+
"license": "MIT",
10+
"scripts": {
11+
"release": "semantic-release"
12+
},
13+
"devDependencies": {
14+
"semantic-release": "25.0.2"
15+
},
16+
"packageManager": "[email protected]+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd"
17+
}

0 commit comments

Comments
 (0)