66
77env :
88 SONAR_PROJECT_KEY : vincejv_dtone-dvs-api-java-client
9+ MVN_ARTIFACT_ID : dvs-apiclient
910
1011jobs :
1112
1213 pre_job :
1314 name : Duplicate checks
1415 runs-on : ubuntu-latest
16+ if : ${{ !contains(github.event.head_commit.message, 'docs-update(') }} # skip for commits containing 'docs-update('
1517 outputs :
1618 should_skip : ${{ steps.skip_check.outputs.should_skip }}
1719 paths_result : ${{ steps.skip_check.outputs.paths_result }}
@@ -52,12 +54,14 @@ jobs:
5254 env :
5355 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
5456 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
55- run : mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true
57+ run : mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true -Pallow-snapshots
5658
5759 deploy :
58- name : Release artifact
60+ name : Release artifact to central
5961 runs-on : ubuntu-latest
6062 needs : code_quality_checks
63+ outputs :
64+ artifact_version : ${{ steps.gen_ver.outputs.artifact_version }}
6165 permissions :
6266 contents : read
6367 packages : write
7983 gpg-private-key : ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
8084 gpg-passphrase : MAVEN_GPG_PASSPHRASE
8185
86+ - name : Prepare artifact version
87+ id : gen_ver
88+ run : |
89+ echo "artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
90+
8291 - name : Build and release to central repo
8392 env :
8493 MAVEN_USERNAME : ${{ secrets.OSSRH_USERNAME }}
8594 MAVEN_PASSWORD : ${{ secrets.OSSRH_TOKEN }}
8695 MAVEN_GPG_PASSPHRASE : ${{ secrets.MAVEN_GPG_PASSPHRASE }}
87- run : mvn -B deploy -Prelease-for-oss
96+ run : mvn -B deploy -Prelease-for-oss,allow-snapshots
97+
98+ pr_update :
99+ name : Pull request update
100+ if : always()
101+ needs : [ pre_job, deploy ]
102+ runs-on : ubuntu-latest
103+ permissions :
104+ contents : read
105+ pull-requests : write # allows job to decorate PRs with analysis results
106+ steps :
107+ - name : Update PR (Skip message)
108+ uses : marocchino/sticky-pull-request-comment@v2
109+ if : ${{ always() && needs.pre_job.outputs.should_skip == 'true' }}
110+ with :
111+ message : |
112+ ⚪ Skipped CI/CD as deployment was done in a previous job
113+
114+ - name : Update PR (Success message)
115+ uses : marocchino/sticky-pull-request-comment@v2
116+ if : ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version != '' }}
117+ with :
118+ message : |
119+ ✅ Released version to SNAPSHOT repository: `${{ needs.deploy.outputs.artifact_version }}`
120+
121+ #### Add to your POM
122+ ```xml
123+ <dependency>
124+ <groupId>com.vincejv</groupId>
125+ <artifactId>${{ env.MVN_ARTIFACT_ID }}</artifactId>
126+ <version>${{ needs.deploy.outputs.artifact_version }}</version>
127+ </dependency>
128+ ```
129+
130+ - name : Update PR (Failure message)
131+ uses : marocchino/sticky-pull-request-comment@v2
132+ if : ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version == '' }}
133+ with :
134+ message : |
135+ ❌ CI Build & Deployment failed, please check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details
0 commit comments