From b6309e1e453d67c20ca8ec056726d3457fca08aa Mon Sep 17 00:00:00 2001 From: CodeBlo Date: Sun, 4 Feb 2024 22:40:24 +0300 Subject: [PATCH] Remove release plugin and use versions plugin --- .github/workflows/build-and-release.yml | 46 +++++++++++++++++++++++++ .github/workflows/build-for-release.yml | 40 --------------------- .github/workflows/publish.yml | 26 -------------- pom.xml | 9 ++--- 4 files changed, 49 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/build-and-release.yml delete mode 100644 .github/workflows/build-for-release.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 0000000..7d4fb73 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,46 @@ +name: Release to Maven Central + +on: + release: + types: [ published ] + +permissions: + contents: write + + + +jobs: + build-for-release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: master + - name: Setup git config + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Set up JDK 19 + uses: actions/setup-java@v4 + with: + java-version: '19' + distribution: 'corretto' + cache: maven + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + + - if: github.event.release + name: Update version in pom.xml (Release only) + run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false + - name: Verify and deploy + run: mvn -B deploy --file pom.xml + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/.github/workflows/build-for-release.yml b/.github/workflows/build-for-release.yml deleted file mode 100644 index a5dcf61..0000000 --- a/.github/workflows/build-for-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build for Release - -on: workflow_dispatch -permissions: - contents: write - -env: - MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} - MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} - -jobs: - build-for-release: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: master - - name: Setup git config - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - - name: Set up JDK 19 - uses: actions/setup-java@v4 - with: - java-version: '19' - distribution: 'corretto' - cache: maven - gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import - server-id: central # Value of the distributionManagement/repository/id field of the pom.xml - server-username: MAVEN_USERNAME # env variable for username in deploy - server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy - - name: View settings.xml - run: cat /home/runner/.m2/settings.xml - - name: Prepare for release - run: mvn -B release:prepare release:perform --file pom.xml - - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 40277b4..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Deploy to central - -on: workflow_dispatch - - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - uses: actions/checkout@v4 - - name: Set env - run: echo "RELEASE_VERSION=v0.0.2" >> $GITHUB_ENV - - name: Set up JDK 19 - uses: actions/setup-java@v4 - with: - java-version: '19' - distribution: 'corretto' - server-id: central # Value of the distributionManagement/repository/id field of the pom.xml - server-username: ${{ secrets.MAVEN_USERNAME }} # env variable for username in deploy - server-password: ${{ secrets.MAVEN_CENTRAL_TOKEN }} # env variable for token in deploy - - - name: Release with Maven - run: mvn -B release:perform -DconnectionUrl=scm:git:${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ env.RELEASE_VERSION }} diff --git a/pom.xml b/pom.xml index 12ca99d..0d9a5d6 100644 --- a/pom.xml +++ b/pom.xml @@ -150,12 +150,9 @@ - org.apache.maven.plugins - maven-release-plugin - 3.0.1 - - v@{project.version} - + org.codehaus.mojo + versions-maven-plugin + 2.16.2