Skip to content

Commit

Permalink
Automate artifact publishing to maven central (#28)
Browse files Browse the repository at this point in the history
* chore(ci): #21 preparations for automated artifact publishing to maven central

* chore(ci): #21 Added GPG signing for release

* chore(ci): #21 settings for central server id
  • Loading branch information
snovak7 authored Apr 17, 2024
1 parent 3e05885 commit ed412af
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 11 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
trust_level: 4
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand All @@ -27,8 +33,16 @@ jobs:
- name: PR Check
if: github.event_name == 'pull_request'
run: mvn --batch-mode package
- name: Publish package
- name: Publish package to GitHub Maven Repository
run: mvn --batch-mode deploy
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package to Maven Central Repository
if: github.event_name == 'release'
run: mvn -P release --batch-mode deploy
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_AUTOPUBLISH: false
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
97 changes: 87 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<artifactId>keycloak-event-listener-temporal</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>https://infinityflow.app/</url>
<description>A Keycloak SPI Event Listener that publishes events to Temporal Server</description>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand All @@ -19,13 +21,6 @@
<keycloak.version>24.0.3</keycloak.version>
</properties>

<repositories>
<repository>
<id>mavenCentral</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
Expand Down Expand Up @@ -79,6 +74,7 @@
<mainClass>MainKt</mainClass>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -92,9 +88,6 @@
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.PaxosServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
Expand Down Expand Up @@ -172,5 +165,89 @@
</repository>
</distributionManagement>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>1.9.20</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
<autoPublish>${env.MAVEN_AUTOPUBLISH}</autoPublish>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>

<developers>
<developer>
<id>snovak7</id>
<name>Simon Novak</name>
<url>https://github.com/snovak7</url>
</developer>
</developers>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:https://github.com/InfinityFlowApp/keycloak-event-listener-temporal.git</connection>
<developerConnection>scm:git:https://github.com/InfinityFlowApp/keycloak-event-listener-temporal.git</developerConnection>
<url>https://github.com/InfinityFlowApp/keycloak-event-listener-temporal</url>
</scm>
</project>
11 changes: 11 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>central</id>
<username>${env.MAVEN_USERNAME}</username>
<password>${env.MAVEN_PASSWORD}</password>
</server>
</servers>
</settings>

0 comments on commit ed412af

Please sign in to comment.