Skip to content

Commit

Permalink
Tune maven-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
p3t committed Nov 12, 2024
1 parent 574cbac commit 1296db7
Show file tree
Hide file tree
Showing 27 changed files with 267 additions and 1,019 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/maven_build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: '[ BUILD ] Build Project (Java/Maven)'
name: '[ Start ] Build Project (Java/Maven)'

on:
workflow_dispatch:
Expand Down Expand Up @@ -40,6 +40,8 @@ env:
jobs:
Build:
runs-on: ubuntu-latest
outputs:
build_artifacts_id: ${{ steps.BuildArtifactUpload.outputs.artifact-id }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -63,26 +65,36 @@ jobs:
id: Build
run: ./mvnw -T1C --batch-mode clean install

- name: Evaluate branch name where the scan results are added to in Sonarcloud
if: ${{inputs.actor != 'dependabot[bot]' }}
id: branch_to_scan
shell: bash
run: |
echo github.head_ref - pull request: ${{ github.head_ref }}
echo github.ref_name - push: ${{ github.ref_name }}
echo event: ${{ github.event_name }}
echo branch name to scan: ${{ github.head_ref || github.ref_name }}
echo name=${{ github.head_ref || github.ref_name }} >> $GITHUB_OUTPUT
- name: Javadoc and sign artifacts
if: ${{ inputs.release_build }}
run: ./mvnw -T1C --batch-mode package javadoc:jar gpg:sign -Dgpg.signer=bc
run: ./mvnw -T1C --batch-mode package 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: (Info) Display structure of files
run: tree

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

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

on:
workflow_call:
Expand All @@ -7,36 +7,86 @@ on:
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
build_artifact_id:
description: 'The id of the uploaded build artifacts.'
type: string
required: false
default: 'build-artifacts'
env:
BUILD_VERSION: ${{ inputs.build_version }}

jobs:
PublishOnCentral:
name: 'Publish to Maven Central'
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: 'SERVER_USERNAME'
server-password: 'SERVER_PASSWORD'

- name: (Info) Display build-version
run: echo ${{ inputs.build_version }}

# - name: Download build artifacts
# uses: actions/download-artifact@v4
# with:
# merge-multiple: true
# name: build-artifacts-${{ inputs.build_version }}

- name: Set version
run: ./mvnw versions:set -DnewVersion=${{ inputs.build_version }} -DgenerateBackupPoms=false

- name: Publish to Maven Central
run: ./mvnw -T1C --batch-mode deploy -Dgpg.signer=bc -Dcentral -DskipTests
env:
SERVER_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
SERVER_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: (Info) Display structure of the files
if: always()
run: tree -D

PublishGitHub:
name: 'Publish to GitHub packages'
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: 'github'
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
name: build-artifacts-${{ inputs.build_version }}

- name: Set version
run: ./mvnw versions:set -DnewVersion=${{ inputs.build_version }} -DgenerateBackupPoms=false

- name: Publish to GitHub
run: ./mvnw deploy -DskipTests=true -Dmaven.javadoc.skip=true -B -V
env:
GITHUB_TOKEN: ${{ github.token }}
12 changes: 10 additions & 2 deletions .github/workflows/start_release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#

name: '[ RELEASE ] Package & Deploy'
name: '[ Start ] Release artifacts, Build & Deploy'

on:
workflow_dispatch:
Expand Down Expand Up @@ -49,6 +49,7 @@ jobs:
packages: write

UploadAssetsToRelease:
name: 'Upload assets to release'
needs: [ ReleaseVersion, Build ]
runs-on: ubuntu-latest
permissions:
Expand All @@ -57,6 +58,9 @@ jobs:
BUILD_VERSION: ${{ needs.ReleaseVersion.outputs.build_version }}

steps:
- name: (Info) build_artifact_id
run: echo "build_artifact_id=${{ needs.Build.outputs.build_artifact_id }}"

- uses: actions/download-artifact@v4
with:
merge-multiple: true
Expand All @@ -67,7 +71,10 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: |
./**/build/libs/*
./**/target/*.jar
./**/target/*.jar.asc
./**/target/*.pom
./**/target/*.pom.asc
./LICENSE
./README.md
Expand All @@ -76,6 +83,7 @@ jobs:
uses: ./.github/workflows/maven_publish.yml
with:
build_version: ${{ needs.ReleaseVersion.outputs.build_version }}
build_artifact_id: ${{ needs.Build.outputs.build_artifact_id }}
secrets: inherit
permissions:
packages: write
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Java CI with Gradle](https://github.com/p3t/spring-curserpaging/actions/workflows/build.yml/badge.svg)](https://github.com/p3t/spring-curserpaging/actions/workflows/build.yml)
[![[ BUILD ] Build Project (Java/Maven)](https://github.com/p3t/spring-cursorpaging/actions/workflows/maven_build.yml/badge.svg)](https://github.com/p3t/spring-cursorpaging/actions/workflows/maven_build.yml)

# Spring Data repository support for cursor based paging

Expand Down
3 changes: 0 additions & 3 deletions build.gradle.kts

This file was deleted.

24 changes: 0 additions & 24 deletions buildSrc/build.gradle.kts

This file was deleted.

3 changes: 0 additions & 3 deletions buildSrc/src/main/kotlin/Dependencies.kt

This file was deleted.

3 changes: 0 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt

This file was deleted.

Loading

0 comments on commit 1296db7

Please sign in to comment.