Skip to content

Commit

Permalink
Merge pull request #77 from wiremock/maven-central-releases
Browse files Browse the repository at this point in the history
Add Maven Central release configuration
  • Loading branch information
oleg-nenashev authored Oct 16, 2023
2 parents a780a64 + cd4f647 commit 2b9b2ec
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 7 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
with:
fetch-depth: 0

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -29,20 +34,29 @@ jobs:
distribution: 'temurin'
cache: maven

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Set Release Version
id: vars
shell: bash
run: |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
mvn -ntp -B versions:set -DnewVersion=${{ github.event.inputs.version }}-SNAPSHOT
mvn -ntp --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }}
git diff-index --quiet HEAD || git commit -m "Releasing version ${{ github.event.inputs.version }}" pom.xml
- name: Publish to GitHub Packages
run: mvn -ntp -B release:prepare release:perform
run: mvn -ntp --batch-mode clean deploy -Prelease
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Set up Java for publishing to Maven Central
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish to the Maven Central
run: mvn --batch-mode deploy -Prelease,mavencentral-release
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
86 changes: 86 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,90 @@
<url>https://maven.pkg.github.com/wiremock/wiremock-testcontainers-java</url>
</repository>
</distributionManagement>

<profiles>
<profile>
<id>release</id>
<properties>
<version.maven-release-plugin>3.0.0-M7</version.maven-release-plugin>
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>${version.maven-release-plugin}</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<!-- The key's name & passphrase are configured via GitHub's setup-java action. -->
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>${version.maven-gpg-plugin}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- This is required to make sure the plugin does not stop asking for -->
<!-- user input on the passphrase -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>mavencentral-release</id>
<properties>
<version.nexus-staging-maven-plugin>1.6.13</version.nexus-staging-maven-plugin>
</properties>
<distributionManagement>
<repository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${version.nexus-staging-maven-plugin}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 2b9b2ec

Please sign in to comment.