Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 98 additions & 14 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,115 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "main" ]
branches: [ "main", "master", "develop" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "master", "develop" ]
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17, 21]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn -B clean compile --file pom.xml

- name: Run tests
run: mvn -B test --file pom.xml

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-java-${{ matrix.java-version }}
path: target/surefire-reports/

- name: Generate JaCoCo report
run: mvn -B jacoco:report --file pom.xml

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: jacoco-report-java-${{ matrix.java-version }}
path: target/site/jacoco/

- name: Verify code quality
run: mvn -B verify --file pom.xml

- name: Build JAR
run: mvn -B package --file pom.xml -DskipTests

- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: licify-java-${{ matrix.java-version }}
path: target/*.jar

code-quality:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Run Checkstyle
run: mvn -B checkstyle:check --file pom.xml

- name: Run Javadoc generation
run: mvn -B javadoc:javadoc --file pom.xml

publish:
needs: [build, code-quality]
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: 17
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE

- name: Publish to Maven Central
run: mvn -B release:prepare release:perform -Darguments=-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: target/*-sources.jar,target/*-javadoc.jar,target/*.jar
Loading
Loading