-
Notifications
You must be signed in to change notification settings - Fork 0
331 lines (271 loc) · 10.5 KB
/
release.yml
File metadata and controls
331 lines (271 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Extract version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test
build:
name: Build Java Client Artifacts
needs: validate
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Update README with release version
run: |
VERSION="${{ needs.validate.outputs.version }}"
sed -i "s/<version>[^<]*<\/version>/<version>${VERSION}<\/version>/g" README.md
sed -i "s/implementation '[^']*'/implementation 'com.orisunlabs:orisun-java-client:${VERSION}'/g" README.md
sed -i 's/implementation "[^"]*"/implementation "com.orisunlabs:orisun-java-client:${VERSION}"/g' README.md
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "chore: update README to version ${VERSION}"
git push
- name: Build release artifacts
run: ./gradlew clean build shadowJar sourcesJar javadocJar
- name: Prepare release artifacts
run: |
mkdir -p release-artifacts
cd build/libs
# Find the shadow JAR (fat JAR with all dependencies) - this is what users want
shadow_jar=$(ls orisun-client*.jar 2>/dev/null | grep -v 'javadoc' | grep -v 'sources' | head -1)
if [ -z "$shadow_jar" ]; then
echo "Error: No shadow JAR file found"
ls -la
exit 1
fi
echo "Found shadow JAR: $shadow_jar"
cp "$shadow_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}.jar
# Copy sources and javadoc JARs
if ls *sources.jar 1> /dev/null 2>&1; then
sources_jar=$(ls *sources.jar | head -1)
echo "Found sources JAR: $sources_jar"
cp "$sources_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}-sources.jar
fi
if ls *javadoc.jar 1> /dev/null 2>&1; then
javadoc_jar=$(ls *javadoc.jar | head -1)
echo "Found javadoc JAR: $javadoc_jar"
cp "$javadoc_jar" ../../release-artifacts/orisun-java-client-${{ needs.validate.outputs.version }}-javadoc.jar
fi
# Verify files were copied
echo "Contents of release-artifacts:"
ls -la ../../release-artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: java-client-artifacts
path: release-artifacts/*.jar
if-no-files-found: error
publish-to-github-packages:
name: Publish to GitHub Packages
needs: [ validate, build ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Configure Gradle
run: |
echo "VERSION=${{ needs.validate.outputs.version }}" >> $GITHUB_ENV
- name: Publish to GitHub Packages
run: |
./gradlew publish \
-Pversion=${{ needs.validate.outputs.version }} \
-PmavenUsername=${{ github.actor }} \
-PmavenPassword=${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-release:
name: Create GitHub Release
needs: [ validate, build ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: java-client-artifacts
path: release-artifacts
- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git tag -l "v*" --sort=-v:refname | sed -n '2p')
if [ -z "$PREVIOUS_TAG" ]; then
echo "changelog=Initial release of the Java client" >> $GITHUB_OUTPUT
else
echo "changelog<<EOF" >> $GITHUB_OUTPUT
git log --pretty=format:"* %s (%h)" $PREVIOUS_TAG..HEAD >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Java Client v${{ needs.validate.outputs.version }}
tag_name: v${{ needs.validate.outputs.version }}
body: |
## Orisun Java Client v${{ needs.validate.outputs.version }}
${{ steps.changelog.outputs.changelog }}
## Installation
### Option 1: GitHub Packages (Recommended)
The client is published to GitHub Packages.
**Maven**
Add to `pom.xml`:
```xml
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/oexza/orisun-client-java</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.orisunlabs</groupId>
<artifactId>orisun-java-client</artifactId>
<version>${{ needs.validate.outputs.version }}</version>
</dependency>
</dependencies>
```
Configure authentication in `~/.m2/settings.xml`:
```xml
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_GITHUB_TOKEN</password>
</server>
```
**Gradle**
Add to `build.gradle`:
```groovy
repositories {
maven {
url = 'https://maven.pkg.github.com/oexza/orisun-client-java'
credentials {
username = project.findProperty('githubUsername') ?: System.getenv('GITHUB_USERNAME')
password = project.findProperty('githubToken') ?: System.getenv('GITHUB_TOKEN')
}
}
}
dependencies {
implementation "com.orisunlabs:orisun-java-client:${{ needs.validate.outputs.version }}"
}
```
### Option 2: Download JAR
Download `orisun-java-client-${{ needs.validate.outputs.version }}.jar` from the assets below.
**Maven - System dependency:**
```xml
<dependency>
<groupId>com.orisunlabs</groupId>
<artifactId>orisun-java-client</artifactId>
<version>${{ needs.validate.outputs.version }}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/orisun-java-client-${{ needs.validate.outputs.version }}.jar</systemPath>
</dependency>
```
**Gradle - File dependency:**
```groovy
dependencies {
implementation files("libs/orisun-java-client-${{ needs.validate.outputs.version }}.jar")
}
```
## Usage
See the [README](https://github.com/oexza/orisun-client-java) for detailed usage instructions.
### Quick Start - OrisunClient (Event Operations)
```java
import com.orisunlabs.orisun.client.OrisunClient;
import com.orisun.eventstore.Eventstore;
try (OrisunClient client = OrisunClient.newBuilder()
.withServer("localhost", 5005)
.withBasicAuth("admin", "changeit")
.build()) {
// Save events
Eventstore.SaveEventsRequest request = Eventstore.SaveEventsRequest.newBuilder()
.setBoundary("users")
.addEvents(Eventstore.EventToSave.newBuilder()
.setEventId(java.util.UUID.randomUUID().toString())
.setEventType("UserCreated")
.setData("{\"userId\":\"user-123\"}")
.build())
.build();
client.saveEvents(request);
}
```
### Quick Start - AdminClient (User Management)
```java
import com.orisunlabs.orisun.client.AdminClient;
import com.orisun.admin.AdminOuterClass.*;
try (AdminClient adminClient = AdminClient.newBuilder()
.withServer("localhost", 5005)
.withBasicAuth("admin", "changeit")
.build()) {
// Create a user
CreateUserRequest request = CreateUserRequest.newBuilder()
.setName("John Doe")
.setUsername("johndoe")
.setPassword("securePassword123")
.addRoles("user")
.build();
AdminUser user = adminClient.createUser(request);
}
```
files: release-artifacts/*
draft: false
prerelease: false