Skip to content

Commit

Permalink
feat: integrate JReleaser for automated releases
Browse files Browse the repository at this point in the history
- Add JReleaser Maven plugin
- Updated `.gitignore` to include `.env.keys`.
- Create GitHub Actions workflow for releasing new versions and publishing to Maven Central
- Add JReleaser configuration file for changelog management
  • Loading branch information
f-lopes committed Sep 27, 2024
1 parent 80c37ff commit 0df3026
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 23 deletions.
32 changes: 32 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
changelog:
exclude:
labels:
- ignore-for-release
authors:
- octocat

categories:
- title: 🎉 New Features
labels:
- enhancement
- feature

- title: 🐞 Bug Fixes
labels:
- bug

- title: 📔 Documentation
labels:
- documentation

- title: 🔨 Dependency Upgrades
labels:
- dependencies

- title: Other Changes
labels:
- "*"

- title: Breaking Changes 🛠
labels:
- breaking-change
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build

on:
push:
tags:
- 'v*'
branches:
- 'feat/jreleaser'

jobs:

build:
name: "Release new version and publish to the Maven Central Repository"

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: maven

- name: Retrieve release version from tag
id: retrieve_release_version
run: release_version=${GITHUB_REF_NAME#v}; echo "release_version=$release_version" >> "$GITHUB_OUTPUT"

- name: Set release version
id: set_release_version
run: mvn -B versions:set -DnewVersion=${{ steps.current_version.outputs.release_version }}

- name: Commit & Push changes
uses: actions-js/push@master

Check warning on line 38 in .github/workflows/release.yml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/release.yml#L38

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: Perform release ${{ github.event.inputs.version }}

- name: Release to Maven Central
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B -pl spring-mvc-test-utils -Prelease jreleaser:deploy

- name: Set next development version
run: mvn -B build-helper:parse-version versions:set-property -Dproperty=revision -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit

- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: Set next development version
tags: true
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@

<slf4j-api.version>1.7.36</slf4j-api.version>

<junit-jupiter.version>5.11.0</junit-jupiter.version>
<junit-jupiter.version>5.11.1</junit-jupiter.version>

<lombok.version>1.18.34</lombok.version>

<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.4.0</maven-surefire-plugin.version>
<maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
<versions-maven-plugin.version>2.17.1</versions-maven-plugin.version>
<maven-pmd-plugin.version>3.25.0</maven-pmd-plugin.version>
<spotbugs-maven-plugin.version>4.8.6.3</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.8.6.4</spotbugs-maven-plugin.version>

<sonar.organization>f-lopes</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
Expand Down
60 changes: 40 additions & 20 deletions spring-mvc-test-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<maven-jxr-plugin.version>3.4.0</maven-jxr-plugin.version>
<nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<jreleaser-maven-plugin.version>1.14.0</jreleaser-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -195,6 +196,13 @@
<profiles>
<profile>
<id>release</id>
<properties>
<spotbugs.skip>true</spotbugs.skip>
<pmd.skip>true</pmd.skip>
<skipTests>true</skipTests>
<altDeploymentRepository>local::file:${project.build.outputDirectory}/staging-deploy
</altDeploymentRepository>
</properties>
<build>
<plugins>
<plugin>
Expand All @@ -216,6 +224,9 @@
<goals>
<goal>jar</goal>
</goals>
<configuration>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -229,6 +240,9 @@
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -251,32 +265,38 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>${jreleaser-maven-plugin.version}</version>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<jreleaser>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<deploy>
<maven>
<nexus2>
<maven-central>
<active>ALWAYS</active>
<url>https://oss.sonatype.org/service/local</url>
<snapshotUrl>
https://s01.oss.sonatype.org/content/repositories/snapshots/
</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>false</releaseRepository>
<stagingRepositories>target/staging-deploy</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
</jreleaser>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spotbugs.skip>true</spotbugs.skip>
<pmd.skip>true</pmd.skip>
<skipTests>true</skipTests>
</properties>
</profile>
</profiles>

Expand Down

0 comments on commit 0df3026

Please sign in to comment.