Skip to content

Commit 2cd6745

Browse files
pratik3558Pratik Lala
andauthored
Add GitHub Actions CI and GitHub Release workflow (#5)
- ci.yml: build and test on every push/PR across Java 11, 17, and 21 - release.yml: triggered by version tag push (v*.*.*) or manual dispatch; builds JARs and attaches them to a GitHub Release automatically No secrets required. Maven Central publishing to be added in a follow-up once Sonatype credentials are available. Co-authored-by: Pratik Lala <[email protected]>
1 parent df20832 commit 2cd6745

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI — Build and Test
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
tags-ignore: ["v*"]
7+
pull_request:
8+
branches: ["**"]
9+
10+
jobs:
11+
build:
12+
name: Build and Test (Java ${{ matrix.java }})
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
java: ['11', '17', '21']
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK ${{ matrix.java }}
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: ${{ matrix.java }}
26+
distribution: corretto
27+
cache: maven
28+
29+
- name: Build and test
30+
run: mvn --batch-mode clean verify
31+
32+
- name: Upload test results
33+
if: always()
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: test-results-java-${{ matrix.java }}
37+
path: target/surefire-reports/
38+
retention-days: 7

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Release — GitHub Release
2+
3+
# Trigger: push a version tag
4+
# git tag v1.0.0 && git push origin v1.0.0
5+
#
6+
# No secrets required. Builds the JARs and attaches them to a GitHub Release.
7+
# Maven Central publishing will be added in a future workflow once credentials are available.
8+
9+
on:
10+
push:
11+
tags:
12+
- "v*.*.*"
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: "Version to release (e.g. 1.0.0) — without the 'v' prefix"
17+
required: true
18+
19+
jobs:
20+
release:
21+
name: Build and Publish GitHub Release
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Set up JDK 11
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: '11'
34+
distribution: corretto
35+
cache: maven
36+
37+
- name: Determine version
38+
id: version
39+
run: |
40+
if [ -n "${{ github.event.inputs.version }}" ]; then
41+
VERSION="${{ github.event.inputs.version }}"
42+
else
43+
VERSION="${GITHUB_REF_NAME#v}"
44+
fi
45+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
46+
echo "Releasing version: $VERSION"
47+
48+
- name: Set Maven version
49+
run: |
50+
mvn --batch-mode versions:set \
51+
-DnewVersion=${{ steps.version.outputs.version }} \
52+
-DgenerateBackupPoms=false
53+
54+
- name: Build and test
55+
run: mvn --batch-mode clean verify
56+
57+
- name: Create GitHub Release
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
tag_name: v${{ steps.version.outputs.version }}
61+
name: v${{ steps.version.outputs.version }}
62+
generate_release_notes: true
63+
make_latest: true
64+
files: |
65+
target/json2jsontransformer-*.jar
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)