Skip to content

Commit 2b9b2ec

Browse files
Merge pull request #77 from wiremock/maven-central-releases
Add Maven Central release configuration
2 parents a780a64 + cd4f647 commit 2b9b2ec

File tree

2 files changed

+107
-7
lines changed

2 files changed

+107
-7
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24+
- name: Configure Git user
25+
run: |
26+
git config user.email "actions@github.com"
27+
git config user.name "GitHub Actions"
28+
2429
- name: Setup Java
2530
uses: actions/setup-java@v3
2631
with:
@@ -29,20 +34,29 @@ jobs:
2934
distribution: 'temurin'
3035
cache: maven
3136

32-
- name: Configure Git user
33-
run: |
34-
git config user.email "actions@github.com"
35-
git config user.name "GitHub Actions"
36-
3737
- name: Set Release Version
3838
id: vars
3939
shell: bash
4040
run: |
4141
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
42-
mvn -ntp -B versions:set -DnewVersion=${{ github.event.inputs.version }}-SNAPSHOT
42+
mvn -ntp --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }}
4343
git diff-index --quiet HEAD || git commit -m "Releasing version ${{ github.event.inputs.version }}" pom.xml
4444
4545
- name: Publish to GitHub Packages
46-
run: mvn -ntp -B release:prepare release:perform
46+
run: mvn -ntp --batch-mode clean deploy -Prelease
4747
env:
4848
GITHUB_TOKEN: ${{ github.token }}
49+
50+
- name: Set up Java for publishing to Maven Central
51+
uses: actions/setup-java@v3
52+
with:
53+
java-version: '11'
54+
distribution: 'temurin'
55+
server-id: ossrh
56+
server-username: MAVEN_USERNAME
57+
server-password: MAVEN_PASSWORD
58+
- name: Publish to the Maven Central
59+
run: mvn --batch-mode deploy -Prelease,mavencentral-release
60+
env:
61+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
62+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

pom.xml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,90 @@
213213
<url>https://maven.pkg.github.com/wiremock/wiremock-testcontainers-java</url>
214214
</repository>
215215
</distributionManagement>
216+
217+
<profiles>
218+
<profile>
219+
<id>release</id>
220+
<properties>
221+
<version.maven-release-plugin>3.0.0-M7</version.maven-release-plugin>
222+
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
223+
</properties>
224+
<build>
225+
<pluginManagement>
226+
<plugins>
227+
<plugin>
228+
<artifactId>maven-release-plugin</artifactId>
229+
<version>${version.maven-release-plugin}</version>
230+
<configuration>
231+
<tagNameFormat>@{project.version}</tagNameFormat>
232+
</configuration>
233+
</plugin>
234+
<!-- The key's name & passphrase are configured via GitHub's setup-java action. -->
235+
<plugin>
236+
<artifactId>maven-gpg-plugin</artifactId>
237+
<version>${version.maven-gpg-plugin}</version>
238+
<executions>
239+
<execution>
240+
<id>sign-artifacts</id>
241+
<phase>verify</phase>
242+
<goals>
243+
<goal>sign</goal>
244+
</goals>
245+
<configuration>
246+
<!-- This is required to make sure the plugin does not stop asking for -->
247+
<!-- user input on the passphrase -->
248+
<gpgArguments>
249+
<arg>--pinentry-mode</arg>
250+
<arg>loopback</arg>
251+
</gpgArguments>
252+
</configuration>
253+
</execution>
254+
</executions>
255+
</plugin>
256+
</plugins>
257+
</pluginManagement>
258+
<plugins>
259+
<plugin>
260+
<artifactId>maven-gpg-plugin</artifactId>
261+
</plugin>
262+
</plugins>
263+
</build>
264+
</profile>
265+
<profile>
266+
<id>mavencentral-release</id>
267+
<properties>
268+
<version.nexus-staging-maven-plugin>1.6.13</version.nexus-staging-maven-plugin>
269+
</properties>
270+
<distributionManagement>
271+
<repository>
272+
<id>ossrh</id>
273+
<name>Central Repository OSSRH</name>
274+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
275+
</repository>
276+
</distributionManagement>
277+
<build>
278+
<pluginManagement>
279+
<plugins>
280+
<plugin>
281+
<groupId>org.sonatype.plugins</groupId>
282+
<artifactId>nexus-staging-maven-plugin</artifactId>
283+
<version>${version.nexus-staging-maven-plugin}</version>
284+
<extensions>true</extensions>
285+
<configuration>
286+
<serverId>ossrh</serverId>
287+
<nexusUrl>https://s01.oss.sonatype.org</nexusUrl>
288+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
289+
</configuration>
290+
</plugin>
291+
</plugins>
292+
</pluginManagement>
293+
<plugins>
294+
<plugin>
295+
<groupId>org.sonatype.plugins</groupId>
296+
<artifactId>nexus-staging-maven-plugin</artifactId>
297+
</plugin>
298+
</plugins>
299+
</build>
300+
</profile>
301+
</profiles>
216302
</project>

0 commit comments

Comments
 (0)