Skip to content

Commit c477da4

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents e435dda + 929a73b commit c477da4

2 files changed

Lines changed: 292 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
25+
- name: Grant execute permission for gradlew
26+
run: chmod +x gradlew
27+
28+
- name: Build with Gradle
29+
run: ./gradlew build -x test
30+
31+
- name: Run tests
32+
run: ./gradlew test

.github/workflows/release.yml

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., 1.0.0)'
11+
required: true
12+
13+
jobs:
14+
validate:
15+
name: Validate Release
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.get_version.outputs.version }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Set up JDK 21
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '21'
29+
distribution: 'temurin'
30+
31+
- name: Extract version from tag
32+
id: get_version
33+
run: |
34+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
35+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
36+
else
37+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Grant execute permission for gradlew
41+
run: chmod +x gradlew
42+
43+
- name: Run tests
44+
run: ./gradlew test
45+
46+
build:
47+
name: Build Java Client Artifacts
48+
needs: validate
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
with:
54+
submodules: recursive
55+
56+
- name: Set up JDK 21
57+
uses: actions/setup-java@v4
58+
with:
59+
java-version: '21'
60+
distribution: 'temurin'
61+
62+
- name: Grant execute permission for gradlew
63+
run: chmod +x gradlew
64+
65+
- name: Build JAR
66+
run: ./gradlew clean build jar
67+
68+
- name: Build Sources JAR
69+
run: ./gradlew sourcesJar
70+
71+
- name: Build Javadoc JAR
72+
run: ./gradlew javadocJar
73+
74+
- name: Prepare release artifacts
75+
run: |
76+
mkdir -p release-artifacts
77+
cd build/libs
78+
79+
# Find the main JAR (without sources or javadoc suffix)
80+
main_jar=$(ls *.jar 2>/dev/null | grep -v 'javadoc' | grep -v 'sources' | grep -v 'plain' | head -1)
81+
82+
if [ -z "$main_jar" ]; then
83+
echo "Error: No main JAR file found"
84+
ls -la
85+
exit 1
86+
fi
87+
88+
echo "Found main JAR: $main_jar"
89+
cp "$main_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}.jar
90+
91+
# Copy sources and javadoc JARs
92+
if ls *sources.jar 1> /dev/null 2>&1; then
93+
sources_jar=$(ls *sources.jar | head -1)
94+
echo "Found sources JAR: $sources_jar"
95+
cp "$sources_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}-sources.jar
96+
fi
97+
98+
if ls *javadoc.jar 1> /dev/null 2>&1; then
99+
javadoc_jar=$(ls *javadoc.jar | head -1)
100+
echo "Found javadoc JAR: $javadoc_jar"
101+
cp "$javadoc_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}-javadoc.jar
102+
fi
103+
104+
# Verify files were copied
105+
echo "Contents of release-artifacts:"
106+
ls -la ../../release-artifacts/
107+
108+
- name: Upload artifacts
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: java-client-artifacts
112+
path: release-artifacts/*.jar
113+
if-no-files-found: error
114+
115+
publish-to-github-packages:
116+
name: Publish to GitHub Packages
117+
needs: [validate, build]
118+
runs-on: ubuntu-latest
119+
permissions:
120+
contents: read
121+
packages: write
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
with:
126+
submodules: recursive
127+
128+
- name: Set up JDK 21
129+
uses: actions/setup-java@v4
130+
with:
131+
java-version: '21'
132+
distribution: 'temurin'
133+
134+
- name: Grant execute permission for gradlew
135+
run: chmod +x gradlew
136+
137+
- name: Configure Gradle
138+
run: |
139+
echo "VERSION=${{ needs.validate.outputs.version }}" >> $GITHUB_ENV
140+
141+
- name: Publish to GitHub Packages
142+
run: |
143+
./gradlew publish \
144+
-Pversion=${{ needs.validate.outputs.version }} \
145+
-PmavenUsername=${{ github.actor }} \
146+
-PmavenPassword=${{ secrets.GITHUB_TOKEN }}
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
150+
create-release:
151+
name: Create GitHub Release
152+
needs: [validate, build]
153+
runs-on: ubuntu-latest
154+
permissions:
155+
contents: write
156+
steps:
157+
- name: Checkout code
158+
uses: actions/checkout@v4
159+
with:
160+
fetch-depth: 0
161+
162+
- name: Download artifacts
163+
uses: actions/download-artifact@v4
164+
with:
165+
name: java-client-artifacts
166+
path: release-artifacts
167+
168+
- name: Generate changelog
169+
id: changelog
170+
run: |
171+
PREVIOUS_TAG=$(git tag -l "v*" --sort=-v:refname | sed -n '2p')
172+
if [ -z "$PREVIOUS_TAG" ]; then
173+
echo "changelog=Initial release of the Java client" >> $GITHUB_OUTPUT
174+
else
175+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
176+
git log --pretty=format:"* %s (%h)" $PREVIOUS_TAG..HEAD >> $GITHUB_OUTPUT
177+
echo "" >> $GITHUB_OUTPUT
178+
echo "EOF" >> $GITHUB_OUTPUT
179+
fi
180+
181+
- name: Create Release
182+
uses: softprops/action-gh-release@v1
183+
with:
184+
name: Java Client v${{ needs.validate.outputs.version }}
185+
tag_name: v${{ needs.validate.outputs.version }}
186+
body: |
187+
## Orisun Java Client v${{ needs.validate.outputs.version }}
188+
189+
${{ steps.changelog.outputs.changelog }}
190+
191+
## Installation
192+
193+
### Option 1: Download JAR
194+
195+
Download the JAR file from the assets below and add it to your project.
196+
197+
### Option 2: GitHub Packages
198+
199+
Add to your `pom.xml`:
200+
201+
```xml
202+
<repository>
203+
<id>github</id>
204+
<url>https://maven.pkg.github.com/oexza/orisun-client-java</url>
205+
</repository>
206+
207+
<dependency>
208+
<groupId>com.orisunlabs</groupId>
209+
<artifactId>orisun-java-client</artifactId>
210+
<version>${{ needs.validate.outputs.version }}</version>
211+
</dependency>
212+
```
213+
214+
Or for Gradle:
215+
216+
```groovy
217+
repositories {
218+
maven { url 'https://maven.pkg.github.com/oexza/orisun-client-java' }
219+
}
220+
221+
implementation 'com.orisunlabs:orisun-java-client:${{ needs.validate.outputs.version }}'
222+
```
223+
224+
**Note**: To use GitHub Packages, you'll need to authenticate:
225+
226+
```groovy
227+
// In ~/.gradle/gradle.properties
228+
githubUsername=YOUR_GITHUB_USERNAME
229+
githubPassword=YOUR_GITHUB_TOKEN
230+
```
231+
232+
Or in `pom.xml`:
233+
234+
```xml
235+
<server>
236+
<id>github</id>
237+
<username>${env.GITHUB_USERNAME}</username>
238+
<password>${env.GITHUB_TOKEN}</password>
239+
</server>
240+
```
241+
242+
## Usage
243+
244+
See the [README](https://github.com/oexza/orisun-client-java) for detailed usage instructions.
245+
246+
Quick start:
247+
248+
```java
249+
import com.orisunlabs.orisun.client.OrisunClient;
250+
251+
OrisunClient client = OrisunClient.newBuilder()
252+
.withServer("localhost", 5005)
253+
.withBasicAuth("admin", "changeit")
254+
.build();
255+
256+
// Use the client...
257+
```
258+
files: release-artifacts/*
259+
draft: false
260+
prerelease: false

0 commit comments

Comments
 (0)