From dbc2146e1feacc01671c440fc932d8b63bfc9965 Mon Sep 17 00:00:00 2001 From: Jonathan Louie Date: Tue, 24 Sep 2024 10:11:19 -0700 Subject: [PATCH] Create Java snapshot workflow Signed-off-by: Jonathan Louie --- .github/workflows/java-snapshots.yml | 134 +++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 .github/workflows/java-snapshots.yml diff --git a/.github/workflows/java-snapshots.yml b/.github/workflows/java-snapshots.yml new file mode 100644 index 0000000000..2113e00966 --- /dev/null +++ b/.github/workflows/java-snapshots.yml @@ -0,0 +1,134 @@ +name: Java Snapshot Deployment + +on: + pull_request: + types: + - closed + workflow_dispatch: + inputs: + version: + description: "The snapshot version of GLIDE, formatted as *.*.*" + required: true + +jobs: + if_merged: + if: github.event.pull_request.merged + load-platform-matrix: + runs-on: ubuntu-latest + environment: AWS_ACTIONS + outputs: + PLATFORM_MATRIX: ${{ steps.load-platform-matrix.outputs.PLATFORM_MATRIX }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: load-platform-matrix + id: load-platform-matrix + shell: bash + run: | + # Get the matrix from the matrix.json file, without the object that has the IMAGE key + export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["maven"])))' < .github/json_matrices/build-matrix.json | jq -c .)" + echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT + + set-snapshot-version: + runs-on: ubuntu-latest + outputs: + RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }} + steps: + - name: Set the snapshot version + id: snapshot-version + shell: bash + run: | + if ${{ github.event_name == 'workflow_dispatch' }}; then + R_VERSION="${{ env.INPUT_VERSION }}" + else + R_VERSION=${GITHUB_REF:11} + fi + echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_ENV + echo "Release version detected: $R_VERSION" + echo "RELEASE_VERSION=$R_VERSION" >> $GITHUB_OUTPUT + env: + INPUT_VERSION: ${{ github.event.inputs.version }} + + create-binaries: + needs: [set-snapshot-version, load-platform-matrix] + if: github.repository_owner == 'valkey-io' + timeout-minutes: 35 + env: + JAVA_VERSION: "11" + RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }} + strategy: + fail-fast: false + matrix: + host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }} + + runs-on: ${{ matrix.host.RUNNER }} + + steps: + - name: Setup self-hosted runner access + run: | + GHA_HOME=/home/ubuntu/actions-runner/_work/valkey-glide + if [ -d $GHA_HOME ]; then + sudo chown -R $USER:$USER $GHA_HOME + sudo rm -rf $GHA_HOME + mkdir -p $GHA_HOME/valkey-glide + else + echo "No cleaning needed" + fi + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: ${{ env.JAVA_VERSION }} + + - name: Install shared software dependencies + uses: ./.github/workflows/install-shared-dependencies + with: + os: ${{ matrix.host.OS }} + target: ${{ matrix.host.TARGET }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install protoc (protobuf) + uses: arduino/setup-protoc@v3 + with: + version: "26.1" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create secret key ring file + working-directory: java/client + run: | + echo "$SECRING_GPG" | base64 --decode > ./secring.gpg + ls -ltr + env: + SECRING_GPG: ${{ secrets.SECRING_GPG }} + + - 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 + run: | + src_folder=~/.m2/repository/io/valkey/valkey-glide/${{ env.RELEASE_VERSION }} + cd $src_folder + jar -cvf bundle.jar * + ls -ltr + cd - + cp $src_folder/bundle.jar bundle-${{ matrix.host.TARGET }}.jar + + - name: Upload artifacts + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: java-${{ matrix.host.TARGET }} + path: | + java/bundle*.jar +