Skip to content

Commit 093e475

Browse files
committed
Add GitHub Actions automation and JitPack configuration
- Add CI workflow for automated testing on push/PR - Add release workflow with manual trigger for version management - Configure JitPack build optimization with Java 21 - Enable automated releases with GitHub releases and JitPack integration - Support patch/minor/major version bumping via workflow dispatch
1 parent 1b61e13 commit 093e475

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
22+
23+
- name: Cache Maven dependencies
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.m2
27+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: ${{ runner.os }}-m2
29+
30+
- name: Run tests - Main Library
31+
run: mvn clean test
32+
33+
- name: Run tests - Integration Tests
34+
run: |
35+
cd integration-tests
36+
mvn clean test
37+
38+
- name: Build library
39+
run: mvn clean compile
40+
41+
- name: Build integration tests
42+
run: |
43+
cd integration-tests
44+
mvn clean compile
45+
46+
jitpack-test:
47+
runs-on: ubuntu-latest
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49+
50+
steps:
51+
- name: Trigger JitPack build for main branch
52+
run: |
53+
echo "Triggering JitPack build for main-SNAPSHOT"
54+
curl -s "https://jitpack.io/com/github/wassertim/dynamodb-toolkit/main-SNAPSHOT" || true

.github/workflows/release.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '21'
31+
distribution: 'temurin'
32+
33+
- name: Cache Maven dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.m2
37+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
38+
restore-keys: ${{ runner.os }}-m2
39+
40+
- name: Configure Git
41+
run: |
42+
git config --global user.name "github-actions[bot]"
43+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
44+
45+
- name: Run tests
46+
run: |
47+
mvn clean test
48+
cd integration-tests && mvn clean test
49+
50+
- name: Prepare release
51+
run: |
52+
# Determine next version based on input
53+
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=dynamodb-toolkit.version -q -DforceStdout)
54+
BASE_VERSION=$(echo $CURRENT_VERSION | sed 's/-SNAPSHOT//')
55+
56+
case "${{ github.event.inputs.version_type }}" in
57+
"major")
58+
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print ($1+1)".0.0"}')
59+
;;
60+
"minor")
61+
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print $1"."($2+1)".0"}')
62+
;;
63+
"patch")
64+
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print $1"."$2"."($3+1)}')
65+
;;
66+
esac
67+
68+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
69+
echo "Releasing version: $NEW_VERSION"
70+
71+
- name: Update version
72+
run: |
73+
# Update version property in both pom.xml files
74+
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEW_VERSION<\/dynamodb-toolkit.version>/" pom.xml
75+
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEW_VERSION<\/dynamodb-toolkit.version>/" integration-tests/pom.xml
76+
77+
- name: Build and verify
78+
run: |
79+
mvn clean compile
80+
cd integration-tests && mvn clean compile
81+
82+
- name: Commit and tag release
83+
run: |
84+
git add pom.xml integration-tests/pom.xml
85+
git commit -m "Release version $NEW_VERSION"
86+
git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
87+
88+
- name: Prepare next development version
89+
run: |
90+
# Calculate next development version
91+
NEXT_DEV_VERSION=$(echo $NEW_VERSION | awk -F. '{print $1"."$2"."($3+1)"-SNAPSHOT"}')
92+
93+
# Update to next development version
94+
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEXT_DEV_VERSION<\/dynamodb-toolkit.version>/" pom.xml
95+
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEXT_DEV_VERSION<\/dynamodb-toolkit.version>/" integration-tests/pom.xml
96+
97+
git add pom.xml integration-tests/pom.xml
98+
git commit -m "Bump to next development version $NEXT_DEV_VERSION"
99+
100+
- name: Push changes and tags
101+
run: |
102+
git push origin main
103+
git push origin "v$NEW_VERSION"
104+
105+
- name: Create GitHub Release
106+
uses: actions/create-release@v1
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
with:
110+
tag_name: v${{ env.NEW_VERSION }}
111+
release_name: Release v${{ env.NEW_VERSION }}
112+
body: |
113+
## Changes in v${{ env.NEW_VERSION }}
114+
115+
This release was automatically generated.
116+
117+
### JitPack Usage
118+
Add this dependency to your `pom.xml`:
119+
```xml
120+
<dependency>
121+
<groupId>com.github.wassertim</groupId>
122+
<artifactId>dynamodb-toolkit</artifactId>
123+
<version>v${{ env.NEW_VERSION }}</version>
124+
</dependency>
125+
```
126+
127+
Don't forget to add the JitPack repository:
128+
```xml
129+
<repositories>
130+
<repository>
131+
<id>jitpack.io</id>
132+
<url>https://jitpack.io</url>
133+
</repository>
134+
</repositories>
135+
```
136+
draft: false
137+
prerelease: false
138+
139+
- name: Trigger JitPack build
140+
run: |
141+
curl -s "https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION"

jitpack.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jdk:
2+
- openjdk21
3+
install:
4+
- mvn clean compile -DskipTests=true

0 commit comments

Comments
 (0)