Skip to content

Commit

Permalink
Fixes for java client release pipeline (valkey-io#1922)
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Chloe Yip <[email protected]>
  • Loading branch information
Yury-Fridlyand authored and cyip10 committed Jul 18, 2024
1 parent cb1c63f commit 9aa12af
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
21 changes: 5 additions & 16 deletions .github/workflows/java-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,21 @@ jobs:
OS: ubuntu,
RUNNER: ubuntu-latest,
TARGET: x86_64-unknown-linux-gnu,
CLASSIFIER: linux-x86_64
}
- {
OS: ubuntu,
RUNNER: ["self-hosted", "Linux", "ARM64"],
TARGET: aarch64-unknown-linux-gnu,
CLASSIFIER: linux-aarch_64,
CONTAINER: "2_28"
}
- {
OS: macos,
RUNNER: macos-12,
TARGET: x86_64-apple-darwin,
CLASSIFIER: osx-x86_64
}
- {
OS: macos,
RUNNER: macos-latest,
TARGET: aarch64-apple-darwin,
CLASSIFIER: osx-aarch_64
}

runs-on: ${{ matrix.host.RUNNER }}
Expand All @@ -99,7 +94,7 @@ jobs:
- name: Set the release version
shell: bash
run: |
if ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}; then
if ${{ github.event_name == 'pull_request' }}; then
R_VERSION="255.255.255"
elif ${{ github.event_name == 'workflow_dispatch' }}; then
R_VERSION="${{ env.INPUT_VERSION }}"
Expand Down Expand Up @@ -139,18 +134,12 @@ jobs:
env:
SECRING_GPG: ${{ secrets.SECRING_GPG }}

- name: Replace placeholders and version in build.gradle
shell: bash
working-directory: ./java/client
run: |
SED_FOR_MACOS=`if [[ "${{ matrix.host.os }}" =~ .*"macos".* ]]; then echo "''"; fi`
sed -i $SED_FOR_MACOS 's/placeholder/${{ matrix.host.CLASSIFIER }}/g' build.gradle
sed -i $SED_FOR_MACOS "s/255.255.255/${{ env.RELEASE_VERSION }}/g" build.gradle
- name: Build java client
working-directory: java
run: |
./gradlew :client:publishToMavenLocal -Psigning.secretKeyRingFile=secring.gpg -Psigning.password="${{ secrets.GPG_PASSWORD }}" -Psigning.keyId=${{ secrets.GPG_KEY_ID }}
env:
GLIDE_RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

- name: Bundle JAR
working-directory: java
Expand All @@ -160,12 +149,12 @@ jobs:
jar -cvf bundle.jar *
ls -ltr
cd -
cp $src_folder/bundle.jar .
cp $src_folder/bundle.jar bundle-${{ matrix.host.TARGET }}.jar
- name: Upload artifacts to publish
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: java-${{ matrix.host.TARGET }}
path: |
java/bundle.jar
java/bundle*.jar
14 changes: 5 additions & 9 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Build java client
working-directory: java
run: ./gradlew --continue build
run: ./gradlew --continue build -x javadoc

- name: Ensure no skipped files by linter
working-directory: java
Expand Down Expand Up @@ -165,22 +165,18 @@ jobs:

- name: Install Java
run: |
yum install -y java-${{ matrix.java }}
yum install -y java-${{ matrix.java }}-amazon-corretto-devel.x86_64
- name: Build rust part
- name: Build java wrapper
working-directory: java
run: cargo build --release

- name: Build java part
working-directory: java
run: ./gradlew --continue build
run: ./gradlew --continue build -x javadoc

- name: Upload test & spotbugs reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.java }}
name: test-reports-${{ matrix.java }}-amazon-linux
path: |
java/client/build/reports/**
java/integTest/build/reports/**
Expand Down
2 changes: 1 addition & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.0', classifier: osdetector.classifier
implementation "io.valkey:valkey-glide:1.0.1:${osdetector.classifier}"
}

application {
Expand Down
7 changes: 3 additions & 4 deletions java/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ dependencies {
}
```
Optionally: you can specify a snapshot release and classifier:
Optionally: you can specify a snapshot release:
```bash
export GLIDE_LOCAL_VERSION=1.0.0-SNAPSHOT
export GLIDE_LOCAL_CLASSIFIER=osx-aarch_64
export GLIDE_RELEASE_VERSION=1.0.1-SNAPSHOT
./gradlew publishToMavenLocal
```
Expand All @@ -204,7 +203,7 @@ repositories {
}
dependencies {
// Update to use version defined in the previous step
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.0-SNAPSHOT', classifier='osx-aarch_64'
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.1-SNAPSHOT', classifier='osx-aarch_64'
}
```
Expand Down
42 changes: 33 additions & 9 deletions java/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id ("com.github.spotbugs") version "6.0.18"
id 'io.freefair.lombok' version '8.6'
id 'com.github.spotbugs' version '6.0.18'
id 'com.google.osdetector' version '1.7.3'
}

repositories {
Expand Down Expand Up @@ -156,7 +158,11 @@ tasks.register('copyNativeLib', Copy) {
into sourceSets.main.output.resourcesDir
}

def defaultReleaseVersion = "255.255.255";

delombok.dependsOn('compileJava')
jar.dependsOn('copyNativeLib')
javadoc.dependsOn('copyNativeLib')
copyNativeLib.dependsOn('buildRustRelease')
compileTestJava.dependsOn('copyNativeLib')
test.dependsOn('buildRust')
Expand All @@ -177,16 +183,13 @@ sourceSets {
}
}

// version is replaced during released workflow java-cd.yml
def defaultReleaseVersion = "255.255.255";

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId = 'io.valkey'
artifactId = 'valkey-glide'
version = System.getenv("GLIDE_LOCAL_VERSION") ?: defaultReleaseVersion;
version = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion;
pom {
name = 'valkey-glide'
description = 'General Language Independent Driver for the Enterprise (GLIDE) for Valkey'
Expand Down Expand Up @@ -218,8 +221,14 @@ publishing {
}
}

java {
modularity.inferModulePath = true
withSourcesJar()
withJavadocJar()
}

tasks.withType(Sign) {
def releaseVersion = System.getenv("GLIDE_LOCAL_VERSION") ?: defaultReleaseVersion;
def releaseVersion = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion;
def isReleaseVersion = !releaseVersion.endsWith("SNAPSHOT") && releaseVersion != defaultReleaseVersion;
onlyIf("isReleaseVersion is set") { isReleaseVersion }
}
Expand All @@ -239,9 +248,24 @@ tasks.withType(Test) {
}

jar {
archiveBaseName = "valkey-glide"
// placeholder will be renamed by platform+arch on the release workflow java-cd.yml
archiveClassifier = System.getenv("GLIDE_LOCAL_CLASSIFIER") ?: "placeholder"
archiveClassifier = osdetector.classifier
}

sourcesJar {
// suppress following error
// Entry glide/api/BaseClient.java is a duplicate but no duplicate handling strategy has been set
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

delombok {
modulePath = classpath
}

javadoc {
dependsOn delombok
source = delombok.outputs
options.tags = [ "example:a:Example:" ]
failOnError = false // TODO fix all javadoc errors and warnings and remove that
}

spotbugsMain {
Expand Down

0 comments on commit 9aa12af

Please sign in to comment.