Skip to content

Commit 7159143

Browse files
author
Abhishek Malvadkar
committed
GH-1 : Added GitHub action workflow for CI and CD
1 parent 5081f6c commit 7159143

File tree

3 files changed

+96
-34
lines changed

3 files changed

+96
-34
lines changed

.github/workflows/Dev-CI.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/ci-cd.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+

pom.xml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,27 @@
1111
<description>Common Utility Library</description>
1212

1313
<properties>
14-
<!-- Dependency versions management -->
14+
<!-- Dependency versions -->
1515
<java.version>21</java.version>
1616
<junit-jupiter.version>5.10.2</junit-jupiter.version>
1717
<assertj-core.version>3.25.3</assertj-core.version>
1818

19-
<!-- Plugin versions management -->
20-
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
21-
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
19+
<!-- Plugin versions -->
20+
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
21+
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
22+
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
23+
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
2224
</properties>
2325

26+
<distributionManagement>
27+
<repository>
28+
<id>github</id>
29+
<name>GitHub Packages</name>
30+
<url>https://maven.pkg.github.com/abhishekmalvadkar/${project.artifactId}</url>
31+
</repository>
32+
</distributionManagement>
33+
34+
2435
<dependencies>
2536
<!-- JUnit 5 API for writing tests -->
2637
<dependency>
@@ -66,7 +77,7 @@
6677
<plugin>
6778
<groupId>org.apache.maven.plugins</groupId>
6879
<artifactId>maven-jar-plugin</artifactId>
69-
<version>3.2.2</version>
80+
<version>${maven-jar-plugin.version}</version>
7081
</plugin>
7182

7283
<!-- Surefire Plugin for Running JUnit 5 Tests -->
@@ -78,6 +89,13 @@
7889
<useModulePath>false</useModulePath>
7990
</configuration>
8091
</plugin>
92+
93+
<!-- Deploy Plugin for GitHub Packages -->
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-deploy-plugin</artifactId>
97+
<version>${maven-deploy-plugin.version}</version>
98+
</plugin>
8199
</plugins>
82100
</build>
83101

0 commit comments

Comments
 (0)