Skip to content

Commit

Permalink
Merge pull request #122 from RedHatInsights/feat/release-to-maven-cen…
Browse files Browse the repository at this point in the history
…tral

build: Deploy Java artifacts to Maven Central
  • Loading branch information
jponge authored Jul 24, 2023
2 parents 94a97f6 + 9e336c8 commit ea5b8b9
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 75 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/deploy-maven-release.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: "chore: releasing version ${{ github.event.inputs.version }}"
- name: Release with JReleaser
uses: jreleaser/release-action@v2
with:
setup-java: false
env:
JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }}
JRELEASER_TAG_NAME: ${{ github.event.inputs.version }}
JRELEASER_PREVIOUS_TAG_NAME: ${{ github.event.inputs.previousVersion }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./release.sh
- name: Set the next release version
run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT
- name: Commit & Push changes
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ There are three modules within the project:

Product artifacts are available from Red Hat internal repositories.

If you need to use these libraries while in development then you can consume the upstream artefacts from GitHub Packages:
- see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry
- see https://github.com/orgs/RedHatInsights/packages?repo_name=insights-java-client
- use https://maven.pkg.github.com/RedHatInsights/insights-java-client as an additional Maven repository to your build
If you need to use these libraries while in development then you can consume the **Java** upstream artefacts from Maven Central.

## Building

Expand Down
1 change: 1 addition & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<artifactId>runtimes-java</artifactId>
<version>1.0.10-SNAPSHOT</version>
</parent>

<artifactId>runtimes-java-api</artifactId>

<properties>
Expand Down
32 changes: 32 additions & 0 deletions jboss-cert-helper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<artifactId>runtimes-java</artifactId>
<version>1.0.10-SNAPSHOT</version>
</parent>

<artifactId>jboss-cert-helper</artifactId>
<packaging>mvn-golang</packaging>

Expand Down Expand Up @@ -135,4 +136,35 @@
<sourceDirectory>${basedir}${file.separator}src</sourceDirectory>
</build>

<profiles>
<profile>
<id>publication</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
28 changes: 0 additions & 28 deletions jreleaser.yml

This file was deleted.

177 changes: 162 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,51 @@
<version>1.0.10-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Red Hat Insights Java Client</name>
<description>Red Hat Insights Java Client</description>
<url>https://github.com/RedHatInsights/insights-java-client</url>
<inceptionYear>2023</inceptionYear>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Benjamin Evans</name>
<email>[email protected]</email>
<organization>Red Hat</organization>
<organizationUrl>https://www.redhat.com/</organizationUrl>
</developer>
<developer>
<name>Julien Ponge</name>
<email>[email protected]</email>
<organization>Red Hat</organization>
<organizationUrl>https://www.redhat.com/</organizationUrl>
</developer>
<developer>
<name>Emmanuel Hugonnet</name>
<email>[email protected]</email>
<organization>Red Hat</organization>
<organizationUrl>https://www.redhat.com/</organizationUrl>
</developer>
</developers>

<modules>
<module>api</module>
<module>runtime</module>
<module>jboss-cert-helper</module>
</modules>

<scm>
<connection>scm:git:git://github.com/RedHatInsights/insights-java-client.git</connection>
<developerConnection>scm:git:ssh://github.com:RedHatInsights/insights-java-client.git</developerConnection>
<url>http://github.com/RedHatInsights/insights-java-client/tree/main</url>
</scm>

<distributionManagement>
<repository>
<id>github</id>
Expand Down Expand Up @@ -57,6 +96,9 @@
<maven-clean-plugin.version>3.3.1</maven-clean-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<jreleaser-maven-plugin.version>1.7.0</jreleaser-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -205,6 +247,21 @@
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>

Expand All @@ -216,21 +273,6 @@
<version>${maven-compiler-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -307,6 +349,7 @@
</build>

<profiles>

<profile>
<id>coverage</id>
<build>
Expand Down Expand Up @@ -334,6 +377,7 @@
</plugins>
</build>
</profile>

<profile>
<id>integration</id>
<build>
Expand All @@ -348,5 +392,108 @@
</plugins>
</build>
</profile>

<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>${jreleaser-maven-plugin.version}</version>
<inherited>false</inherited>
<configuration>
<projectVersionPattern>SEMVER</projectVersionPattern>
<jreleaser>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<release>
<github>
<owner>RedHatInsights</owner>
<changelog>
<preset>conventional-commits</preset>
<links>true</links>
<formatted>ALWAYS</formatted>
<hide>
<contributors>
<contributor>GitHub</contributor>
<contributor>dependabot[bot]</contributor>
<contributor>bot</contributor>
</contributors>
</hide>
</changelog>
</github>
</release>
<deploy>
<maven>
<pomchecker>
<failOnWarning>false</failOnWarning>
<failOnError>false</failOnError>
</pomchecker>
<nexus2>
<maven-central>
<active>ALWAYS</active>
<url>https://oss.sonatype.org/service/local</url>
<snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>false</releaseRepository>
<!-- TODO make true after the first release -->
<stagingRepositories>target/staging-deploy</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
</jreleaser>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>publication</id>
<properties>
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
</properties>
<build>
<defaultGoal>deploy</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
<configuration>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>
</project>
11 changes: 11 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

echo "📦 Staging artifacts..."
./mvnw --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true

echo "🚀 Releasing..."
/mvnw --batch-mode --no-transfer-progress -Prelease -pl :runtimes-java jreleaser:full-release

echo "🎉 Done!"
1 change: 1 addition & 0 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<artifactId>runtimes-java</artifactId>
<version>1.0.10-SNAPSHOT</version>
</parent>

<artifactId>runtimes-java-core-runtime</artifactId>

<dependencies>
Expand Down

0 comments on commit ea5b8b9

Please sign in to comment.