|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' # Runs for all branches |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build & Test |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: github.ref != 'refs/heads/master' # Runs on all branches except master |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout Repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup Java 21 |
| 22 | + uses: actions/setup-java@v4 |
| 23 | + with: |
| 24 | + java-version: '21' |
| 25 | + distribution: 'temurin' |
| 26 | + cache: 'maven' |
| 27 | + |
| 28 | + - name: Make Maven wrapper executable |
| 29 | + run: chmod +x mvnw |
| 30 | + |
| 31 | + - name: Build and Run Tests |
| 32 | + run: ./mvnw --no-transfer-progress clean verify |
| 33 | + |
| 34 | + - if: ${{ github.ref == 'refs/heads/master' }} |
| 35 | + name: Publish to GitHub Packages Apache Maven |
| 36 | + run: ./mvnw deploy -s $GITHUB_WORKSPACE/settings.xml |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ github.token }} |
| 39 | + |
| 40 | + deploy: |
| 41 | + name: Build, Test & Deploy |
| 42 | + runs-on: ubuntu-latest |
| 43 | + if: github.ref == 'refs/heads/master' # Runs only on master |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + packages: write # Needed to publish to GitHub Packages |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout Repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Setup Java |
| 53 | + uses: actions/setup-java@v4 |
| 54 | + with: |
| 55 | + java-version: '21' |
| 56 | + distribution: 'temurin' |
| 57 | + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml |
| 58 | + settings-path: ${{ github.workspace }} # location for the settings.xml file |
| 59 | + cache: 'maven' |
| 60 | + |
| 61 | + - name: Build and Deploy to GitHub Packages |
| 62 | + run: ./mvnw --no-transfer-progress clean deploy -s $GITHUB_WORKSPACE/settings.xml |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ github.token }} |
| 65 | + |
| 66 | + - name: Create GitHub Release |
| 67 | + uses: softprops/action-gh-release@v2 |
| 68 | + with: |
| 69 | + tag_name: ${{ env.VERSION }} |
| 70 | + generate_release_notes: true |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
0 commit comments