Skip to content

Commit e8091fa

Browse files
Maven central release (#72)
For #71 . It is unlikely we will get it working in a single PR though ## References - TODO <!-- References to relevant GitHub issues and pull requests, esp. upstream and downstream changes --> ## Submitter checklist - [x] Recommended: Join [WireMock Slack](https://slack.wiremock.org/) to get any help in `#help-contributing` or a project-specific channel like `#wiremock-java` - [x] Recommended: If you participate in Hacktoberfest 2023, make sure you're [signed up](https://wiremock.org/events/hacktoberfest/) there and in the WireMock form - [x] The PR request is well described and justified, including the body and the references - [x] The PR title represents the desired changelog entry - [x] The repository's code style is followed (see the contributing guide) - [x] Test coverage that demonstrates that the change works as expected - [x] For new features, there's necessary documentation in this pull request or in a subsequent PR to [wiremock.org](https://github.com/wiremock/wiremock.org) <!-- Put an `x` into the [ ] to show you have filled the information. The template comes from https://github.com/wiremock/.github/blob/main/.github/pull_request_template.md You can override it by creating .github/pull_request_template.md in your own repository -->
1 parent 1921cca commit e8091fa

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ jobs:
1919
distribution: 'adopt'
2020
- name: Validate Gradle wrapper
2121
uses: gradle/wrapper-validation-action@v1
22+
23+
- name: Determine new version
24+
id: new_version
25+
run: |
26+
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
27+
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
28+
2229
- name: Publish package
2330
uses: gradle/gradle-build-action@v2
2431
with:
25-
arguments: publish
32+
arguments: -Pversion=${{ steps.new_version.outputs.new_version }} publish
33+
2634
env:
27-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
38+
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
39+
OSSRH_GPG_SECRET_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_PASSWORD }}

build.gradle

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
id 'com.diffplug.spotless' version '6.22.0'
1515
id 'com.palantir.git-version' version '3.0.0'
1616
id 'com.github.johnrengelman.shadow' version '8.1.1'
17+
id 'io.github.gradle-nexus.publish-plugin' version "1.0.0"
1718
}
1819

1920
wrapper {
@@ -39,6 +40,11 @@ configurations {
3940
standaloneOnly
4041
}
4142

43+
java {
44+
withSourcesJar()
45+
withJavadocJar()
46+
}
47+
4248
jar {
4349
archiveBaseName.set("${baseArtifact}")
4450
exclude 'META-INF/services'
@@ -71,10 +77,28 @@ shadowJar {
7177
exclude 'handlebars-*.js'
7278
}
7379

74-
group 'org.wiremock'
80+
group 'org.wiremock.extensions'
7581

7682
version gitVersion()
7783

84+
signing {
85+
// Docs: https://github.com/wiremock/community/blob/main/infra/maven-central.md
86+
required {
87+
!version.toString().contains("SNAPSHOT") && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("publish"))
88+
}
89+
def signingKey = providers
90+
.environmentVariable("OSSRH_GPG_SECRET_KEY")
91+
.forUseAtConfigurationTime()
92+
def signingPassphrase = providers
93+
.environmentVariable("OSSRH_GPG_SECRET_KEY_PASSWORD")
94+
.forUseAtConfigurationTime()
95+
if (signingKey.present && signingPassphrase.present) {
96+
useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get())
97+
def extension = extensions.getByName("publishing") as PublishingExtension
98+
sign(extension.publications)
99+
}
100+
}
101+
78102
publishing {
79103
repositories {
80104
maven {
@@ -213,3 +237,23 @@ idea {
213237
}
214238
}
215239

240+
nexusPublishing {
241+
// See https://github.com/wiremock/community/blob/main/infra/maven-central.md
242+
repositories {
243+
sonatype {
244+
nexusUrl = uri("https://oss.sonatype.org/service/local/")
245+
snapshotRepositoryUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
246+
247+
def ossrhUsername = providers
248+
.environmentVariable("OSSRH_USERNAME")
249+
.forUseAtConfigurationTime()
250+
def ossrhPassword = providers
251+
.environmentVariable("OSSRH_TOKEN")
252+
.forUseAtConfigurationTime()
253+
if (ossrhUsername.present && ossrhPassword.present) {
254+
username = ossrhUsername.get()
255+
password = ossrhPassword.get()
256+
}
257+
}
258+
}
259+
}

0 commit comments

Comments
 (0)