From bfb3780ad006838210bfd3135505c73f64675e30 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 08:02:10 +0530 Subject: [PATCH 1/8] Add distributionManagement section Explicitly add plugin versions --- pom.xml | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9376596..68ab844 100644 --- a/pom.xml +++ b/pom.xml @@ -13,12 +13,33 @@ 17 UTF-8 3.8.1 + 3.4.0 + 3.13.0 + 3.1.3 3.5.0 - 3.25.3 + 3.1.3 3.8.0 + 3.4.2 + 3.8.0 + 3.3.1 + 3.20.0 + 2.4 + 3.5.0 4.13.0 + 3.25.3 + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + org.apache.maven.enforcer @@ -58,11 +79,93 @@ + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 enforce-maven-version @@ -132,5 +235,4 @@ - \ No newline at end of file From 65a92f220b101c8a1df374d5f4bd56ec9069b3c1 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 08:15:59 +0530 Subject: [PATCH 2/8] Update workflow for testing --- .github/workflows/maven.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5f7d4d3..4b9e78f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,8 +28,14 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven + server-id: 'ossrh' + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD - name: Build with Maven - run: ./mvnw -V -B verify + run: ./mvnw -V -B deploy + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph From c65bcc42b9fe4be5fc570de516721577eefb9015 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 10:37:33 +0530 Subject: [PATCH 3/8] Use central-publishing-maven-plugin --- pom.xml | 142 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 68ab844..f9bdd9e 100644 --- a/pom.xml +++ b/pom.xml @@ -8,15 +8,42 @@ enforcer-rules 1.0-SNAPSHOT + Maven Enforcer Rule to ban empty java source files + https://github.com/shitikanth/enforcer-rules + + + + The Apache Software License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Shitikanth Kashyap + shitikanth1@gmail.com + + + + + scm:git:https://github.com/shitikanth/enforcer-rules.git + scm:git:ssh://git@github.com:shitikanth/enforcer-rules.git + HEAD + https://github.com/shitikanth/enforcer-rules/tree/main + + 17 17 UTF-8 3.8.1 + 3.4.0 3.13.0 3.1.3 3.5.0 + 3.2.6 3.1.3 3.8.0 3.4.2 @@ -24,22 +51,16 @@ 3.3.1 3.20.0 2.4 - 3.5.0 + 3.2.2 + 0.6.0 + + 4.13.0 3.25.3 + 5.11.0 + 1.5.7 - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - org.apache.maven.enforcer @@ -67,13 +88,13 @@ org.junit.jupiter junit-jupiter - 5.11.0 + ${junit-jupiter.version} test ch.qos.logback logback-classic - 1.5.7 + ${logback-classic.version} test @@ -101,6 +122,11 @@ maven-compiler-plugin ${maven-compiler-plugin.version} + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + org.apache.maven.plugins maven-deploy-plugin @@ -108,8 +134,8 @@ org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} + maven-gpg-plugin + ${maven-gpg-plugin.version} org.apache.maven.plugins @@ -136,33 +162,14 @@ maven-surefire-plugin ${maven-surefire-plugin.version} + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-maven-plugin.version} + - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - org.apache.maven.plugins maven-enforcer-plugin @@ -234,5 +241,60 @@ + + deploy + + true + + + + + org.sonatype.central + central-publishing-maven-plugin + true + + central + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + \ No newline at end of file From e1c2fcac5f0f83309cb1309c79ace676d0c8d4e1 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 10:43:28 +0530 Subject: [PATCH 4/8] Add environment variables for GPG private key and passphrase --- .github/workflows/maven.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4b9e78f..c478589 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,14 +28,16 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven - server-id: 'ossrh' + server-id: 'central' server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - name: Build with Maven - run: ./mvnw -V -B deploy + run: ./mvnw -V -B deploy -Dgpg.signer=bc env: MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + MAVEN_GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph From 8b3ec83e93f136befe97024025dd8673cf4b7e11 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 14:00:38 +0530 Subject: [PATCH 5/8] Add semantic versioning --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f9bdd9e..4ab9a82 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.shitikanth enforcer-rules - 1.0-SNAPSHOT + 1.0.0-SNAPSHOT Maven Enforcer Rule to ban empty java source files https://github.com/shitikanth/enforcer-rules @@ -297,4 +297,4 @@ - \ No newline at end of file + From bdc1049b29bd9d1d75092a11ba05f5170d052807 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 14:55:08 +0530 Subject: [PATCH 6/8] Fix developerConnection --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4ab9a82..59b759e 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ scm:git:https://github.com/shitikanth/enforcer-rules.git - scm:git:ssh://git@github.com:shitikanth/enforcer-rules.git + scm:git:ssh://git@github.com/shitikanth/enforcer-rules.git HEAD https://github.com/shitikanth/enforcer-rules/tree/main From 6cc49b5adec9dedab41255b97af644ef4a3c2dc4 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 17:11:03 +0530 Subject: [PATCH 7/8] Create two workflows for CI and Release --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++ .github/workflows/maven.yml | 44 ----------------------------------- .github/workflows/release.yml | 29 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e3b8da3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: Java CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + server-id: 'central' + - name: Build with Maven + run: ./mvnw -B verify + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@v4 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index c478589..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,44 +0,0 @@ -# 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 - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - server-id: 'central' - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - - name: Build with Maven - run: ./mvnw -V -B deploy -Dgpg.signer=bc - env: - MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - MAVEN_GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..34791a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Release + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + server-id: 'central' + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Perform Release + run: ./mvnw -B -Dgpg.signer=bc release:prepare release:perform + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + MAVEN_GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} \ No newline at end of file From 108e78b55801f9b378f5613fb36c0c738c271be4 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Tue, 24 Sep 2024 17:13:21 +0530 Subject: [PATCH 8/8] Only run deployment related steps in release profile --- .github/workflows/release.yml | 2 +- pom.xml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34791a9..c7f7650 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - name: Perform Release - run: ./mvnw -B -Dgpg.signer=bc release:prepare release:perform + run: ./mvnw -B -Prelease -Dgpg.signer=bc release:prepare release:perform env: MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/pom.xml b/pom.xml index 59b759e..31766ae 100644 --- a/pom.xml +++ b/pom.xml @@ -242,10 +242,7 @@ - deploy - - true - + release