Skip to content

Commit

Permalink
build: add jreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-grgt committed Dec 14, 2023
1 parent 4b6d5a9 commit d02de54
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 6 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: release

on:
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# Configure build steps as you'd normally do

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'zulu'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

# Post JARs to Maven Central

- name: Release to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
git config user.name "${{ github.event.head_commit.committer.name }}"
git config user.email "${{ github.event.head_commit.committer.email }}"
mvn -B --file pom.xml release:prepare release:perform
# Create a release

- name: Run JReleaser
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Persist logs

- name: JReleaser release output
if: always()
uses: actions/upload-artifact@v3
with:
name: jreleaser-release
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
145 changes: 139 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,41 @@
<module>xjx-serdes</module>
</modules>

<licenses>
<license>
<name>GPL-v3.0</name>
<url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<id>jonasgeiregat</id>
<name>Jonas Geiregat</name>
<email>[email protected]</email>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/jonasgeiregat/xjx.git</connection>
<developerConnection>scm:git:https://github.com/jonasgeiregat/xjx.git</developerConnection>
<url>https://github.com/jonasgeiregat/xjx.git</url>
<tag>HEAD</tag>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
<surefire-maven-plugin.version>3.1.2</surefire-maven-plugin.version>
<maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<jreleaser.version>1.9.0</jreleaser.version>
</properties>

<dependencyManagement>
Expand All @@ -41,15 +69,50 @@
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<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-compiler-plugin</artifactId>
<version>${maven-compiler-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-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>${jreleaser.version}</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
<executions>
<execution>
<id>clean</id>
Expand All @@ -67,7 +130,77 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<configuration>
<jreleaser>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<deploy>
<maven>
<nexus2>
<maven-central>
<active>ALWAYS</active>
<url>https://s01.oss.sonatype.org/service/local</url>
<snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>true</releaseRepository>
<stagingRepositories>target/staging-deploy</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
</jreleaser>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<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</goal>
</goals>
<configuration>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit d02de54

Please sign in to comment.