Build Pipeline For main #4
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
name: Build Pipeline | |
run-name: 'Build Pipeline For ${{github.ref_name}}' | |
on: | |
push: | |
jobs: | |
build-job: | |
name: Build Job | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
- name: Downloading Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Maven Build | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo 'Running in main branch' | |
mvn clean install | |
- name: Maven Build -- Feature Branch | |
if: github.ref != 'refs/heads/main' | |
run: | | |
echo 'Running in ${{github.ref_name}} branch' | |
mvn clean install | |
publish-to-artifact-repositories: | |
name: Publish To Nexus & OSSRH | |
runs-on: ubuntu-latest | |
needs: build-job | |
env: | |
REPOSITORY_ID: "maven-snapshots" | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
- name: Downloading Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Get Version | |
run: echo "POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Print Current Version | |
run: echo "Current Version Is - ${{env.POM_VERSION}}" | |
- name: Check If Release Version | |
if: ${{ !contains(env.POM_VERSION, '-SNAPSHOT') }} | |
run: echo "REPOSITORY_ID=maven-release" >> $GITHUB_ENV | |
- name: Deploy To Nexus | |
run: echo "Deploy artifact to nexus - ${{env.REPOSITORY_ID}}" | |
- name: Deploy To OSSRH | |
if: ${{ env.REPOSITORY_ID == 'maven-release'}} | |
run: echo "Deploy aftifacts to OSSRH" |