Skip to content

Release

Release #2

Workflow file for this run

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
### Option 1: Download JAR
Download the JAR file from the assets below and add it to your project.
### Option 2: GitHub Packages
Add to your `pom.xml`:
```xml
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/oexza/orisun-client-java</url>
</repository>
<dependency>
<groupId>com.orisunlabs</groupId>
<artifactId>orisun-java-client</artifactId>
<version>${{ needs.validate.outputs.version }}</version>
</dependency>
```
Or for Gradle:
```groovy
repositories {
maven { url 'https://maven.pkg.github.com/oexza/orisun-client-java' }
}
implementation 'com.orisunlabs:orisun-java-client:${{ needs.validate.outputs.version }}'
```
**Note**: To use GitHub Packages, you'll need to authenticate:
```groovy
// In ~/.gradle/gradle.properties
githubUsername=YOUR_GITHUB_USERNAME
githubPassword=YOUR_GITHUB_TOKEN
```
Or in `pom.xml`:
```xml
<server>
<id>github</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
```
## Usage
See the [README](https://github.com/oexza/orisun-client-java) for detailed usage instructions.
Quick start:
```java
import com.orisunlabs.orisun.client.OrisunClient;
OrisunClient client = OrisunClient.newBuilder()
.withServer("localhost", 5005)
.withBasicAuth("admin", "changeit")
.build();
// Use the client...
```
files: release-artifacts/*
draft: false
prerelease: false