-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from vincejv/development
Release to Prod
- Loading branch information
Showing
3 changed files
with
155 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
name: Maven Central SNAPSHOT deployment | ||
|
||
on: | ||
pull_request_target: | ||
types: [ opened, synchronize, reopened ] | ||
|
||
env: | ||
SONAR_PROJECT_KEY: vincejv_fpi-framework | ||
|
||
jobs: | ||
|
||
pre_job: | ||
name: Duplicate checks | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
paths_result: ${{ steps.skip_check.outputs.paths_result }} | ||
steps: | ||
- name: Skip duplicate actions | ||
id: skip_check | ||
uses: fkirc/skip-duplicate-actions@v5 | ||
with: | ||
concurrent_skipping: outdated_runs | ||
cancel_others: true | ||
|
||
code_quality_checks: | ||
name: Code quality checks | ||
runs-on: ubuntu-latest | ||
needs: pre_job | ||
if: needs.pre_job.outputs.should_skip != 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
cache: maven | ||
|
||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
|
||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true | ||
|
||
deploy: | ||
name: Release artifact | ||
runs-on: ubuntu-latest | ||
needs: code_quality_checks | ||
outputs: | ||
artifact_version: ${{ steps.gen_ver.outputs.artifact_version }} | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
cache: maven | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
||
- name: Build and release to central repo | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
run: mvn -B deploy -Prelease-for-oss | ||
|
||
- name: Store artifact version | ||
id: gen_ver | ||
run: | | ||
echo "artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | ||
pr_update: | ||
name: Pull request update | ||
if: always() | ||
needs: [pre_job, deploy] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write # allows job to decorate PRs with analysis results | ||
steps: | ||
- name: Update PR (Skip message) | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{ always() && needs.pre_job.outputs.should_skip == 'true' }} | ||
with: | ||
message: | | ||
⚪ Skipped CI/CD as deployment was done in a previous job | ||
- name: Update PR (Success message) | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version != '' }} | ||
with: | ||
message: | | ||
✅ Released version to SNAPSHOT repository: `${{ needs.deploy.outputs.artifact_version }}` | ||
#### Parent POM Usage: | ||
```xml | ||
<parent> | ||
<groupId>com.abavilla</groupId> | ||
<artifactId>fpi-framework-pom</artifactId> | ||
<version>${{ needs.deploy.outputs.artifact_version }}</version> | ||
</parent> | ||
``` | ||
#### BOM Usage: | ||
```xml | ||
<dependencyManagement> | ||
<dependency> | ||
<groupId>com.abavilla</groupId> | ||
<artifactId>fpi-framework-bom</artifactId> | ||
<version>${{ needs.deploy.outputs.artifact_version }}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencyManagement> | ||
``` | ||
- name: Update PR (Failure message) | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version == '' }} | ||
with: | ||
message: | | ||
❌ CI Build & Deployment failed, please check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details |
File renamed without changes.