From 4c5ca92a7f2c59ccb52b063bf339587234781b42 Mon Sep 17 00:00:00 2001 From: Nassim Boutekedjiret Date: Tue, 9 Jan 2024 12:20:12 +0100 Subject: [PATCH] [#3] Update GitHub release and project site * Updated maven-release.yaml * Updated POM files * Optimized maven-deploy.yaml --- .github/workflows/maven-deploy.yml | 44 +++++------- .github/workflows/maven-release.yml | 100 +++++++++++++++++++--------- metricshub-jre-linux/pom.xml | 4 +- metricshub-jre-windows/pom.xml | 4 +- pom.xml | 21 ++---- 5 files changed, 93 insertions(+), 80 deletions(-) diff --git a/.github/workflows/maven-deploy.yml b/.github/workflows/maven-deploy.yml index 9930fca..059e138 100644 --- a/.github/workflows/maven-deploy.yml +++ b/.github/workflows/maven-deploy.yml @@ -8,14 +8,24 @@ on: push: branches: [ "main" ] +# Default to bash +defaults: + run: + shell: bash + jobs: - build-linux: - runs-on: ubuntu-latest + deploy: permissions: contents: write packages: write + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + steps: - name: Checkout code uses: actions/checkout@v4 @@ -29,36 +39,12 @@ jobs: server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: Build and Deploy from ubuntu-latest - run: mvn -B deploy + - name: Build and Deploy from ${{ matrix.os }} + run: mvn -B deploy --file pom.xml -s $GITHUB_WORKSPACE/settings.xml env: GITHUB_TOKEN: ${{ github.token }} + # Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Maven Dependency Tree Dependency Submission uses: advanced-security/maven-dependency-submission-action@v3.0.3 - build-windows: - runs-on: windows-latest - - permissions: - contents: write - packages: write - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: 'maven' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Build and Deploy from windows-latest - run: mvn -B deploy - env: - GITHUB_TOKEN: ${{ github.token }} - diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index eff8410..4da36c6 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -33,6 +33,7 @@ permissions: pull-requests: write pages: write id-token: write + packages: write # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these releases and deployments to complete. @@ -90,33 +91,47 @@ jobs: git tag -d ${{ env.tagName }} || true git push origin :refs/tags/${{ env.tagName }} || true - - name: Prepare release - id: prepare + - name: Update project version to ${{ inputs.releaseVersion }} run: | - mvn -B -U \ - release:clean \ - release:prepare \ - -DpreparationGoals="clean verify" \ - -DreleaseVersion=${{ inputs.releaseVersion }} \ - -DdevelopmentVersion=${{ inputs.developmentVersion }} \ - -Dresume=false - env: - GITHUB_TOKEN: ${{ github.token }} + mvn versions:set -DnewVersion=${{ inputs.releaseVersion }} + mvn versions:commit - - name: Release rollback on failure + - name: Commit ${{ inputs.releaseVersion }} run: | - mvn -B -U \ - release:rollback \ - if: always() && (steps.prepare.outcome == 'failure') + git add pom.xml metricshub-jre-linux/pom.xml metricshub-jre-windows/pom.xml + git commit -m "Updated POM version to ${{ inputs.releaseVersion }}" + + - name: Create tag ${{ env.tagName }} + run: | + git tag -a ${{ env.tagName }} -m "Release ${{ env.tagName }}" + + - name: Push tag ${{ env.tagName }} + run: | + git push origin ${{ env.tagName }} + + - name: Prepare next version ${{ inputs.developmentVersion }} + run: | + mvn versions:set -DnewVersion=${{ inputs.developmentVersion }} + mvn versions:commit + git add pom.xml metricshub-jre-linux/pom.xml metricshub-jre-windows/pom.xml + git commit -m "Updated POM version to ${{ inputs.developmentVersion }}" + + - name: Push next version ${{ inputs.developmentVersion }}" + run: | + git push origin ${{ env.branchName }} release: - name: Release v${{ inputs.releaseVersion }} - - runs-on: ${{ matrix.os }} + name: Release v${{ inputs.releaseVersion }} on ${{ matrix.config.os }} + + needs: prepare + + runs-on: ${{ matrix.config.os }} strategy: matrix: - os: [ ubuntu-latest, windows-latest ] + config: + - { os: ubuntu-latest, packageSuffix: linux } + - { os: windows-latest, packageSuffix: windows } steps: @@ -132,30 +147,48 @@ jobs: server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Checkout ${{ needs.prepare.outputs.tagName }} branch + run: | + git fetch + git checkout ${{ needs.prepare.outputs.tagName }} 2>/dev/null + - name: Perform release to GitHub Packages id: perform run: | mvn -B -U \ - release:perform \ - -Dgoals=deploy \ - -DworkingDirectory=$GITHUB_WORKSPACE/target/release \ - -DreleaseVersion=${{ inputs.releaseVersion }} \ - -DdevelopmentVersion=${{ inputs.developmentVersion }} \ + clean deploy \ + -s $GITHUB_WORKSPACE/settings.xml env: GITHUB_TOKEN: ${{ github.token }} - - name: Release rollback on failure + - name: Get Deployed Package Version ID from Versions + id: version-id run: | - mvn -B -U \ - release:rollback \ + curl -X GET -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" https://api.github.com/orgs/sentrysoftware/packages/maven/org.sentrysoftware.metricshub-jre-${{ matrix.config.packageSuffix }}/versions >> $HOME/versionIds.json + echo "versionId=$(grep -B1 '"name": "${{ inputs.releaseVersion }}"' $HOME/versionIds.json | grep '"id":' | awk -F': ' '{print $2}' | tr -d ',')" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ github.token }} if: always() && (steps.perform.outcome == 'failure') + - name: Deployed Version ID + run: echo "The deployed Version ID is ${{ env.versionId }}" + if: always() && (steps.perform.outcome == 'failure') + + - name: Package ${{ inputs.releaseVersion }} removal on failure + uses: actions/delete-package-versions@v4 + with: + package-version-ids: ${{ env.versionId }} + package-name: org.sentrysoftware.metricshub-jre-${{ matrix.config.packageSuffix }} + package-type: maven + if: always() && (steps.perform.outcome == 'failure') && (env.versionId != '') + - uses: actions/upload-artifact@v4 with: - name: jre-${{ matrix.os }} + name: jre-${{ matrix.config.os }} path: | - ./target/release/target/*.buildinfo - ./metricshub-jre-*/target/release/target/*.zip + ./target/*.buildinfo + ./metricshub-jre-*/target/*.zip + ./metricshub-jre-*/target/*.buildinfo # Finalize job finalize: @@ -164,6 +197,8 @@ jobs: needs: [ prepare, release ] steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: merge-multiple: true @@ -175,8 +210,9 @@ jobs: fail_on_unmatched_files: false generate_release_notes: true files: | - *.buildinfo - *.zip + ./target/*.buildinfo + ./metricshub-jre-*/target/*.zip + ./metricshub-jre-*/target/*.buildinfo - name: Create Pull Request from ${{ needs.prepare.outputs.branchName }} to ${{ github.event.repository.default_branch }} uses: devops-infra/action-pull-request@v0.5.5 diff --git a/metricshub-jre-linux/pom.xml b/metricshub-jre-linux/pom.xml index 566c2bb..7521332 100644 --- a/metricshub-jre-linux/pom.xml +++ b/metricshub-jre-linux/pom.xml @@ -17,9 +17,9 @@ - maven-site-plugin + maven-deploy-plugin - true + false diff --git a/metricshub-jre-windows/pom.xml b/metricshub-jre-windows/pom.xml index cbc3013..3b2b8d4 100644 --- a/metricshub-jre-windows/pom.xml +++ b/metricshub-jre-windows/pom.xml @@ -17,9 +17,9 @@ - maven-site-plugin + maven-deploy-plugin - true + false diff --git a/pom.xml b/pom.xml index 2d2bf00..10134c0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,4 @@ - + 4.0.0 @@ -16,7 +14,7 @@ UTF-8 - 2023-10-25T22:28:48Z + 2024-01-09T17:32:03Z @@ -40,7 +38,7 @@ scm:git:https://github.com/sentrysoftware/metricshub-jre-builder.git https://maven.pkg.github.com/sentrysoftware/metricshub-jre-builder - HEAD + v1.0.00 @@ -98,6 +96,9 @@ maven-deploy-plugin + + true + @@ -168,16 +169,6 @@ maven-deploy-plugin 3.1.1 - - - org.apache.maven.plugins - maven-release-plugin - 3.0.1 - - v@{project.version} - true - -