Skip to content

Commit

Permalink
new maven based build
Browse files Browse the repository at this point in the history
  • Loading branch information
p3t committed Nov 11, 2024
1 parent 68d07ad commit 0a0e7d0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 202 deletions.
141 changes: 0 additions & 141 deletions .github/workflows/build.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/maven_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ jobs:
id: Build
run: ./mvnw -T1C --batch-mode clean install

- name: Publish to GitHub Packages Apache Maven
- name: Javadoc and sign artifacts
if: ${{ inputs.release_build }}
run: ./mvnw -T1C --batch-mode package javadoc:jar gpg:sign -Dgpg.signer=bc
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
./**/target/libs/*${{inputs.build_version}}*.jar
./**/target/libs/*${{inputs.build_version}}*.jar.asc
./**/target/*${{inputs.build_version}}*.jar
./**/target/*${{inputs.build_version}}*.jar.asc
./**/target/reports/
retention-days: 10

- name: Publish to GitHub Packages Apache Maven
- name: Publish to GitHub Packages
if: ${{ inputs.release_build }}
run: mvn deploy
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}
42 changes: 42 additions & 0 deletions .github/workflows/maven_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: '[ PUBLISH ] Release build with maven'

on:
workflow_call:
inputs:
build_version:
description: 'The version to be published'
type: string
required: true
Publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
cache-dependency-path: '**/pom.xml'
server-id: 'central'
server-username: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
server-password: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts

- name: Display structure of downloaded files
run: tree

- name: Publish to Maven Central
run: ./mvnw deploy -DskipTests=true -Dmaven.javadoc.skip=true -B -V

- name: Debug
if: ${{ failure() }}
run: |
echo "Failed"
tree
62 changes: 7 additions & 55 deletions .github/workflows/start_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ jobs:
Build:
needs: [ ReleaseVersion ]
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/maven_build.yml
with:
build_version: ${{ needs.ReleaseVersion.outputs.build_version }}
release_build: true
secrets: inherit
permissions:
pull-requests: write
contents: write
packages: write

UploadAssetsToRelease:
needs: [ ReleaseVersion, Build ]
Expand All @@ -72,59 +73,10 @@ jobs:
Publish:
needs: [ ReleaseVersion, Build ]
runs-on: ubuntu-latest
uses: ./.github/workflows/maven_publish.yml
with:
build_version: ${{ needs.ReleaseVersion.outputs.build_version }}
secrets: inherit
permissions:
contents: write
packages: write
env:
BUILD_VERSION: ${{ needs.ReleaseVersion.outputs.build_version }}

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

- uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Display structure of downloaded files
run: tree

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4 # v3.1.0

- name: Generate gradle.properties with version
run: |
echo "version=${BUILD_VERSION}"
echo "version=${BUILD_VERSION}" >> ./gradle.properties
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: publish to sonar central
run: ./gradlew sonatypeCentralUpload
env:
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
SONATYPE_CENTRAL_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
SONATYPE_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: Debug
if: ${{ failure() }}
run: |
echo "Failed"
tree
contents: write
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<waitUntil>uploaded</waitUntil>
</configuration>
</plugin>

Expand Down

0 comments on commit 0a0e7d0

Please sign in to comment.