Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 121 additions & 18 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,135 @@
name: Trigger Jenkins Job
name: Maven Deploy and Release

on:
push:
branches:
- master
- latest
paths:
- superstream-clients/pom.xml

jobs:
trigger-jenkins:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

env:
HOME: /home/runner

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Determine deployment type
id: deployment
run: |
# Automatic deployment based on branch
if [ "${{ github.ref }}" == "refs/heads/latest" ]; then
echo "type=production" >> $GITHUB_OUTPUT
echo "branch=latest" >> $GITHUB_OUTPUT
else
echo "type=beta" >> $GITHUB_OUTPUT
echo "branch=master" >> $GITHUB_OUTPUT
fi

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Trigger Jenkins Job
- name: Import GPG key
env:
JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
HTTP_STATUS=$(curl -w "%{http_code}" -o /tmp/jenkins_response.txt -f -X POST \
"https://jenkins.superstream.ai/job/DevOps/job/Superstream/job/SDK/job/superstream-clients-java/buildWithParameters?DEPLOYMENT_TYPE=production" \
--user "[email protected]:$JENKINS_TOKEN")

if [ $? -ne 0 ] || [ "$HTTP_STATUS" -ne 201 ] && [ "$HTTP_STATUS" -ne 200 ]; then
echo "Jenkins trigger failed with HTTP status: $HTTP_STATUS"
cat /tmp/jenkins_response.txt
exit 1
fi

echo "Successfully triggered Jenkins build (HTTP $HTTP_STATUS)"
echo "$GPG_PRIVATE_KEY" | gpg --batch --yes --passphrase "$GPG_PASSPHRASE" --import
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
gpg --list-secret-keys --keyid-format LONG
echo "D64C041FB68170463BE78AD7C4E3F1A8A5F0A659:6:" | gpg --import-ownertrust

- name: Read Version from pom.xml
id: version
working-directory: superstream-clients
run: |
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Original version from pom.xml: $POM_VERSION"
echo "base=$POM_VERSION" >> $GITHUB_OUTPUT

- name: Create Maven Settings
run: |
mkdir -p ~/.m2
echo "${{ secrets.MAVEN_SETTINGS }}" > ~/.m2/settings.xml

- name: Build and Deploy Beta
if: steps.deployment.outputs.type == 'beta'
working-directory: superstream-clients
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn -B package --file pom.xml
BETA_VERSION="${{ steps.version.outputs.base }}-beta"
echo "Setting beta version: $BETA_VERSION"
mvn versions:set -DnewVersion=$BETA_VERSION
mvn -s ~/.m2/settings.xml deploy -DautoPublish=true -Dgpg.passphrase="$GPG_PASSPHRASE"

- name: Build and Deploy Production
if: steps.deployment.outputs.type == 'production'
working-directory: superstream-clients
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn -B package --file pom.xml
mvn -s ~/.m2/settings.xml deploy -DautoPublish=true -Dgpg.passphrase="$GPG_PASSPHRASE"

- name: Create GitHub Release
if: steps.deployment.outputs.type == 'production'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.base }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b $VERSION
git push origin $VERSION
cd superstream-clients
gh release create $VERSION target/superstream-clients-${VERSION}.jar --generate-notes

- name: Send Slack Notification - Success
if: success() && steps.deployment.outputs.type == 'production'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-clients-java v${{ steps.version.outputs.base }} Production Release SUCCESSFUL"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Send Slack Notification - Failure
if: failure() && steps.deployment.outputs.type == 'production'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-clients-java v${{ steps.version.outputs.base }} Production Release FAILED"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Send Slack Notification - Cancelled
if: cancelled() && steps.deployment.outputs.type == 'production'
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "superstream-clients-java v${{ steps.version.outputs.base }} Production Release CANCELLED"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

2 changes: 1 addition & 1 deletion superstream-clients/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>ai.superstream</groupId>
<artifactId>superstream-clients</artifactId>
<name>Superstream Kafka Client Optimizer</name>
<version>2.0.1</version>
<version>2.0.2</version>
<description>A Java library that dynamically optimizes Kafka client configuration based on recommendations</description>
<url>https://github.com/superstreamlabs/superstream-clients-java</url>
<developers>
Expand Down
2 changes: 1 addition & 1 deletion superstream-clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ai.superstream</groupId>
<artifactId>superstream-clients</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<packaging>jar</packaging>

<name>Superstream Kafka Client Optimizer</name>
Expand Down