diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index 813998d..b344bcd 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -91,47 +91,41 @@ jobs: git tag -d ${{ env.tagName }} || true git push origin :refs/tags/${{ env.tagName }} || true - - name: Update project version to ${{ inputs.releaseVersion }} + - name: Prepare release + id: prepare run: | - mvn versions:set -DnewVersion=${{ inputs.releaseVersion }} - mvn versions:commit - - - name: Commit ${{ inputs.releaseVersion }} - run: | - 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 }}" + mvn -B -U \ + -Prelease + release:clean \ + release:prepare \ + -DpreparationGoals="clean verify" \ + -DreleaseVersion=${{ inputs.releaseVersion }} \ + -DdevelopmentVersion=${{ inputs.developmentVersion }} \ + -Dresume=false + env: + GITHUB_TOKEN: ${{ github.token }} - - name: Push next version ${{ inputs.developmentVersion }}" + - name: Release rollback on failure run: | - git push origin ${{ env.branchName }} + mvn -B -U \ + release:rollback \ + if: always() && (steps.prepare.outcome == 'failure') + + - uses: actions/upload-artifact@v4 + with: + name: release-${{ matrix.os }}.properties + path: release.properties release: - name: Release v${{ inputs.releaseVersion }} on ${{ matrix.config.os }} + name: Release v${{ inputs.releaseVersion }} on ${{ matrix.os }} needs: prepare - runs-on: ${{ matrix.config.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - config: - - { os: ubuntu-latest, packageSuffix: linux } - - { os: windows-latest, packageSuffix: windows } + os: [ ubuntu-latest, windows-latest ] steps: @@ -147,54 +141,42 @@ 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 + - uses: actions/download-artifact@v4 + with: + name: release-${{ matrix.os }}.properties - name: Perform release to GitHub Packages id: perform run: | mvn -B -U \ - clean deploy \ + release:perform \ + -Dgoals=deploy \ + -DworkingDirectory=$GITHUB_WORKSPACE/target/release \ + -DreleaseVersion=${{ inputs.releaseVersion }} \ + -DdevelopmentVersion=${{ inputs.developmentVersion }} \ -s $GITHUB_WORKSPACE/settings.xml env: GITHUB_TOKEN: ${{ github.token }} - - name: Get Deployed Package Version ID from Versions List - id: version-id + - name: Release rollback on failure run: | - 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 }}" + mvn -B -U \ + release:rollback \ 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.config.os }} + name: jre-${{ matrix.os }} path: | - ./target/*.buildinfo - ./metricshub-jre-*/target/*.zip - ./metricshub-jre-*/target/*.buildinfo + ./target/release/target/*.buildinfo + ./target/release/metricshub-jre-*/target/*.zip + ./target/release/metricshub-jre-*/target/*.buildinfo # Finalize job finalize: name: Finalize release runs-on: ubuntu-latest - needs: [ prepare, release ] + needs: [ prepare, prepare-os-release, release ] steps: - uses: actions/checkout@v4 diff --git a/pom.xml b/pom.xml index 6e4e8ca..b5e444b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.sentrysoftware metricshub-jre-builder - 1.0.00-SNAPSHOT + 1.1.00-SNAPSHOT MetricsHub JRE Builder pom @@ -14,7 +14,7 @@ UTF-8 - 2024-01-09T17:32:03Z + 2024-01-10T15:57:07Z @@ -89,7 +89,13 @@ metricshub-jre-linux - + + release + + metricshub-jre-windows + metricshub-jre-linux + +