From 0a0e7d0425cb44d1eac7e8b46d4675d72158d66c Mon Sep 17 00:00:00 2001
From: p3t <3204560+p3t@users.noreply.github.com>
Date: Mon, 11 Nov 2024 11:05:29 +0100
Subject: [PATCH] new maven based build
---
.github/workflows/build.yml | 141 ----------------------------
.github/workflows/maven_build.yml | 12 +--
.github/workflows/maven_publish.yml | 42 +++++++++
.github/workflows/start_release.yml | 62 ++----------
pom.xml | 1 +
5 files changed, 56 insertions(+), 202 deletions(-)
delete mode 100644 .github/workflows/build.yml
create mode 100644 .github/workflows/maven_publish.yml
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index d85e625..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,141 +0,0 @@
-name: '[ BUILD ] Build Project (Java/Gradle)'
-
-on:
- workflow_dispatch:
- inputs:
- release_build:
- description: 'toggles an release-build, by default false'
- type: boolean
- default: false
- required: false
- build_version:
- description: 'The version to build and deploy'
- type: string
- required: true
- default: '0-SNAPSHOT'
- workflow_call:
- inputs:
- release_build:
- description: 'toggles an release-build, by default false'
- type: boolean
- default: false
- required: false
- build_version:
- description: 'The version to build and deploy'
- type: string
- required: false
- default: '0-SNAPSHOT'
- outputs:
- build_artifact_id:
- description: 'The id of the uploaded build artifacts.'
- value: ${{ jobs.Build.outputs.build_artifacts_id}}
- push:
- branches: [ "main" ]
- pull_request:
- branches: [ "main" ]
-
-env:
- BUILD_VERSION: ${{ inputs.build_version != '' && inputs.build_version || '0-SNAPSHOT' }}
-
-jobs:
- Validation:
- name: "Validation"
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: gradle/actions/wrapper-validation@v4
-
- Build:
- name: "Build, Sign and Upload Artifacts"
- runs-on: ubuntu-latest
- permissions:
- contents: read
- pull-requests: write
- outputs:
- build_artifacts_id: ${{ steps.BuildArtifactUpload.outputs.artifact-id }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- - run: tree
-
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'temurin'
-
- # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
- # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- - name: Setup Gradle
- uses: gradle/actions/setup-gradle@v4 # v3.1.0
- with:
- add-job-summary-as-pr-comment: on-failure
- artifact-retention-days: 5
- # with:
- # dependency-graph: generate-and-submit
-
- - name: Generate gradle.properties
- run: |
- echo "version=${BUILD_VERSION}"
- echo "version=${BUILD_VERSION}" >> ./gradle.properties
- cat ./gradle.properties
-
- - name: Clean
- if: ${{ inputs.release_build }}
- run: ./gradlew clean
- env:
- GITHUB_DEPENDENCY_GRAPH_ENABLED: false
-
- - name: Build with Gradle Wrapper
- id: Build
- run: ./gradlew -Pversion=${BUILD_VERSION} --info build jacocoTestReport
-
- - name: Sign Artifacts
- if: ${{ steps.Build.outcome == 'success' && inputs.release_build }}
- # if: inputs.release_build
- run: |
- ./gradlew -Pversion=${BUILD_VERSION} \
- --info signMavenJavaPublication
- env:
- GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
- GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
- GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
-
- - name: Build Artifacts Upload
- id: BuildArtifactUpload
- uses: actions/upload-artifact@v4
- with:
- name: build-artifacts
- path: |
- ./**/build/libs/*${{inputs.build_version}}*.jar
- ./**/build/libs/*${{inputs.build_version}}*.jar.asc
- ./**/build/reports/
-
- DependencySubmission:
- name: "Dependency Submission"
- runs-on: ubuntu-latest
- permissions:
- contents: write
-
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'temurin'
-
- # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
- # https://github.com/gradle/actions/blob/main/docs/dependency-submission.md
- - name: Generate and submit dependency graph
- uses: gradle/actions/dependency-submission@v4
- env:
- # Exclude all dependencies that originate solely in the 'buildSrc' or testapp project
- DEPENDENCY_GRAPH_EXCLUDE_PROJECTS: ':buildSrc|:cursorpaging-testapp'
- # Exclude dependencies that are only resolved in test classpaths
- DEPENDENCY_GRAPH_EXCLUDE_CONFIGURATIONS: '.*[Tt]est(Compile|Runtime)Classpath'
- with:
- build-scan-publish: true
- build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
- build-scan-terms-of-use-agree: "yes"
\ No newline at end of file
diff --git a/.github/workflows/maven_build.yml b/.github/workflows/maven_build.yml
index 9ee4200..1a43998 100644
--- a/.github/workflows/maven_build.yml
+++ b/.github/workflows/maven_build.yml
@@ -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 }}
\ No newline at end of file
+ GITHUB_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/maven_publish.yml b/.github/workflows/maven_publish.yml
new file mode 100644
index 0000000..4cfc623
--- /dev/null
+++ b/.github/workflows/maven_publish.yml
@@ -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
\ No newline at end of file
diff --git a/.github/workflows/start_release.yml b/.github/workflows/start_release.yml
index 8487b64..4348fbe 100644
--- a/.github/workflows/start_release.yml
+++ b/.github/workflows/start_release.yml
@@ -38,7 +38,7 @@ 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
@@ -46,6 +46,7 @@ jobs:
permissions:
pull-requests: write
contents: write
+ packages: write
UploadAssetsToRelease:
needs: [ ReleaseVersion, Build ]
@@ -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
\ No newline at end of file
+ contents: write
diff --git a/pom.xml b/pom.xml
index ec84841..6e25330 100644
--- a/pom.xml
+++ b/pom.xml
@@ -273,6 +273,7 @@
true
central
+ uploaded