Release #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: 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 | |
| Download the `orisun-java-client-${{ needs.validate.outputs.version }}.jar` file from the assets below. | |
| ### Maven | |
| **Option 1: System dependency** | |
| Place the JAR in your project's `lib/` directory and add to `pom.xml`: | |
| ```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> | |
| ``` | |
| **Option 2: Install to local Maven repository** | |
| ```bash | |
| mvn install:install-file \ | |
| -Dfile=orisun-java-client-${{ needs.validate.outputs.version }}.jar \ | |
| -DgroupId=com.orisunlabs \ | |
| -DartifactId=orisun-java-client \ | |
| -Dversion=${{ needs.validate.outputs.version }} \ | |
| -Dpackaging=jar | |
| ``` | |
| Then add as a regular dependency in `pom.xml`: | |
| ```xml | |
| <dependency> | |
| <groupId>com.orisunlabs</groupId> | |
| <artifactId>orisun-java-client</artifactId> | |
| <version>${{ needs.validate.outputs.version }}</version> | |
| </dependency> | |
| ``` | |
| ### Gradle | |
| **Option 1: Direct file dependency** | |
| Place the JAR in your project's `libs/` directory and add to `build.gradle`: | |
| ```groovy | |
| dependencies { | |
| implementation files("libs/orisun-java-client-${{ needs.validate.outputs.version }}.jar") | |
| } | |
| ``` | |
| **Option 2: Flat directory repository** | |
| ```groovy | |
| repositories { | |
| flatDir { dirs 'libs' } | |
| } | |
| dependencies { | |
| implementation "com.orisunlabs:orisun-java-client:${{ needs.validate.outputs.version }}" | |
| } | |
| ``` | |
| **Option 3: Build from source** | |
| ```bash | |
| git clone https://github.com/oexza/orisun-client-java.git | |
| cd orisun-client-java | |
| git submodule update --init --recursive | |
| ./gradlew build | |
| ``` | |
| The JAR will be at: `build/libs/orisun-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 |