From 894ec5c5bae77ab744afe930d72aacf4e82e8847 Mon Sep 17 00:00:00 2001 From: Sudipta Borah Date: Wed, 11 Feb 2026 15:44:07 +0530 Subject: [PATCH 1/4] add build workflow --- .github/workflow/build.yml | 75 +++++++++++++++++++++++++++++++++++++ build_config/toolchains.xml | 13 +++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflow/build.yml create mode 100644 build_config/toolchains.xml diff --git a/.github/workflow/build.yml b/.github/workflow/build.yml new file mode 100644 index 0000000..76c2863 --- /dev/null +++ b/.github/workflow/build.yml @@ -0,0 +1,75 @@ +name: Build - oci-openai-java-sdk + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +concurrency: + group: build-oci-openai-java-sdk-${{ github.ref }} + cancel-in-progress: true + +env: + MAJOR_VERSION: "0" + MINOR_VERSION: "1" + VERSION_OFFSET: 20 + TOOLCHAINS_PATH: "build_config/toolchains.xml" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Compute Build Version + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + BRANCH="${{ github.head_ref }}" + else + BRANCH="${GITHUB_REF#refs/heads/}" + fi + + SANITIZED_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9]/_/g') + + if [ "$BRANCH" = "main" ]; then + VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${GITHUB_RUN_NUMBER}" + else + VERSION="${MAJOR_VERSION}.${MINOR_VERSION}-${SANITIZED_BRANCH}.${GITHUB_RUN_NUMBER}-SNAPSHOT" + fi + + echo "VERSION=${VERSION}" >> $GITHUB_ENV + + - name: Run Maven Build and Verify + run: | + TOOLCHAINS="" + if [ -f "${{ env.TOOLCHAINS_PATH }}" ]; then + TOOLCHAINS="--global-toolchains ${{ env.TOOLCHAINS_PATH }}" + fi + + # Update the POM version dynamically + mvn -B $TOOLCHAINS org.codehaus.mojo:versions-maven-plugin:2.14.2:set -DnewVersion="${{ env.VERSION }}" -DgenerateBackupPoms=false + + # Run the actual build and tests + mvn -B $TOOLCHAINS verify + + - name: Upload Build Artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: oci-openai-java-sdk-artifacts + path: | + **/target/*.jar + **/target/*.war + **/target/*.zip + **/target/*.tar.gz diff --git a/build_config/toolchains.xml b/build_config/toolchains.xml new file mode 100644 index 0000000..535eb25 --- /dev/null +++ b/build_config/toolchains.xml @@ -0,0 +1,13 @@ + + + + + jdk + + 17 + + + /usr/lib/jvm/jdk-17.0.1 + + + \ No newline at end of file From 6e674a636b387b378d812b99dee59633ffc4338f Mon Sep 17 00:00:00 2001 From: Sudipta Borah Date: Wed, 11 Feb 2026 15:46:36 +0530 Subject: [PATCH 2/4] update workflow folder name --- .github/{workflow => workflows}/build.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/build.yml (100%) diff --git a/.github/workflow/build.yml b/.github/workflows/build.yml similarity index 100% rename from .github/workflow/build.yml rename to .github/workflows/build.yml From 190d21d220c517b79df2d3e08efe5f89d9853290 Mon Sep 17 00:00:00 2001 From: Sudipta Borah Date: Wed, 11 Feb 2026 15:54:18 +0530 Subject: [PATCH 3/4] fix build name --- .github/workflows/build.yml | 39 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76c2863..c158b61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,43 +33,42 @@ jobs: cache: 'maven' - name: Compute Build Version + id: versioning run: | + # Calculate the patch number: 20 + run_number + PATCH=$(( ${{ env.VERSION_OFFSET }} + ${{ github.run_number }} )) + + # Determine branch name if [ "${{ github.event_name }}" == "pull_request" ]; then BRANCH="${{ github.head_ref }}" else BRANCH="${GITHUB_REF#refs/heads/}" fi - SANITIZED_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9]/_/g') + # Clean branch name for Maven (alphanumeric only) + SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9]/_/g') + # Final version string construction if [ "$BRANCH" = "main" ]; then - VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${GITHUB_RUN_NUMBER}" + # Result: 0.1.21 + VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${PATCH}" else - VERSION="${MAJOR_VERSION}.${MINOR_VERSION}-${SANITIZED_BRANCH}.${GITHUB_RUN_NUMBER}-SNAPSHOT" + # Result: 0.1.21-branch_name-SNAPSHOT + VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${PATCH}-${SAFE_BRANCH}-SNAPSHOT" fi - echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "Final Version set to: $VERSION" - - name: Run Maven Build and Verify + - name: Run Maven Build run: | TOOLCHAINS="" if [ -f "${{ env.TOOLCHAINS_PATH }}" ]; then TOOLCHAINS="--global-toolchains ${{ env.TOOLCHAINS_PATH }}" fi - # Update the POM version dynamically - mvn -B $TOOLCHAINS org.codehaus.mojo:versions-maven-plugin:2.14.2:set -DnewVersion="${{ env.VERSION }}" -DgenerateBackupPoms=false + # Set the version in all poms + mvn -B $TOOLCHAINS org.codehaus.mojo:versions-maven-plugin:2.14.2:set \ + -DnewVersion="${{ env.VERSION }}" -DgenerateBackupPoms=false - # Run the actual build and tests - mvn -B $TOOLCHAINS verify - - - name: Upload Build Artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: oci-openai-java-sdk-artifacts - path: | - **/target/*.jar - **/target/*.war - **/target/*.zip - **/target/*.tar.gz + mvn -B $TOOLCHAINS clean verify From 7f0877802651040e1802f8e6409ecf26640a2ab4 Mon Sep 17 00:00:00 2001 From: Sudipta Borah Date: Wed, 11 Feb 2026 16:05:48 +0530 Subject: [PATCH 4/4] remove build versioning --- .github/workflows/build.yml | 44 +++++-------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c158b61..1ebf80d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,18 +12,15 @@ concurrency: cancel-in-progress: true env: - MAJOR_VERSION: "0" - MINOR_VERSION: "1" - VERSION_OFFSET: 20 TOOLCHAINS_PATH: "build_config/toolchains.xml" jobs: build: + name: Build & Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout repository + uses: actions/checkout@v4 - name: Setup Java 17 uses: actions/setup-java@v4 @@ -32,43 +29,12 @@ jobs: distribution: 'temurin' cache: 'maven' - - name: Compute Build Version - id: versioning - run: | - # Calculate the patch number: 20 + run_number - PATCH=$(( ${{ env.VERSION_OFFSET }} + ${{ github.run_number }} )) - - # Determine branch name - if [ "${{ github.event_name }}" == "pull_request" ]; then - BRANCH="${{ github.head_ref }}" - else - BRANCH="${GITHUB_REF#refs/heads/}" - fi - - # Clean branch name for Maven (alphanumeric only) - SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9]/_/g') - - # Final version string construction - if [ "$BRANCH" = "main" ]; then - # Result: 0.1.21 - VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${PATCH}" - else - # Result: 0.1.21-branch_name-SNAPSHOT - VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${PATCH}-${SAFE_BRANCH}-SNAPSHOT" - fi - - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "Final Version set to: $VERSION" - - - name: Run Maven Build + - name: Verify (Compile & Test) run: | TOOLCHAINS="" if [ -f "${{ env.TOOLCHAINS_PATH }}" ]; then TOOLCHAINS="--global-toolchains ${{ env.TOOLCHAINS_PATH }}" fi - - # Set the version in all poms - mvn -B $TOOLCHAINS org.codehaus.mojo:versions-maven-plugin:2.14.2:set \ - -DnewVersion="${{ env.VERSION }}" -DgenerateBackupPoms=false + # build locally and run unit tests mvn -B $TOOLCHAINS clean verify