From 4f6ae2c7ea490091395ebab3bb02dec01192fc34 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 11 Nov 2025 17:09:35 -0800 Subject: [PATCH 01/56] feat: adding maven support --- .github/actions/extract-version-from-tag/action.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/extract-version-from-tag/action.yaml b/.github/actions/extract-version-from-tag/action.yaml index 56d26d5f..0d0b8a67 100644 --- a/.github/actions/extract-version-from-tag/action.yaml +++ b/.github/actions/extract-version-from-tag/action.yaml @@ -28,8 +28,15 @@ runs: run: | # Priority order: VERSION file -> Git tag if [[ -f "${{ inputs.version-file }}" ]]; then - # Use VERSION file - TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) + # Check if it's a pom.xml file + if [[ "${{ inputs.version-file }}" == *"pom.xml" ]]; then + # Extract version from pom.xml (project version, not dependencies) + # Get the first tag which is typically the project version + TAG=$(grep -m 1 "" "${{ inputs.version-file }}" | sed 's/.*\(.*\)<\/version>.*/\1/' | tr -d '\n\r' | xargs) + else + # Use VERSION file + TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) + fi SOURCE="file" elif [[ "${{ github.ref }}" == refs/tags/* ]]; then # Triggered by tag push From e9d98e77b7895f22a3a45393f8461d44901df7be Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Wed, 12 Nov 2025 22:03:20 -0800 Subject: [PATCH 02/56] ci: added java and maven support to execute build --- .github/workflows/reusable_execute-build.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/reusable_execute-build.yaml b/.github/workflows/reusable_execute-build.yaml index ff91225f..676fbab2 100644 --- a/.github/workflows/reusable_execute-build.yaml +++ b/.github/workflows/reusable_execute-build.yaml @@ -102,6 +102,28 @@ on: type: string default: . + # Java/Maven setup + setup-java: + description: Whether to set up Java environment + required: false + type: boolean + default: false + java-version: + description: Java version to set up (e.g., "17", "21") + required: false + type: string + default: "21" + java-distribution: + description: Java distribution (temurin, zulu, adopt, corretto, etc.) + required: false + type: string + default: temurin + java-cache: + description: Package manager to cache (maven, gradle, sbt). Leave empty for no cache. + required: false + type: string + default: maven + outputs: gh-artifact-name: description: The name of the uploaded artifacts on github @@ -146,6 +168,14 @@ jobs: submodules: recursive fetch-depth: 1 + - name: Set up Java + if: inputs.setup-java + uses: actions/setup-java@v4 + with: + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + cache: ${{ inputs.java-cache }} + - name: Set up JFrog CLI uses: jfrog/setup-jfrog-cli@5b06f730cc5a6f55d78b30753f8583454b08c0aa # v4.8.1 env: From 66e70d13e9d5508a7c324f6ed85332ba3d66cff5 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Thu, 13 Nov 2025 10:26:05 -0800 Subject: [PATCH 03/56] fix: removed changes for pom version handling --- .github/actions/extract-version-from-tag/action.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/actions/extract-version-from-tag/action.yaml b/.github/actions/extract-version-from-tag/action.yaml index 0d0b8a67..56d26d5f 100644 --- a/.github/actions/extract-version-from-tag/action.yaml +++ b/.github/actions/extract-version-from-tag/action.yaml @@ -28,15 +28,8 @@ runs: run: | # Priority order: VERSION file -> Git tag if [[ -f "${{ inputs.version-file }}" ]]; then - # Check if it's a pom.xml file - if [[ "${{ inputs.version-file }}" == *"pom.xml" ]]; then - # Extract version from pom.xml (project version, not dependencies) - # Get the first tag which is typically the project version - TAG=$(grep -m 1 "" "${{ inputs.version-file }}" | sed 's/.*\(.*\)<\/version>.*/\1/' | tr -d '\n\r' | xargs) - else - # Use VERSION file - TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) - fi + # Use VERSION file + TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) SOURCE="file" elif [[ "${{ github.ref }}" == refs/tags/* ]]; then # Triggered by tag push From 4360e1d64cb10a291dbefb5be6fe84e53a7aa4e3 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Thu, 13 Nov 2025 10:30:21 -0800 Subject: [PATCH 04/56] fix: fix comment on input variable --- .github/workflows/reusable_execute-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_execute-build.yaml b/.github/workflows/reusable_execute-build.yaml index 676fbab2..e9e8ebba 100644 --- a/.github/workflows/reusable_execute-build.yaml +++ b/.github/workflows/reusable_execute-build.yaml @@ -119,7 +119,7 @@ on: type: string default: temurin java-cache: - description: Package manager to cache (maven, gradle, sbt). Leave empty for no cache. + description: Package manager to cache (maven, gradle, sbt). required: false type: string default: maven From 6618995f5d2e7767fd26de76cf56638db1d4fc3b Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 15:42:01 -0800 Subject: [PATCH 05/56] fix: added support for jar files --- .../workflows/deploy-artifacts/entrypoint.sh | 36 +++++++++++++++++++ .../deploy-artifacts/package_utils.sh | 13 +++++++ 2 files changed, 49 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index b1d1ca5b..e736edda 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -232,6 +232,42 @@ upload_rpm_packages() { done < <(find . -name "*.rpm" -print0) } +upload_jar_packages() { + if [[ "$DRY_RUN" == "true" ]]; then + echo "Would upload JAR packages to JFrog..." >&2 + else + echo "Uploading JAR packages to JFrog..." >&2 + fi + while IFS= read -r -d '' jar; do + if [[ ! -f "$jar" ]]; then + continue + fi + + # Get metadata using the shared function + read -r -a metadata < <(get_jar_metadata "$jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + + echo " Package: $pkgname, Version: $version" >&2 + + # Upload the RPM + run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "version=$VERSION" + + # Upload signature and checksums if they exist + if [[ -f "$jar.asc" ]]; then + echo " Uploading signature: $jar.asc" >&2 + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.jar" -print0) +} + upload_generic_files() { if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload generic files..." >&2 diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 88e1713b..c9d0d332 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -10,6 +10,19 @@ handle_error() { exit 1 } +# Function to extract JAR metadata +get_jar_metadata() { + local jar="$1" + local filename="${jar##*/}" # Get just the filename without path + local pkgname version + + pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') + version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + + # Return package name and version + echo "$pkgname $version" +} + # Function to extract RPM metadata and distribution # Unlike for debs this requires parsing the name (because the distro name is not standard) get_rpm_metadata() { From ecd6c6bf94922c4d1dd11103a4bc79d87339cdde Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 15:51:05 -0800 Subject: [PATCH 06/56] fix: fix to finvoke jar package handling in entrypoint.sh --- .github/workflows/deploy-artifacts/entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index e736edda..f5dbdaa4 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -387,6 +387,9 @@ main() { cd deb upload_deb_packages cd .. + cd jar + upload_jar_packages + cd .. cd generic upload_generic_files cd .. From 9a7dd346c7d88065041db7025121a8dcfb00709c Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 22:01:48 -0800 Subject: [PATCH 07/56] fix: added missing logic for jar files --- .github/workflows/deploy-artifacts/entrypoint.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index f5dbdaa4..477f888b 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -125,6 +125,7 @@ structure_build_artifacts() { echo "current files: $(ls -la build-artifacts)" >&2 mkdir -p structured_build_artifacts/deb mkdir -p structured_build_artifacts/rpm + mkdir -p structured_build_artifacts/jar mkdir -p structured_build_artifacts/generic while IFS= read -r -d '' deb; do if [[ ! -f "$deb" ]]; then @@ -145,6 +146,16 @@ structure_build_artifacts() { done < <(find build-artifacts -name "*.rpm" -print0) echo "current files: $(ls -la build-artifacts)" >&2 + while IFS= read -r -d '' jar; do + if [[ ! -f "$jar" ]]; then + continue + fi + + echo "Processing JAR: $jar" >&2 + process_rpm "$jar" "./structured_build_artifacts/jar" + done < <(find build-artifacts -name "*.jar" -print0) + echo "current files: $(ls -la build-artifacts)" >&2 + while IFS= read -r -d '' generic; do if [[ ! -f "$generic" ]]; then echo "Skipping non-file: $generic" >&2 From bf1a8d5ef42f3daf71a262ca4b4156bde94bb7af Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 23:18:57 -0800 Subject: [PATCH 08/56] fix: fixed pathing for maven --- .../workflows/deploy-artifacts/entrypoint.sh | 12 ++++--- .../deploy-artifacts/package_utils.sh | 31 +++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 477f888b..c8e23ee0 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -152,7 +152,7 @@ structure_build_artifacts() { fi echo "Processing JAR: $jar" >&2 - process_rpm "$jar" "./structured_build_artifacts/jar" + process_jar "$jar" "./structured_build_artifacts/jar" done < <(find build-artifacts -name "*.jar" -print0) echo "current files: $(ls -la build-artifacts)" >&2 @@ -258,20 +258,22 @@ upload_jar_packages() { read -r -a metadata < <(get_jar_metadata "$jar") pkgname="${metadata[0]}" version="${metadata[1]}" + group_id="${metadata[2]}" + group_path="${group_id//./\/}" - echo " Package: $pkgname, Version: $version" >&2 + echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload the RPM - run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ + run jf rt upload "$jar" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" \ - --target-props "version=$VERSION" + --target-props "group_id=$group_id;package_name=$pkgname;version=$version" # Upload signature and checksums if they exist if [[ -f "$jar.asc" ]]; then echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index c9d0d332..3834f288 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -14,13 +14,18 @@ handle_error() { get_jar_metadata() { local jar="$1" local filename="${jar##*/}" # Get just the filename without path - local pkgname version + local pkgname version group_id pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + group_id=$(unzip -Z1 "$jar" \ + | awk '/pom\.properties$/ {print; exit}' \ + | xargs -r -I{} unzip -p "$jar" "{}" \ + | grep '^groupId=' \ + | cut -d= -f2) # Return package name and version - echo "$pkgname $version" + echo "$pkgname $version $group_id" } # Function to extract RPM metadata and distribution @@ -72,6 +77,28 @@ process_rpm() { cp -v "$rpm" "$target/$rpm_name" >&2 } +process_jar() { + local jar="$1" + local dest_dir="$2" + local -a metadata + local pkgname version arch dist + + # Get metadata using the new function + read -r -a metadata < <(get_jar_metadata "$jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + + local target="$dest_dir/$dist/$arch" + echo "DEBUG: Creating directory structure:" >&2 + echo " Distribution: $dist" >&2 + echo " Architecture: $arch" >&2 + echo " Target path: $target" >&2 + mkdir -p "$target" + echo "Copying RPM to: $target" >&2 + rpm_name=$(basename "$rpm") + cp -v "$rpm" "$target/$rpm_name" >&2 +} + get_codename_for_deb() { case "$1" in *ubuntu20.04*) echo "focal" ;; From 760ac27cd9426823b3297bfdf17cbbf8455c544b Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:05:18 -0800 Subject: [PATCH 09/56] fix: updated structure_build_artifact --- .../workflows/deploy-artifacts/entrypoint.sh | 5 ++--- .../deploy-artifacts/package_utils.sh | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index c8e23ee0..018b6d12 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -259,12 +259,11 @@ upload_jar_packages() { pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" - group_path="${group_id//./\/}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload the RPM - run jf rt upload "$jar" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ + run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" \ @@ -273,7 +272,7 @@ upload_jar_packages() { # Upload signature and checksums if they exist if [[ -f "$jar.asc" ]]; then echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 3834f288..081710b1 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -81,22 +81,24 @@ process_jar() { local jar="$1" local dest_dir="$2" local -a metadata - local pkgname version arch dist + local pkgname version group_id group_path # Get metadata using the new function read -r -a metadata < <(get_jar_metadata "$jar") pkgname="${metadata[0]}" version="${metadata[1]}" - - local target="$dest_dir/$dist/$arch" + group_id="${metadata[2]}" + group_path="${group_id//./\/}" + + local target="$dest_dir/$group_path/$pkgname/$version" echo "DEBUG: Creating directory structure:" >&2 - echo " Distribution: $dist" >&2 - echo " Architecture: $arch" >&2 - echo " Target path: $target" >&2 + echo " Group id: $group_id" >&2 + echo " Package name: $pkgname" >&2 + echo " Version: $version" >&2 mkdir -p "$target" - echo "Copying RPM to: $target" >&2 - rpm_name=$(basename "$rpm") - cp -v "$rpm" "$target/$rpm_name" >&2 + echo "Copying JAR to: $target" >&2 + jar_name=$(basename "$jar") + cp -v "$rpm" "$target/$jar_name" >&2 } get_codename_for_deb() { From 4311f4a5ef8ff012a71436353938088d4a616ed1 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:12:22 -0800 Subject: [PATCH 10/56] fix: trying to use specific version of deploy entrypoint.sh script --- .github/workflows/reusable_deploy-artifacts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index 22cbab28..d9c018e7 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -121,7 +121,7 @@ jobs: id: deploy shell: bash run: | - chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh + chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh@760ac27cd9426823b3297bfdf17cbbf8455c544b dry_run_arg="" if [ "${{ inputs.dry-run }}" = "true" ]; then dry_run_arg="--dry-run" From 20b5c89211e060da0e1118bc735bc1e616acf946 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:19:22 -0800 Subject: [PATCH 11/56] fix: added deubug to entrypoint --- .github/workflows/deploy-artifacts/entrypoint.sh | 1 + .github/workflows/reusable_deploy-artifacts.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 018b6d12..c23a4336 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -x set -euo pipefail export PS4='+($LINENO): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' trap 'handle_error ${LINENO}' ERR diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index d9c018e7..22cbab28 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -121,7 +121,7 @@ jobs: id: deploy shell: bash run: | - chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh@760ac27cd9426823b3297bfdf17cbbf8455c544b + chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh dry_run_arg="" if [ "${{ inputs.dry-run }}" = "true" ]; then dry_run_arg="--dry-run" From 52354f739fde07de513266b2060c07b08f0c7a79 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:44:18 -0800 Subject: [PATCH 12/56] fix: typo in package_utils --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 081710b1..e069af9f 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -98,7 +98,7 @@ process_jar() { mkdir -p "$target" echo "Copying JAR to: $target" >&2 jar_name=$(basename "$jar") - cp -v "$rpm" "$target/$jar_name" >&2 + cp -v "$jar" "$target/$jar_name" >&2 } get_codename_for_deb() { From 04dee2faa2f64dd382f1cb05b5dc947b06b1b567 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:59:43 -0800 Subject: [PATCH 13/56] fix: removed deubug --- .github/workflows/deploy-artifacts/entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index c23a4336..be908627 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x set -euo pipefail export PS4='+($LINENO): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' trap 'handle_error ${LINENO}' ERR @@ -164,7 +163,7 @@ structure_build_artifacts() { fi echo "Processing generic file: $generic" >&2 process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" \) -type f -print0) + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -type f -print0) } upload_deb_packages() { @@ -245,6 +244,7 @@ upload_rpm_packages() { } upload_jar_packages() { + if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload JAR packages to JFrog..." >&2 else @@ -263,7 +263,7 @@ upload_jar_packages() { echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 - # Upload the RPM + # Upload the JAR run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ @@ -298,7 +298,7 @@ upload_generic_files() { --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" \) -print0) + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -print0) } From 5a4c970c64b93643f0f1f23623384d40a9f7b318 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 14:18:24 -0800 Subject: [PATCH 14/56] fix: added ability to follow maven deploy artifact layout --- .../deploy-artifacts/package_utils.sh | 19 +++++++++++++++++-- .../workflows/reusable_deploy-artifacts.yaml | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index e069af9f..a330da76 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -96,9 +96,24 @@ process_jar() { echo " Package name: $pkgname" >&2 echo " Version: $version" >&2 mkdir -p "$target" - echo "Copying JAR to: $target" >&2 + + # Get the directory and base name of the jar file + local jar_dir + local jar_name + local base_name + jar_dir=$(dirname "$jar") jar_name=$(basename "$jar") - cp -v "$jar" "$target/$jar_name" >&2 + base_name="${jar_name%.jar}" # Remove .jar extension + + echo "Copying Maven artifacts to: $target" >&2 + + # Copy jar, pom, and asc files + for ext in jar pom jar.asc pom.asc; do + local file="$jar_dir/${base_name}.${ext}" + if [[ -f "$file" ]]; then + cp -v "$file" "$target/" >&2 + fi + done } get_codename_for_deb() { diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index 22cbab28..f6d097d8 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -112,6 +112,7 @@ jobs: with: name: ${{ inputs.gh-artifact-name }} path: ./build-artifacts + - name: Verify artifacts shell: bash run: | From f71bdad6eabe7dd5c93e647fb0ccc09ce9b6371c Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:10:36 -0800 Subject: [PATCH 15/56] fix: added missing files for maven artifacts --- .../workflows/deploy-artifacts/entrypoint.sh | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index be908627..1456a2be 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -246,39 +246,63 @@ upload_rpm_packages() { upload_jar_packages() { if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload JAR packages to JFrog..." >&2 + echo "Would upload JAR/POM packages to JFrog..." >&2 else - echo "Uploading JAR packages to JFrog..." >&2 + echo "Uploading JAR/POM packages to JFrog..." >&2 fi - while IFS= read -r -d '' jar; do - if [[ ! -f "$jar" ]]; then + + # Find all JAR and POM files, then process unique base names + declare -A processed_artifacts + + while IFS= read -r -d '' artifact; do + if [[ ! -f "$artifact" ]]; then + continue + fi + + # Get the directory and base name + local artifact_dir=$(dirname "$artifact") + local artifact_name=$(basename "$artifact") + local base_name="${artifact_name%.jar}" + base_name="${base_name%.pom}" # Remove .pom if it's a standalone pom + + # Skip if we've already processed this base artifact + local artifact_key="$artifact_dir/$base_name" + if [[ -n "${processed_artifacts[$artifact_key]:-}" ]]; then + continue + fi + processed_artifacts[$artifact_key]=1 + + # Determine which file to use for metadata extraction (prefer jar, fallback to pom) + local metadata_file + if [[ -f "$artifact_dir/${base_name}.jar" ]]; then + metadata_file="$artifact_dir/${base_name}.jar" + elif [[ -f "$artifact_dir/${base_name}.pom" ]]; then + metadata_file="$artifact_dir/${base_name}.pom" + else continue fi # Get metadata using the shared function - read -r -a metadata < <(get_jar_metadata "$jar") + read -r -a metadata < <(get_jar_metadata "$metadata_file") pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 - # Upload the JAR - run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" \ - --target-props "group_id=$group_id;package_name=$pkgname;version=$version" - - # Upload signature and checksums if they exist - if [[ -f "$jar.asc" ]]; then - echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . -name "*.jar" -print0) + # Upload all related Maven artifact files (jar, pom, signatures) + for ext in jar pom jar.asc pom.asc; do + local artifact_file="$artifact_dir/${base_name}.${ext}" + if [[ -f "$artifact_file" ]]; then + echo " Uploading $ext: $artifact_file" >&2 + run jf rt upload "$artifact_file" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "group_id=$group_id;package_name=$pkgname;version=$version" + fi + done + done < <(find . \( -name "*.jar" -o -name "*.pom" \) -print0) } upload_generic_files() { From a0fbf516aab60e7da716f63578f9bc59540c3fa0 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:23:08 -0800 Subject: [PATCH 16/56] fix: removed redundant logc --- .../workflows/deploy-artifacts/entrypoint.sh | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 1456a2be..616b0ffd 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -263,7 +263,7 @@ upload_jar_packages() { local artifact_dir=$(dirname "$artifact") local artifact_name=$(basename "$artifact") local base_name="${artifact_name%.jar}" - base_name="${base_name%.pom}" # Remove .pom if it's a standalone pom + base_name="${base_name%.pom}" # Skip if we've already processed this base artifact local artifact_key="$artifact_dir/$base_name" @@ -272,22 +272,26 @@ upload_jar_packages() { fi processed_artifacts[$artifact_key]=1 - # Determine which file to use for metadata extraction (prefer jar, fallback to pom) - local metadata_file - if [[ -f "$artifact_dir/${base_name}.jar" ]]; then - metadata_file="$artifact_dir/${base_name}.jar" - elif [[ -f "$artifact_dir/${base_name}.pom" ]]; then - metadata_file="$artifact_dir/${base_name}.pom" + # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) + local pkgname version group_id + + if [[ -f "$artifact_dir/${base_name}.pom" ]]; then + # Extract metadata from POM (canonical source for Maven metadata) + read -r -a metadata < <(get_pom_metadata "$artifact_dir/${base_name}.pom") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" + elif [[ -f "$artifact_dir/${base_name}.jar" ]]; then + # Fallback: Extract metadata from JAR if no POM exists + read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" else + # No jar or pom found, skip continue fi - # Get metadata using the shared function - read -r -a metadata < <(get_jar_metadata "$metadata_file") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload all related Maven artifact files (jar, pom, signatures) From 66d88b92ebc9cefbdbc6b0afb45b987dadbcaa10 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:28:02 -0800 Subject: [PATCH 17/56] fix: removed call on missing function --- .../workflows/deploy-artifacts/entrypoint.sh | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 616b0ffd..66fa067d 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -244,7 +244,6 @@ upload_rpm_packages() { } upload_jar_packages() { - if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload JAR/POM packages to JFrog..." >&2 else @@ -260,13 +259,13 @@ upload_jar_packages() { fi # Get the directory and base name - local artifact_dir=$(dirname "$artifact") - local artifact_name=$(basename "$artifact") - local base_name="${artifact_name%.jar}" + artifact_dir=$(dirname "$artifact") + artifact_name=$(basename "$artifact") + base_name="${artifact_name%.jar}" base_name="${base_name%.pom}" # Skip if we've already processed this base artifact - local artifact_key="$artifact_dir/$base_name" + artifact_key="$artifact_dir/$base_name" if [[ -n "${processed_artifacts[$artifact_key]:-}" ]]; then continue fi @@ -275,22 +274,11 @@ upload_jar_packages() { # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) local pkgname version group_id - if [[ -f "$artifact_dir/${base_name}.pom" ]]; then - # Extract metadata from POM (canonical source for Maven metadata) - read -r -a metadata < <(get_pom_metadata "$artifact_dir/${base_name}.pom") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - elif [[ -f "$artifact_dir/${base_name}.jar" ]]; then - # Fallback: Extract metadata from JAR if no POM exists - read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - else - # No jar or pom found, skip - continue - fi + # Fallback: Extract metadata from JAR if no POM exists + read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 From d5059c9b7cedfc90db0cd51b8960775ed8afe448 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 08:55:54 -0800 Subject: [PATCH 18/56] Update .github/workflows/deploy-artifacts/package_utils.sh Updated comment to reflect returned values Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index a330da76..2c1afb11 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -24,7 +24,7 @@ get_jar_metadata() { | grep '^groupId=' \ | cut -d= -f2) - # Return package name and version + # Return package name, version, and group_id echo "$pkgname $version $group_id" } From efee88382bbe5029ee902f6d9a790ce53a73bfd1 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:11:40 -0800 Subject: [PATCH 19/56] Update .github/workflows/deploy-artifacts/entrypoint.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 66fa067d..3d89f1ce 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -163,7 +163,7 @@ structure_build_artifacts() { fi echo "Processing generic file: $generic" >&2 process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -type f -print0) + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -type f -print0) } upload_deb_packages() { From 84f92b75f75369f1768901651d3792955053b5de Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:12:15 -0800 Subject: [PATCH 20/56] Update .github/workflows/deploy-artifacts/entrypoint.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 3d89f1ce..e51a0186 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -314,7 +314,7 @@ upload_generic_files() { --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -print0) + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -print0) } From 9e3f2287b82d96d4283e9268d684d7320b2f98f9 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 18 Nov 2025 11:13:50 -0800 Subject: [PATCH 21/56] fix: pr comment fixes --- .../deploy-artifacts/package_utils.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 2c1afb11..fd05c247 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -15,14 +15,22 @@ get_jar_metadata() { local jar="$1" local filename="${jar##*/}" # Get just the filename without path local pkgname version group_id + local pom_props pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') - group_id=$(unzip -Z1 "$jar" \ - | awk '/pom\.properties$/ {print; exit}' \ - | xargs -r -I{} unzip -p "$jar" "{}" \ - | grep '^groupId=' \ - | cut -d= -f2) + + pom_props=$(unzip -Z1 "$jar" | awk '/pom\.properties$/ {print; exit}') + if [[ -n "$pom_props" ]]; then + pkgname=$(unzip -p "$jar" "$pom_props" | grep '^artifactId=' | cut -d= -f2) + version=$(unzip -p "$jar" "$pom_props" | grep '^version=' | cut -d= -f2) + group_id=$(unzip -p "$jar" "$pom_props" | grep '^groupId=' | cut -d= -f2) + else + # Fallback to filename parsing if pom.properties is not found + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z\.\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/.*-([0-9][0-9A-Za-z\.\-]*)\.jar$/\1/') + group_id="" + fi # Return package name, version, and group_id echo "$pkgname $version $group_id" From 6c8016d0eb369af641dd444c5f2d26a05228fd54 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:33:00 -0800 Subject: [PATCH 22/56] Update .github/workflows/deploy-artifacts/package_utils.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index fd05c247..92965e5c 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -96,7 +96,7 @@ process_jar() { pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" - group_path="${group_id//./\/}" + group_path="${group_id:+${group_id//./\/}}" local target="$dest_dir/$group_path/$pkgname/$version" echo "DEBUG: Creating directory structure:" >&2 From 6f190d7038b3c82bf175c10d1be6cf23d03cbc4a Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 18 Nov 2025 14:44:54 -0800 Subject: [PATCH 23/56] fix: addressing how we extract package name and version from jar file name --- .github/workflows/deploy-artifacts/package_utils.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 92965e5c..c5b7f05e 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -17,8 +17,9 @@ get_jar_metadata() { local pkgname version group_id local pom_props - pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') - version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + # Initial parsing - handle versions with SNAPSHOT, SNAPSHOT_, etc. + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z._\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/^[^-]+-([0-9][0-9A-Za-z._\-]*)\.jar$/\1/') pom_props=$(unzip -Z1 "$jar" | awk '/pom\.properties$/ {print; exit}') if [[ -n "$pom_props" ]]; then @@ -27,8 +28,8 @@ get_jar_metadata() { group_id=$(unzip -p "$jar" "$pom_props" | grep '^groupId=' | cut -d= -f2) else # Fallback to filename parsing if pom.properties is not found - pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z\.\-]*\.jar$//') - version=$(echo "$filename" | sed -E 's/.*-([0-9][0-9A-Za-z\.\-]*)\.jar$/\1/') + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z._\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/^[^-]+-([0-9][0-9A-Za-z._\-]*)\.jar$/\1/') group_id="" fi From 1421c04584c38d4cb9ecca9ecd19f89a987311a4 Mon Sep 17 00:00:00 2001 From: Joe Martin Date: Wed, 19 Nov 2025 19:31:37 -0800 Subject: [PATCH 24/56] fix(workflows): use valid files and update tests to expect JAR uploads to maven --- .../deploy-artifacts/create-test-fixtures.sh | 34 +++++++++++++------ .../workflows/deploy-artifacts/entrypoint.sh | 3 +- .../deploy-artifacts/package_utils.sh | 3 +- .../tests/bats/test_all_files_upload.bats | 11 +++--- .../tests/bats/test_java_upload.bats | 13 +++---- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy-artifacts/create-test-fixtures.sh b/.github/workflows/deploy-artifacts/create-test-fixtures.sh index fd49973f..12cfb082 100755 --- a/.github/workflows/deploy-artifacts/create-test-fixtures.sh +++ b/.github/workflows/deploy-artifacts/create-test-fixtures.sh @@ -18,24 +18,36 @@ if [[ -f "tests/nano-tiny_8.4-1_arm64.deb" ]]; then cp "tests/nano-tiny_8.4-1_arm64.deb" "$BUILD_ARTIFACTS_DIR/test-ubuntu22.04.deb" echo " Copied nano-tiny_8.4-1_arm64.deb as test-ubuntu22.04.deb" else - echo " nano-tiny_8.4-1_arm64.deb not found, creating mock" - echo "test-deb-content" > "$BUILD_ARTIFACTS_DIR/test-ubuntu22.04.deb" + echo "Error: tests/nano-tiny_8.4-1_arm64.deb not found. Cannot create mock DEB file." >&2 + exit 1 fi if [[ -f "tests/test-1.0-2.noarch.rpm" ]]; then cp "tests/test-1.0-2.noarch.rpm" "$BUILD_ARTIFACTS_DIR/" echo " Copied test-1.0-2.noarch.rpm" else - echo " test-1.0-2.noarch.rpm not found, creating mock" - echo "test-rpm-content" > "$BUILD_ARTIFACTS_DIR/test-1.0-2.noarch.rpm" + echo "Error: tests/test-1.0-2.noarch.rpm not found. Cannot create mock RPM file." >&2 + exit 1 fi cp -v tests/some/structure/Aerospike.Client.8.0.2.nupkg "$BUILD_ARTIFACTS_DIR/Aerospike.Client.8.0.2.nupkg" -# Create some additional test files -echo "test jar content" > "$BUILD_ARTIFACTS_DIR/test.jar" -echo "test zip content" > "$BUILD_ARTIFACTS_DIR/test.zip" -echo "test tar content" > "$BUILD_ARTIFACTS_DIR/test.tar.gz" +# Create some additional test files with valid formats +# Create a valid JAR file (JAR is a ZIP with META-INF/MANIFEST.MF) +mkdir -p "$BUILD_ARTIFACTS_DIR/temp-jar/META-INF" +echo "Manifest-Version: 1.0" > "$BUILD_ARTIFACTS_DIR/temp-jar/META-INF/MANIFEST.MF" +cd "$BUILD_ARTIFACTS_DIR/temp-jar" && zip -q -r "../test.jar" . && cd - > /dev/null +rm -rf "$BUILD_ARTIFACTS_DIR/temp-jar" + +# Create a valid ZIP file +echo "test zip content" > "$BUILD_ARTIFACTS_DIR/temp-zip-content.txt" +cd "$BUILD_ARTIFACTS_DIR" && zip -q "test.zip" "temp-zip-content.txt" && cd - > /dev/null +rm -f "$BUILD_ARTIFACTS_DIR/temp-zip-content.txt" + +# Create a valid TAR.GZ file +echo "test tar content" > "$BUILD_ARTIFACTS_DIR/temp-tar-content.txt" +cd "$BUILD_ARTIFACTS_DIR" && tar -czf "test.tar.gz" "temp-tar-content.txt" && cd - > /dev/null +rm -f "$BUILD_ARTIFACTS_DIR/temp-tar-content.txt" mkdir -p "$BUILD_ARTIFACTS_DIR/nested/dir" echo "test-nested-dir-content" > "$BUILD_ARTIFACTS_DIR/nested/dir/test-nested-dir.txt" @@ -45,13 +57,15 @@ if [[ -f "tests/nano-tiny_8.4-1_arm64.deb" ]]; then cp "tests/nano-tiny_8.4-1_arm64.deb" "$BUILD_ARTIFACTS_DIR/nested/dir/test-debian12.deb" echo " Copied nano-tiny_8.4-1_arm64.deb as nested test-debian12.deb" else - echo "test-nested-deb-content" > "$BUILD_ARTIFACTS_DIR/nested/dir/test-debian12.deb" + echo "Error: tests/nano-tiny_8.4-1_arm64.deb not found. Cannot create nested mock DEB file." >&2 + exit 1 fi if [[ -f "tests/test-1.0-2.noarch.rpm" ]]; then cp "tests/test-1.0-2.noarch.rpm" "$BUILD_ARTIFACTS_DIR/nested/dir/nested.rpm" echo " Copied test-1.0-2.noarch.rpm as nested.rpm" else - echo "test-nested-rpm-content" > "$BUILD_ARTIFACTS_DIR/nested/dir/nested.rpm" + echo "Error: tests/test-1.0-2.noarch.rpm not found. Cannot create nested mock RPM file." >&2 + exit 1 fi echo "Test files created:" diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index ba6d7f3d..86f9c506 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -279,7 +279,8 @@ upload_jar_packages() { read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") pkgname="${metadata[0]}" version="${metadata[1]}" - group_id="${metadata[2]}" + # group might be empty if this is a simple jar file Use :- to handle empty group_id + group_id="${metadata[2]:-}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 0dc89e45..fdaec93e 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -96,7 +96,8 @@ process_jar() { read -r -a metadata < <(get_jar_metadata "$jar") pkgname="${metadata[0]}" version="${metadata[1]}" - group_id="${metadata[2]}" + # Use :- to handle empty group_id (when array may only have 2 elements due to trailing space trimming) + group_id="${metadata[2]:-}" group_path="${group_id:+${group_id//./\/}}" local target="$dest_dir/$group_path/$pkgname/$version" diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats index 1ba50e15..b9a9e67a 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats @@ -12,7 +12,7 @@ load "$HELPERS_DIR/assertions.bash" setup_file() { setup_test_artifacts - # Verify expected generic file fixtures exist + # Verify expected file fixtures exist (JAR as Maven artifact, ZIP and TAR.GZ as generic) local -a expected_files=( "$BUILD_ARTIFACTS_DIR/test.jar" "$BUILD_ARTIFACTS_DIR/test.zip" @@ -56,16 +56,17 @@ teardown_file() { # Parse commands into arrays mapfile -t upload_cmd_array < <(echo "$upload_commands") - # Validate generic file uploads (JAR, ZIP, TAR.GZ) + # Validate file uploads (JAR as Maven, ZIP and TAR.GZ as generic) local jar_found=false local zip_found=false local tar_found=false for cmd in "${upload_cmd_array[@]}"; do - # Check for JAR file + # Check for JAR file (should be uploaded as Maven artifact) if [[ $cmd =~ test\.jar ]]; then jar_found=true - assert_upload_command_valid "$cmd" "test.jar" "test-project-generic-dev-local" "" \ + assert_upload_command_valid "$cmd" "test.jar" "test-project-maven-dev-local" \ + "group_id=;package_name=test.jar;version=test.jar" \ "test-build" "12345-artifacts" "test-project" fi @@ -84,7 +85,7 @@ teardown_file() { fi done - # Verify generic files were found + # Verify files were found [[ $jar_found == true ]] || (echo "JAR file upload not found" >&2 && return 1) [[ $zip_found == true ]] || (echo "ZIP file upload not found" >&2 && return 1) [[ $tar_found == true ]] || (echo "TAR.GZ file upload not found" >&2 && return 1) diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats index a621d37f..9e282383 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats @@ -64,8 +64,8 @@ teardown_file() { if [[ $cmd =~ \.jar ]]; then jar_found=true - # Java artifacts go to generic repo - local expected_repo="test-project-generic-dev-local" + # Java artifacts go to Maven repo + local expected_repo="test-project-maven-dev-local" # Extract filename from command local filename @@ -73,8 +73,9 @@ teardown_file() { filename="${BASH_REMATCH[1]}" fi - # Validate command structure - assert_upload_command_valid "$cmd" "$filename" "$expected_repo" "" \ + # Validate command structure with Maven target-props + assert_upload_command_valid "$cmd" "$filename" "$expected_repo" \ + "group_id=;package_name=test.jar;version=test.jar" \ "test-build" "12345-artifacts" "test-project" fi done @@ -106,8 +107,8 @@ teardown_file() { local output output=$(run_entrypoint_dry_run "test-project" "test-build" "v1.0.0" "12345" "12345-metadata") - # Verify "Processing generic file:" messages appear for JAR files - [[ $output == *"Processing generic file:"* ]] || (echo "Generic file processing messages not found" >&2 && return 1) + # Verify "Processing JAR:" messages appear for JAR files + [[ $output == *"Processing JAR:"* ]] || (echo "JAR processing messages not found" >&2 && return 1) # Extract upload commands and verify JAR is present local upload_commands From 709a7ef6385ea54199382023a79605b8ff1cb29a Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 11 Nov 2025 17:09:35 -0800 Subject: [PATCH 25/56] feat: adding maven support --- .github/actions/extract-version-from-tag/action.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/extract-version-from-tag/action.yaml b/.github/actions/extract-version-from-tag/action.yaml index 56d26d5f..0d0b8a67 100644 --- a/.github/actions/extract-version-from-tag/action.yaml +++ b/.github/actions/extract-version-from-tag/action.yaml @@ -28,8 +28,15 @@ runs: run: | # Priority order: VERSION file -> Git tag if [[ -f "${{ inputs.version-file }}" ]]; then - # Use VERSION file - TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) + # Check if it's a pom.xml file + if [[ "${{ inputs.version-file }}" == *"pom.xml" ]]; then + # Extract version from pom.xml (project version, not dependencies) + # Get the first tag which is typically the project version + TAG=$(grep -m 1 "" "${{ inputs.version-file }}" | sed 's/.*\(.*\)<\/version>.*/\1/' | tr -d '\n\r' | xargs) + else + # Use VERSION file + TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) + fi SOURCE="file" elif [[ "${{ github.ref }}" == refs/tags/* ]]; then # Triggered by tag push From 9bd158b204a4b8d87415ec7bd46ad3f448e2e305 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Wed, 12 Nov 2025 22:03:20 -0800 Subject: [PATCH 26/56] ci: added java and maven support to execute build --- .github/workflows/reusable_execute-build.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/reusable_execute-build.yaml b/.github/workflows/reusable_execute-build.yaml index ff91225f..676fbab2 100644 --- a/.github/workflows/reusable_execute-build.yaml +++ b/.github/workflows/reusable_execute-build.yaml @@ -102,6 +102,28 @@ on: type: string default: . + # Java/Maven setup + setup-java: + description: Whether to set up Java environment + required: false + type: boolean + default: false + java-version: + description: Java version to set up (e.g., "17", "21") + required: false + type: string + default: "21" + java-distribution: + description: Java distribution (temurin, zulu, adopt, corretto, etc.) + required: false + type: string + default: temurin + java-cache: + description: Package manager to cache (maven, gradle, sbt). Leave empty for no cache. + required: false + type: string + default: maven + outputs: gh-artifact-name: description: The name of the uploaded artifacts on github @@ -146,6 +168,14 @@ jobs: submodules: recursive fetch-depth: 1 + - name: Set up Java + if: inputs.setup-java + uses: actions/setup-java@v4 + with: + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + cache: ${{ inputs.java-cache }} + - name: Set up JFrog CLI uses: jfrog/setup-jfrog-cli@5b06f730cc5a6f55d78b30753f8583454b08c0aa # v4.8.1 env: From b875b6ebc469d3fd89f96543dab92ad692d4348e Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Thu, 13 Nov 2025 10:26:05 -0800 Subject: [PATCH 27/56] fix: removed changes for pom version handling --- .github/actions/extract-version-from-tag/action.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/actions/extract-version-from-tag/action.yaml b/.github/actions/extract-version-from-tag/action.yaml index 0d0b8a67..56d26d5f 100644 --- a/.github/actions/extract-version-from-tag/action.yaml +++ b/.github/actions/extract-version-from-tag/action.yaml @@ -28,15 +28,8 @@ runs: run: | # Priority order: VERSION file -> Git tag if [[ -f "${{ inputs.version-file }}" ]]; then - # Check if it's a pom.xml file - if [[ "${{ inputs.version-file }}" == *"pom.xml" ]]; then - # Extract version from pom.xml (project version, not dependencies) - # Get the first tag which is typically the project version - TAG=$(grep -m 1 "" "${{ inputs.version-file }}" | sed 's/.*\(.*\)<\/version>.*/\1/' | tr -d '\n\r' | xargs) - else - # Use VERSION file - TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) - fi + # Use VERSION file + TAG=$(cat "${{ inputs.version-file }}" | tr -d '\n\r' | xargs) SOURCE="file" elif [[ "${{ github.ref }}" == refs/tags/* ]]; then # Triggered by tag push From 0c29d16d34ea65748892107e72ade6bc1d7084d0 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Thu, 13 Nov 2025 10:30:21 -0800 Subject: [PATCH 28/56] fix: fix comment on input variable --- .github/workflows/reusable_execute-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_execute-build.yaml b/.github/workflows/reusable_execute-build.yaml index 676fbab2..e9e8ebba 100644 --- a/.github/workflows/reusable_execute-build.yaml +++ b/.github/workflows/reusable_execute-build.yaml @@ -119,7 +119,7 @@ on: type: string default: temurin java-cache: - description: Package manager to cache (maven, gradle, sbt). Leave empty for no cache. + description: Package manager to cache (maven, gradle, sbt). required: false type: string default: maven From abdd11dc6d7033ed2105e491c86d54a31533c3e4 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 15:42:01 -0800 Subject: [PATCH 29/56] fix: added support for jar files --- .../workflows/deploy-artifacts/entrypoint.sh | 36 +++++++++++++++++++ .../deploy-artifacts/package_utils.sh | 13 +++++++ 2 files changed, 49 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 07b36286..ff2881f4 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -243,6 +243,42 @@ upload_rpm_packages() { done < <(find . -name "*.rpm" -print0) } +upload_jar_packages() { + if [[ "$DRY_RUN" == "true" ]]; then + echo "Would upload JAR packages to JFrog..." >&2 + else + echo "Uploading JAR packages to JFrog..." >&2 + fi + while IFS= read -r -d '' jar; do + if [[ ! -f "$jar" ]]; then + continue + fi + + # Get metadata using the shared function + read -r -a metadata < <(get_jar_metadata "$jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + + echo " Package: $pkgname, Version: $version" >&2 + + # Upload the RPM + run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "version=$VERSION" + + # Upload signature and checksums if they exist + if [[ -f "$jar.asc" ]]; then + echo " Uploading signature: $jar.asc" >&2 + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.jar" -print0) +} + upload_generic_files() { if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload generic files..." >&2 diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 571b1305..98b360f9 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -10,6 +10,19 @@ handle_error() { exit 1 } +# Function to extract JAR metadata +get_jar_metadata() { + local jar="$1" + local filename="${jar##*/}" # Get just the filename without path + local pkgname version + + pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') + version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + + # Return package name and version + echo "$pkgname $version" +} + # Function to extract RPM metadata and distribution # Unlike for debs this requires parsing the name (because the distro name is not standard) get_rpm_metadata() { From 4d2ad1056e7e6e83cf897bed0bc440aa2c3074a3 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 15:51:05 -0800 Subject: [PATCH 30/56] fix: fix to finvoke jar package handling in entrypoint.sh --- .github/workflows/deploy-artifacts/entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index ff2881f4..a0fbda68 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -398,6 +398,9 @@ main() { cd deb upload_deb_packages cd .. + cd jar + upload_jar_packages + cd .. cd generic upload_generic_files cd .. From 3d1b50c4eef29f6ca407ec1565374cddaf66cfdc Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 22:01:48 -0800 Subject: [PATCH 31/56] fix: added missing logic for jar files --- .github/workflows/deploy-artifacts/entrypoint.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index a0fbda68..db5186fd 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -125,6 +125,7 @@ structure_build_artifacts() { echo "current files: $(ls -la build-artifacts)" >&2 mkdir -p structured_build_artifacts/deb mkdir -p structured_build_artifacts/rpm + mkdir -p structured_build_artifacts/jar mkdir -p structured_build_artifacts/nupkg mkdir -p structured_build_artifacts/generic while IFS= read -r -d '' deb; do @@ -146,6 +147,16 @@ structure_build_artifacts() { done < <(find build-artifacts -name "*.rpm" -print0) echo "current files: $(ls -la build-artifacts)" >&2 + while IFS= read -r -d '' jar; do + if [[ ! -f "$jar" ]]; then + continue + fi + + echo "Processing JAR: $jar" >&2 + process_rpm "$jar" "./structured_build_artifacts/jar" + done < <(find build-artifacts -name "*.jar" -print0) + echo "current files: $(ls -la build-artifacts)" >&2 + while IFS= read -r -d '' nupkg; do if [[ ! -f "$nupkg" ]]; then continue From 624d7f1f27f1aaee56340ad64a8c394582885c34 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 14 Nov 2025 23:18:57 -0800 Subject: [PATCH 32/56] fix: fixed pathing for maven --- .../workflows/deploy-artifacts/entrypoint.sh | 12 ++++--- .../deploy-artifacts/package_utils.sh | 31 +++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index db5186fd..0b504bb1 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -153,7 +153,7 @@ structure_build_artifacts() { fi echo "Processing JAR: $jar" >&2 - process_rpm "$jar" "./structured_build_artifacts/jar" + process_jar "$jar" "./structured_build_artifacts/jar" done < <(find build-artifacts -name "*.jar" -print0) echo "current files: $(ls -la build-artifacts)" >&2 @@ -269,20 +269,22 @@ upload_jar_packages() { read -r -a metadata < <(get_jar_metadata "$jar") pkgname="${metadata[0]}" version="${metadata[1]}" + group_id="${metadata[2]}" + group_path="${group_id//./\/}" - echo " Package: $pkgname, Version: $version" >&2 + echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload the RPM - run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ + run jf rt upload "$jar" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" \ - --target-props "version=$VERSION" + --target-props "group_id=$group_id;package_name=$pkgname;version=$version" # Upload signature and checksums if they exist if [[ -f "$jar.asc" ]]; then echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 98b360f9..aa5fdaa1 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -14,13 +14,18 @@ handle_error() { get_jar_metadata() { local jar="$1" local filename="${jar##*/}" # Get just the filename without path - local pkgname version + local pkgname version group_id pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + group_id=$(unzip -Z1 "$jar" \ + | awk '/pom\.properties$/ {print; exit}' \ + | xargs -r -I{} unzip -p "$jar" "{}" \ + | grep '^groupId=' \ + | cut -d= -f2) # Return package name and version - echo "$pkgname $version" + echo "$pkgname $version $group_id" } # Function to extract RPM metadata and distribution @@ -72,6 +77,28 @@ process_rpm() { cp -v "$rpm" "$target/$rpm_name" >&2 } +process_jar() { + local jar="$1" + local dest_dir="$2" + local -a metadata + local pkgname version arch dist + + # Get metadata using the new function + read -r -a metadata < <(get_jar_metadata "$jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + + local target="$dest_dir/$dist/$arch" + echo "DEBUG: Creating directory structure:" >&2 + echo " Distribution: $dist" >&2 + echo " Architecture: $arch" >&2 + echo " Target path: $target" >&2 + mkdir -p "$target" + echo "Copying RPM to: $target" >&2 + rpm_name=$(basename "$rpm") + cp -v "$rpm" "$target/$rpm_name" >&2 +} + get_codename_for_deb() { case "$1" in *ubuntu20.04*) echo "focal" ;; From f1b077dfa2e444a822b254928e272947ccf4b0d3 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:05:18 -0800 Subject: [PATCH 33/56] fix: updated structure_build_artifact --- .../workflows/deploy-artifacts/entrypoint.sh | 5 ++--- .../deploy-artifacts/package_utils.sh | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 0b504bb1..02ab378b 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -270,12 +270,11 @@ upload_jar_packages() { pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" - group_path="${group_id//./\/}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload the RPM - run jf rt upload "$jar" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ + run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" \ @@ -284,7 +283,7 @@ upload_jar_packages() { # Upload signature and checksums if they exist if [[ -f "$jar.asc" ]]; then echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local/$group_path/$pkgname/$version" --flat=false \ + run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index aa5fdaa1..d4be61e0 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -81,22 +81,24 @@ process_jar() { local jar="$1" local dest_dir="$2" local -a metadata - local pkgname version arch dist + local pkgname version group_id group_path # Get metadata using the new function read -r -a metadata < <(get_jar_metadata "$jar") pkgname="${metadata[0]}" version="${metadata[1]}" - - local target="$dest_dir/$dist/$arch" + group_id="${metadata[2]}" + group_path="${group_id//./\/}" + + local target="$dest_dir/$group_path/$pkgname/$version" echo "DEBUG: Creating directory structure:" >&2 - echo " Distribution: $dist" >&2 - echo " Architecture: $arch" >&2 - echo " Target path: $target" >&2 + echo " Group id: $group_id" >&2 + echo " Package name: $pkgname" >&2 + echo " Version: $version" >&2 mkdir -p "$target" - echo "Copying RPM to: $target" >&2 - rpm_name=$(basename "$rpm") - cp -v "$rpm" "$target/$rpm_name" >&2 + echo "Copying JAR to: $target" >&2 + jar_name=$(basename "$jar") + cp -v "$rpm" "$target/$jar_name" >&2 } get_codename_for_deb() { From 3179674262aa619e70314b48cacdf45d96b9c221 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:12:22 -0800 Subject: [PATCH 34/56] fix: trying to use specific version of deploy entrypoint.sh script --- .github/workflows/reusable_deploy-artifacts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index 1d0e08d2..4bcfc863 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -121,7 +121,7 @@ jobs: id: deploy shell: bash run: | - chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh + chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh@760ac27cd9426823b3297bfdf17cbbf8455c544b dry_run_arg="" if [ "${{ inputs.dry-run }}" = "true" ]; then dry_run_arg="--dry-run" From 563b9bdaafab3f396d6436460567b71069fc9916 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:19:22 -0800 Subject: [PATCH 35/56] fix: added deubug to entrypoint --- .github/workflows/deploy-artifacts/entrypoint.sh | 1 + .github/workflows/reusable_deploy-artifacts.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 02ab378b..62200056 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -x set -euo pipefail export PS4='+($LINENO): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' trap 'handle_error ${LINENO}' ERR diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index 4bcfc863..1d0e08d2 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -121,7 +121,7 @@ jobs: id: deploy shell: bash run: | - chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh@760ac27cd9426823b3297bfdf17cbbf8455c544b + chmod +x ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh dry_run_arg="" if [ "${{ inputs.dry-run }}" = "true" ]; then dry_run_arg="--dry-run" From 5036858998a2c23983423ea7fa1a5f8e2bcde934 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:44:18 -0800 Subject: [PATCH 36/56] fix: typo in package_utils --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index d4be61e0..81cd2cf2 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -98,7 +98,7 @@ process_jar() { mkdir -p "$target" echo "Copying JAR to: $target" >&2 jar_name=$(basename "$jar") - cp -v "$rpm" "$target/$jar_name" >&2 + cp -v "$jar" "$target/$jar_name" >&2 } get_codename_for_deb() { From 92da7a985127a1ab3375a6390c28d508c818dd12 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 11:59:43 -0800 Subject: [PATCH 37/56] fix: removed deubug --- .github/workflows/deploy-artifacts/entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 62200056..88f09f8d 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x set -euo pipefail export PS4='+($LINENO): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' trap 'handle_error ${LINENO}' ERR @@ -175,7 +174,7 @@ structure_build_artifacts() { fi echo "Processing generic file: $generic" >&2 process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" \) -type f -print0) + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -type f -print0) } upload_deb_packages() { @@ -256,6 +255,7 @@ upload_rpm_packages() { } upload_jar_packages() { + if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload JAR packages to JFrog..." >&2 else @@ -274,7 +274,7 @@ upload_jar_packages() { echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 - # Upload the RPM + # Upload the JAR run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ @@ -309,7 +309,7 @@ upload_generic_files() { --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" \) -print0) + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -print0) } From 34fc2f872921f81b39ae25c7fcf9d7363acbbf65 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 14:18:24 -0800 Subject: [PATCH 38/56] fix: added ability to follow maven deploy artifact layout --- .../deploy-artifacts/package_utils.sh | 19 +++++++++++++++++-- .../workflows/reusable_deploy-artifacts.yaml | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 81cd2cf2..e0087609 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -96,9 +96,24 @@ process_jar() { echo " Package name: $pkgname" >&2 echo " Version: $version" >&2 mkdir -p "$target" - echo "Copying JAR to: $target" >&2 + + # Get the directory and base name of the jar file + local jar_dir + local jar_name + local base_name + jar_dir=$(dirname "$jar") jar_name=$(basename "$jar") - cp -v "$jar" "$target/$jar_name" >&2 + base_name="${jar_name%.jar}" # Remove .jar extension + + echo "Copying Maven artifacts to: $target" >&2 + + # Copy jar, pom, and asc files + for ext in jar pom jar.asc pom.asc; do + local file="$jar_dir/${base_name}.${ext}" + if [[ -f "$file" ]]; then + cp -v "$file" "$target/" >&2 + fi + done } get_codename_for_deb() { diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index 1d0e08d2..d3adb86f 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -112,6 +112,7 @@ jobs: with: name: ${{ inputs.gh-artifact-name }} path: ./build-artifacts + - name: Verify artifacts shell: bash run: | From cac6281b6f7579837c13d06566a5e5401e892bf3 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:10:36 -0800 Subject: [PATCH 39/56] fix: added missing files for maven artifacts --- .../workflows/deploy-artifacts/entrypoint.sh | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 88f09f8d..2ebeaff5 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -257,39 +257,63 @@ upload_rpm_packages() { upload_jar_packages() { if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload JAR packages to JFrog..." >&2 + echo "Would upload JAR/POM packages to JFrog..." >&2 else - echo "Uploading JAR packages to JFrog..." >&2 + echo "Uploading JAR/POM packages to JFrog..." >&2 fi - while IFS= read -r -d '' jar; do - if [[ ! -f "$jar" ]]; then + + # Find all JAR and POM files, then process unique base names + declare -A processed_artifacts + + while IFS= read -r -d '' artifact; do + if [[ ! -f "$artifact" ]]; then + continue + fi + + # Get the directory and base name + local artifact_dir=$(dirname "$artifact") + local artifact_name=$(basename "$artifact") + local base_name="${artifact_name%.jar}" + base_name="${base_name%.pom}" # Remove .pom if it's a standalone pom + + # Skip if we've already processed this base artifact + local artifact_key="$artifact_dir/$base_name" + if [[ -n "${processed_artifacts[$artifact_key]:-}" ]]; then + continue + fi + processed_artifacts[$artifact_key]=1 + + # Determine which file to use for metadata extraction (prefer jar, fallback to pom) + local metadata_file + if [[ -f "$artifact_dir/${base_name}.jar" ]]; then + metadata_file="$artifact_dir/${base_name}.jar" + elif [[ -f "$artifact_dir/${base_name}.pom" ]]; then + metadata_file="$artifact_dir/${base_name}.pom" + else continue fi # Get metadata using the shared function - read -r -a metadata < <(get_jar_metadata "$jar") + read -r -a metadata < <(get_jar_metadata "$metadata_file") pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 - # Upload the JAR - run jf rt upload "$jar" "$PROJECT-maven-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" \ - --target-props "group_id=$group_id;package_name=$pkgname;version=$version" - - # Upload signature and checksums if they exist - if [[ -f "$jar.asc" ]]; then - echo " Uploading signature: $jar.asc" >&2 - run jf rt upload "$jar.asc" "$PROJECT-maven-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . -name "*.jar" -print0) + # Upload all related Maven artifact files (jar, pom, signatures) + for ext in jar pom jar.asc pom.asc; do + local artifact_file="$artifact_dir/${base_name}.${ext}" + if [[ -f "$artifact_file" ]]; then + echo " Uploading $ext: $artifact_file" >&2 + run jf rt upload "$artifact_file" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "group_id=$group_id;package_name=$pkgname;version=$version" + fi + done + done < <(find . \( -name "*.jar" -o -name "*.pom" \) -print0) } upload_generic_files() { From 59c4e69a7076975f2b4b8052ce37e9e7871a8466 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:23:08 -0800 Subject: [PATCH 40/56] fix: removed redundant logc --- .../workflows/deploy-artifacts/entrypoint.sh | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 2ebeaff5..316e59a0 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -274,7 +274,7 @@ upload_jar_packages() { local artifact_dir=$(dirname "$artifact") local artifact_name=$(basename "$artifact") local base_name="${artifact_name%.jar}" - base_name="${base_name%.pom}" # Remove .pom if it's a standalone pom + base_name="${base_name%.pom}" # Skip if we've already processed this base artifact local artifact_key="$artifact_dir/$base_name" @@ -283,22 +283,26 @@ upload_jar_packages() { fi processed_artifacts[$artifact_key]=1 - # Determine which file to use for metadata extraction (prefer jar, fallback to pom) - local metadata_file - if [[ -f "$artifact_dir/${base_name}.jar" ]]; then - metadata_file="$artifact_dir/${base_name}.jar" - elif [[ -f "$artifact_dir/${base_name}.pom" ]]; then - metadata_file="$artifact_dir/${base_name}.pom" + # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) + local pkgname version group_id + + if [[ -f "$artifact_dir/${base_name}.pom" ]]; then + # Extract metadata from POM (canonical source for Maven metadata) + read -r -a metadata < <(get_pom_metadata "$artifact_dir/${base_name}.pom") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" + elif [[ -f "$artifact_dir/${base_name}.jar" ]]; then + # Fallback: Extract metadata from JAR if no POM exists + read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" else + # No jar or pom found, skip continue fi - # Get metadata using the shared function - read -r -a metadata < <(get_jar_metadata "$metadata_file") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 # Upload all related Maven artifact files (jar, pom, signatures) From 45e04729ca08762bd9d1c1b04c0c4079964aff2e Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Sat, 15 Nov 2025 15:28:02 -0800 Subject: [PATCH 41/56] fix: removed call on missing function --- .../workflows/deploy-artifacts/entrypoint.sh | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 316e59a0..cd7af1f2 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -255,7 +255,6 @@ upload_rpm_packages() { } upload_jar_packages() { - if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload JAR/POM packages to JFrog..." >&2 else @@ -271,13 +270,13 @@ upload_jar_packages() { fi # Get the directory and base name - local artifact_dir=$(dirname "$artifact") - local artifact_name=$(basename "$artifact") - local base_name="${artifact_name%.jar}" + artifact_dir=$(dirname "$artifact") + artifact_name=$(basename "$artifact") + base_name="${artifact_name%.jar}" base_name="${base_name%.pom}" # Skip if we've already processed this base artifact - local artifact_key="$artifact_dir/$base_name" + artifact_key="$artifact_dir/$base_name" if [[ -n "${processed_artifacts[$artifact_key]:-}" ]]; then continue fi @@ -286,22 +285,11 @@ upload_jar_packages() { # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) local pkgname version group_id - if [[ -f "$artifact_dir/${base_name}.pom" ]]; then - # Extract metadata from POM (canonical source for Maven metadata) - read -r -a metadata < <(get_pom_metadata "$artifact_dir/${base_name}.pom") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - elif [[ -f "$artifact_dir/${base_name}.jar" ]]; then - # Fallback: Extract metadata from JAR if no POM exists - read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") - pkgname="${metadata[0]}" - version="${metadata[1]}" - group_id="${metadata[2]}" - else - # No jar or pom found, skip - continue - fi + # Fallback: Extract metadata from JAR if no POM exists + read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + group_id="${metadata[2]}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 From bd3e412a988eacccfdb626b35819dfa93f1545c6 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 08:55:54 -0800 Subject: [PATCH 42/56] Update .github/workflows/deploy-artifacts/package_utils.sh Updated comment to reflect returned values Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index e0087609..c4c129a0 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -24,7 +24,7 @@ get_jar_metadata() { | grep '^groupId=' \ | cut -d= -f2) - # Return package name and version + # Return package name, version, and group_id echo "$pkgname $version $group_id" } From 1ab3a660c80ce764e0ac2e47250270558412d577 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:11:40 -0800 Subject: [PATCH 43/56] Update .github/workflows/deploy-artifacts/entrypoint.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index cd7af1f2..3bd913e1 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -174,7 +174,7 @@ structure_build_artifacts() { fi echo "Processing generic file: $generic" >&2 process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -type f -print0) + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -type f -print0) } upload_deb_packages() { From 47ccd659f443ac92d59ed69d736ebb0ab6b2059e Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:12:15 -0800 Subject: [PATCH 44/56] Update .github/workflows/deploy-artifacts/entrypoint.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 3bd913e1..2b301fd7 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -325,7 +325,7 @@ upload_generic_files() { --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" \) -print0) + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -print0) } From 87567de2ab5f1e2012d05936cc43c06e5af7f92e Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 18 Nov 2025 11:13:50 -0800 Subject: [PATCH 45/56] fix: pr comment fixes --- .../deploy-artifacts/package_utils.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index c4c129a0..61eccc2a 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -15,14 +15,22 @@ get_jar_metadata() { local jar="$1" local filename="${jar##*/}" # Get just the filename without path local pkgname version group_id + local pom_props pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') - group_id=$(unzip -Z1 "$jar" \ - | awk '/pom\.properties$/ {print; exit}' \ - | xargs -r -I{} unzip -p "$jar" "{}" \ - | grep '^groupId=' \ - | cut -d= -f2) + + pom_props=$(unzip -Z1 "$jar" | awk '/pom\.properties$/ {print; exit}') + if [[ -n "$pom_props" ]]; then + pkgname=$(unzip -p "$jar" "$pom_props" | grep '^artifactId=' | cut -d= -f2) + version=$(unzip -p "$jar" "$pom_props" | grep '^version=' | cut -d= -f2) + group_id=$(unzip -p "$jar" "$pom_props" | grep '^groupId=' | cut -d= -f2) + else + # Fallback to filename parsing if pom.properties is not found + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z\.\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/.*-([0-9][0-9A-Za-z\.\-]*)\.jar$/\1/') + group_id="" + fi # Return package name, version, and group_id echo "$pkgname $version $group_id" From 474e88a16b4c0cd17c5d9c8033b2fc933a6a2312 Mon Sep 17 00:00:00 2001 From: Mirza Karacic <97757567+mirzakaracic@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:33:00 -0800 Subject: [PATCH 46/56] Update .github/workflows/deploy-artifacts/package_utils.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/package_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 61eccc2a..103bb3d1 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -96,7 +96,7 @@ process_jar() { pkgname="${metadata[0]}" version="${metadata[1]}" group_id="${metadata[2]}" - group_path="${group_id//./\/}" + group_path="${group_id:+${group_id//./\/}}" local target="$dest_dir/$group_path/$pkgname/$version" echo "DEBUG: Creating directory structure:" >&2 From 47736d91f59076b7167ca0e1dad5e739cdfc80ed Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Tue, 18 Nov 2025 14:44:54 -0800 Subject: [PATCH 47/56] fix: addressing how we extract package name and version from jar file name --- .github/workflows/deploy-artifacts/package_utils.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-artifacts/package_utils.sh b/.github/workflows/deploy-artifacts/package_utils.sh index 103bb3d1..0dc89e45 100755 --- a/.github/workflows/deploy-artifacts/package_utils.sh +++ b/.github/workflows/deploy-artifacts/package_utils.sh @@ -17,8 +17,9 @@ get_jar_metadata() { local pkgname version group_id local pom_props - pkgname=$(echo "$filename" | sed 's/-[0-9.]*\.jar$//') - version=$(echo "$filename" | sed 's/.*-//' | sed 's/\.jar$//') + # Initial parsing - handle versions with SNAPSHOT, SNAPSHOT_, etc. + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z._\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/^[^-]+-([0-9][0-9A-Za-z._\-]*)\.jar$/\1/') pom_props=$(unzip -Z1 "$jar" | awk '/pom\.properties$/ {print; exit}') if [[ -n "$pom_props" ]]; then @@ -27,8 +28,8 @@ get_jar_metadata() { group_id=$(unzip -p "$jar" "$pom_props" | grep '^groupId=' | cut -d= -f2) else # Fallback to filename parsing if pom.properties is not found - pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z\.\-]*\.jar$//') - version=$(echo "$filename" | sed -E 's/.*-([0-9][0-9A-Za-z\.\-]*)\.jar$/\1/') + pkgname=$(echo "$filename" | sed -E 's/-[0-9][0-9A-Za-z._\-]*\.jar$//') + version=$(echo "$filename" | sed -E 's/^[^-]+-([0-9][0-9A-Za-z._\-]*)\.jar$/\1/') group_id="" fi From a640455acff69612185a4b35abdc1d9992014b8d Mon Sep 17 00:00:00 2001 From: Joe Martin Date: Thu, 20 Nov 2025 22:06:56 -0800 Subject: [PATCH 48/56] fix: update fixtures and adjust to allow processing nuget --- .../workflows/deploy-artifacts/entrypoint.sh | 49 +++++++++++++++---- .../tests/bats/test_nupkg_upload.bats | 5 +- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 0b8df2a4..bea4bf46 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -122,7 +122,6 @@ run_optional() { structure_build_artifacts() { echo "Structuring build artifacts..." >&2 - echo "current files: $(ls -la build-artifacts)" >&2 mkdir -p structured_build_artifacts/deb mkdir -p structured_build_artifacts/rpm mkdir -p structured_build_artifacts/jar @@ -145,7 +144,6 @@ structure_build_artifacts() { echo "Processing RPM: $rpm" >&2 process_rpm "$rpm" "./structured_build_artifacts/rpm" done < <(find build-artifacts -name "*.rpm" -print0) - echo "current files: $(ls -la build-artifacts)" >&2 while IFS= read -r -d '' jar; do if [[ ! -f "$jar" ]]; then @@ -155,17 +153,15 @@ structure_build_artifacts() { echo "Processing JAR: $jar" >&2 process_jar "$jar" "./structured_build_artifacts/jar" done < <(find build-artifacts -name "*.jar" -print0) - echo "current files: $(ls -la build-artifacts)" >&2 while IFS= read -r -d '' nupkg; do if [[ ! -f "$nupkg" ]]; then continue fi - echo "Processing JAR: $jar" >&2 - process_jar "$jar" "./structured_build_artifacts/jar" - done < <(find build-artifacts -name "*.jar" -print0) - echo "current files: $(ls -la build-artifacts)" >&2 + echo "Processing NUPKG: $nupkg" >&2 + process_nupkg "$nupkg" "./structured_build_artifacts/nupkg" + done < <(find build-artifacts -name "*.nupkg" -print0) while IFS= read -r -d '' generic; do if [[ ! -f "$generic" ]]; then @@ -174,7 +170,7 @@ structure_build_artifacts() { fi echo "Processing generic file: $generic" >&2 process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -type f -print0) + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" -not -name "*.nupkg" \) -type f -print0) } upload_deb_packages() { @@ -309,6 +305,34 @@ upload_jar_packages() { done < <(find . \( -name "*.jar" -o -name "*.pom" \) -print0) } +upload_nupkg_packages() { + if [[ "$DRY_RUN" == "true" ]]; then + echo "Would upload NuGet packages to JFrog..." >&2 + else + echo "Uploading NuGet packages to JFrog..." >&2 + fi + while IFS= read -r -d '' nupkg; do + if [[ ! -f "$nupkg" ]]; then + continue + fi + + echo " Uploading NuGet package: $nupkg" >&2 + run jf rt upload "$nupkg" "$PROJECT-nupkg-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + + # Upload signature if it exists + if [[ -f "$nupkg.asc" ]]; then + echo " Uploading signature: $nupkg.asc" >&2 + run jf rt upload "$nupkg.asc" "$PROJECT-nupkg-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.nupkg" -print0) +} + upload_generic_files() { if [[ "$DRY_RUN" == "true" ]]; then echo "Would upload generic files..." >&2 @@ -415,7 +439,11 @@ main() { echo "Dry run: $DRY_RUN" >&2 echo "Build number: $BUILD_NUMBER" >&2 echo "Metadata build number: $METADATA_BUILD_NUMBER" >&2 - echo "current files: $(ls -la build-artifacts)" >&2 + + if [[ ! -d build-artifacts ]]; then + error "build-artifacts directory does not exist. Artifacts must be downloaded before running this script." + fi + mkdir -p structured_build_artifacts shopt -s globstar nullglob @@ -431,6 +459,9 @@ main() { cd jar upload_jar_packages cd .. + cd nupkg + upload_nupkg_packages + cd .. cd generic upload_generic_files cd .. diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats index 3ef46ff7..9ed47aae 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats @@ -65,9 +65,8 @@ teardown_file() { if [[ $cmd =~ \.nupkg ]]; then nupkg_found=true - # Determine expected repository (check if nupkg has separate repo or uses generic) - # Based on entrypoint.sh, nupkg files go to generic repo - local expected_repo="test-project-generic-dev-local" + # NuGet packages go to NuGet-specific repository + local expected_repo="test-project-nupkg-dev-local" # Extract filename from command local filename From 0b31646d3f4689f3173cf6535d737fd9882e096f Mon Sep 17 00:00:00 2001 From: "Joe M." Date: Thu, 20 Nov 2025 22:19:34 -0800 Subject: [PATCH 49/56] docs: gtammar Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index bea4bf46..a18b7022 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -285,7 +285,7 @@ upload_jar_packages() { read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") pkgname="${metadata[0]}" version="${metadata[1]}" - # group might be empty if this is a simple jar file Use :- to handle empty group_id + # Group might be empty if this is a simple jar file. Use :- to handle empty group_id. group_id="${metadata[2]:-}" echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 From 9903ca3524cde6a745df50f7ab28a85316532ad9 Mon Sep 17 00:00:00 2001 From: "Joe M." Date: Thu, 20 Nov 2025 22:20:56 -0800 Subject: [PATCH 50/56] docs: comment should match refactor Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/create-test-fixtures.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/create-test-fixtures.sh b/.github/workflows/deploy-artifacts/create-test-fixtures.sh index 12cfb082..84ed206c 100755 --- a/.github/workflows/deploy-artifacts/create-test-fixtures.sh +++ b/.github/workflows/deploy-artifacts/create-test-fixtures.sh @@ -64,7 +64,7 @@ if [[ -f "tests/test-1.0-2.noarch.rpm" ]]; then cp "tests/test-1.0-2.noarch.rpm" "$BUILD_ARTIFACTS_DIR/nested/dir/nested.rpm" echo " Copied test-1.0-2.noarch.rpm as nested.rpm" else - echo "Error: tests/test-1.0-2.noarch.rpm not found. Cannot create nested mock RPM file." >&2 + echo "Error: tests/test-1.0-2.noarch.rpm not found. This file is required for nested test fixtures." >&2 exit 1 fi From 11715e8b868089ca6e1486d980ebb820f8ca6a42 Mon Sep 17 00:00:00 2001 From: "Joe M." Date: Thu, 20 Nov 2025 22:22:03 -0800 Subject: [PATCH 51/56] docs: comment should match refactor Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/create-test-fixtures.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/create-test-fixtures.sh b/.github/workflows/deploy-artifacts/create-test-fixtures.sh index 84ed206c..5e954fb9 100755 --- a/.github/workflows/deploy-artifacts/create-test-fixtures.sh +++ b/.github/workflows/deploy-artifacts/create-test-fixtures.sh @@ -57,7 +57,7 @@ if [[ -f "tests/nano-tiny_8.4-1_arm64.deb" ]]; then cp "tests/nano-tiny_8.4-1_arm64.deb" "$BUILD_ARTIFACTS_DIR/nested/dir/test-debian12.deb" echo " Copied nano-tiny_8.4-1_arm64.deb as nested test-debian12.deb" else - echo "Error: tests/nano-tiny_8.4-1_arm64.deb not found. Cannot create nested mock DEB file." >&2 + echo "Error: tests/nano-tiny_8.4-1_arm64.deb not found. This file is required for nested test fixtures." >&2 exit 1 fi if [[ -f "tests/test-1.0-2.noarch.rpm" ]]; then From f864dac717b2792d0ef7a967f0a4c06983fca7ce Mon Sep 17 00:00:00 2001 From: Joe Martin Date: Thu, 20 Nov 2025 22:32:16 -0800 Subject: [PATCH 52/56] fix: update NuGet repository references in entrypoint.sh and test_nupkg_upload.bats --- .github/workflows/deploy-artifacts/entrypoint.sh | 4 ++-- .../deploy-artifacts/tests/bats/test_nupkg_upload.bats | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index a18b7022..9e337532 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -317,7 +317,7 @@ upload_nupkg_packages() { fi echo " Uploading NuGet package: $nupkg" >&2 - run jf rt upload "$nupkg" "$PROJECT-nupkg-dev-local" --flat=false \ + run jf rt upload "$nupkg" "$PROJECT-nuget-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" @@ -325,7 +325,7 @@ upload_nupkg_packages() { # Upload signature if it exists if [[ -f "$nupkg.asc" ]]; then echo " Uploading signature: $nupkg.asc" >&2 - run jf rt upload "$nupkg.asc" "$PROJECT-nupkg-dev-local" --flat=false \ + run jf rt upload "$nupkg.asc" "$PROJECT-nuget-dev-local" --flat=false \ --build-name="$BUILD_NAME" \ --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats index 9ed47aae..3f020a16 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_nupkg_upload.bats @@ -66,7 +66,7 @@ teardown_file() { nupkg_found=true # NuGet packages go to NuGet-specific repository - local expected_repo="test-project-nupkg-dev-local" + local expected_repo="test-project-nuget-dev-local" # Extract filename from command local filename From ca557601630d8a7cc6c3f0adcd31fce9d9899dbf Mon Sep 17 00:00:00 2001 From: "Joe M." Date: Fri, 21 Nov 2025 15:04:20 -0800 Subject: [PATCH 53/56] fix(workflows): nupkg are now not generic Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/deploy-artifacts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 9e337532..a49bfb26 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -350,7 +350,7 @@ upload_generic_files() { --build-number="$ARTIFACT_BUILD_NUMBER" \ --project="$PROJECT" fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" \) -print0) + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" -not -name "*.nupkg" \) -print0) } From 865a8e47680d5f5d3d00011669ad82f6264db571 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 21 Nov 2025 21:57:35 -0800 Subject: [PATCH 54/56] fix: removed comments that could lead to confusion. Added support for non maven jar builds --- .../workflows/deploy-artifacts/entrypoint.sh | 785 +++++++++--------- .../workflows/reusable_deploy-artifacts.yaml | 12 +- 2 files changed, 415 insertions(+), 382 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index a49bfb26..6d185d41 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -4,19 +4,19 @@ export PS4='+($LINENO): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' trap 'handle_error ${LINENO}' ERR # shellcheck disable=SC2317 handle_error() { - local exit_code=$? - local line_number=$1 - echo "Error: Command failed with exit code $exit_code at line $line_number" >&2 - exit 1 + local exit_code=$? + local line_number=$1 + echo "Error: Command failed with exit code $exit_code at line $line_number" >&2 + exit 1 } error() { - local reason="${1:-}" - if [[ -n "$reason" ]]; then - echo "Error: $reason" >&2 - else - echo "Error" >&2 - fi - exit 1 + local reason="${1-}" + if [[ -n $reason ]]; then + echo "Error: $reason" >&2 + else + echo "Error" >&2 + fi + exit 1 } # Default values @@ -25,74 +25,83 @@ DRY_RUN="false" echo "Command line: $0 $*" >&2 # Parse command line arguments while [[ $# -gt 0 ]]; do - case $1 in - --dry-run) - DRY_RUN="true" - shift - ;; - --help|-h) - echo "Usage: $0 [OPTIONS]" >&2 - echo "" >&2 - echo "Uploads artifacts to JFrog Artifactory" >&2 - echo "" >&2 - echo "Options:" >&2 - echo " --metadata-build-number Build ID prefix used to discover related metadata builds (searches for *.json)" >&2 - echo " --dry-run Show what would be uploaded without actually uploading" >&2 - echo " --help, -h Show this help message" >&2 - echo "" >&2 - echo "Examples:" >&2 - echo " $0 database my-app v1.0.0 1754566442238 1754566442238-metadata" >&2 - echo " $0 database my-app v1.0.0 1754566442238 1754566442238-metadata --dry-run" >&2 - exit 0 - ;; - -*) - echo "Unknown option: $1" >&2 - echo "Use --help for usage information" >&2 - exit 1 - ;; - *) - # Positional arguments - if [[ -z "${PROJECT:-}" ]]; then - PROJECT="$1" - elif [[ -z "${BUILD_NAME:-}" ]]; then - BUILD_NAME="$1" - elif [[ -z "${VERSION:-}" ]]; then - VERSION="$1" - elif [[ -z "${BUILD_NUMBER:-}" ]]; then - BUILD_NUMBER="$1" - elif [[ -z "${METADATA_BUILD_NUMBER:-}" ]]; then - METADATA_BUILD_NUMBER="$1" - else - echo "Use --help for usage information" >&2 - exit 1 - fi - shift - ;; - esac + case $1 in + --dry-run) + DRY_RUN="true" + shift + ;; + --jar-group-id) + JAR_GROUP_ID="$2" + shift 2 + ;; + --help | -h) + echo "Usage: $0 [OPTIONS]" >&2 + echo "" >&2 + echo "Uploads artifacts to JFrog Artifactory" >&2 + echo "" >&2 + echo "Options:" >&2 + echo " --metadata-build-number Build ID prefix used to discover related metadata builds (searches for *.json)" >&2 + echo " --jar-group-id Maven group ID for JAR artifacts" >&2 + echo " --dry-run Show what would be uploaded without actually uploading" >&2 + echo " --help, -h Show this help message" >&2 + echo "" >&2 + echo "Examples:" >&2 + echo " $0 database my-app v1.0.0 1754566442238 1754566442238-metadata" >&2 + echo " $0 database my-app v1.0.0 1754566442238 1754566442238-metadata --dry-run" >&2 + echo " $0 database my-app v1.0.0 1754566442238 1754566442238-metadata --jar-group-id com.aerospike.test" >&2 + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo "Use --help for usage information" >&2 + exit 1 + ;; + *) + # Positional arguments + if [[ -z ${PROJECT-} ]]; then + PROJECT="$1" + elif [[ -z ${BUILD_NAME-} ]]; then + BUILD_NAME="$1" + elif [[ -z ${VERSION-} ]]; then + VERSION="$1" + elif [[ -z ${JAR_GROUP_ID-} ]]; then + # Optional argument + JAR_GROUP_ID="$1" + elif [[ -z ${BUILD_NUMBER-} ]]; then + BUILD_NUMBER="$1" + elif [[ -z ${METADATA_BUILD_NUMBER-} ]]; then + METADATA_BUILD_NUMBER="$1" + else + echo "Use --help for usage information" >&2 + exit 1 + fi + shift + ;; + esac done -if [[ -z "${PROJECT:-}" ]]; then - error "project is required +if [[ -z ${PROJECT-} ]]; then + error "project is required Use --help for usage information" fi -if [[ -z "${BUILD_NAME:-}" ]]; then - error "build-name is required +if [[ -z ${BUILD_NAME-} ]]; then + error "build-name is required Use --help for usage information" fi -if [[ -z "${VERSION:-}" ]]; then - error "version is required +if [[ -z ${VERSION-} ]]; then + error "version is required Use --help for usage information" fi -if [[ -z "${BUILD_NUMBER:-}" ]]; then - error "build-number is required +if [[ -z ${BUILD_NUMBER-} ]]; then + error "build-number is required Use --help for usage information" fi -if [[ -z "${METADATA_BUILD_NUMBER:-}" ]]; then - error "metadata-build-number is required +if [[ -z ${METADATA_BUILD_NUMBER-} ]]; then + error "metadata-build-number is required Use --help for usage information" fi ARTIFACT_BUILD_NUMBER="$BUILD_NUMBER-artifacts" @@ -102,273 +111,288 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck disable=SC1091 source "$SCRIPT_DIR/package_utils.sh" - # Wrapper function that either executes or echoes commands run() { - if [[ "$DRY_RUN" == "true" ]]; then - # Define color variables - local green='\033[0;32m' - local reset='\033[0m' - - echo -e "${green} $*${reset}" >&2 - else - "$@" - fi + if [[ $DRY_RUN == "true" ]]; then + # Define color variables + local green='\033[0;32m' + local reset='\033[0m' + + echo -e "${green} $*${reset}" >&2 + else + "$@" + fi } run_optional() { - run "$@" || echo "Warning: $*" >&2 + run "$@" || echo "Warning: $*" >&2 } structure_build_artifacts() { - echo "Structuring build artifacts..." >&2 - mkdir -p structured_build_artifacts/deb - mkdir -p structured_build_artifacts/rpm - mkdir -p structured_build_artifacts/jar - mkdir -p structured_build_artifacts/nupkg - mkdir -p structured_build_artifacts/generic - while IFS= read -r -d '' deb; do - if [[ ! -f "$deb" ]]; then - continue - fi - - echo "Processing DEB: $deb" >&2 - process_deb "$deb" "./structured_build_artifacts/deb" - done < <(find build-artifacts -name "*.deb" -print0) - - while IFS= read -r -d '' rpm; do - if [[ ! -f "$rpm" ]]; then - continue - fi - - echo "Processing RPM: $rpm" >&2 - process_rpm "$rpm" "./structured_build_artifacts/rpm" - done < <(find build-artifacts -name "*.rpm" -print0) - - while IFS= read -r -d '' jar; do - if [[ ! -f "$jar" ]]; then - continue - fi - - echo "Processing JAR: $jar" >&2 - process_jar "$jar" "./structured_build_artifacts/jar" - done < <(find build-artifacts -name "*.jar" -print0) - - while IFS= read -r -d '' nupkg; do - if [[ ! -f "$nupkg" ]]; then - continue - fi - - echo "Processing NUPKG: $nupkg" >&2 - process_nupkg "$nupkg" "./structured_build_artifacts/nupkg" - done < <(find build-artifacts -name "*.nupkg" -print0) - - while IFS= read -r -d '' generic; do - if [[ ! -f "$generic" ]]; then - echo "Skipping non-file: $generic" >&2 - continue - fi - echo "Processing generic file: $generic" >&2 - process_generic "$generic" "./structured_build_artifacts/generic" - done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" -not -name "*.nupkg" \) -type f -print0) + echo "Structuring build artifacts..." >&2 + mkdir -p structured_build_artifacts/deb + mkdir -p structured_build_artifacts/rpm + mkdir -p structured_build_artifacts/jar + mkdir -p structured_build_artifacts/nupkg + mkdir -p structured_build_artifacts/generic + while IFS= read -r -d '' deb; do + if [[ ! -f $deb ]]; then + continue + fi + + echo "Processing DEB: $deb" >&2 + process_deb "$deb" "./structured_build_artifacts/deb" + done < <(find build-artifacts -name "*.deb" -print0) + + while IFS= read -r -d '' rpm; do + if [[ ! -f $rpm ]]; then + continue + fi + + echo "Processing RPM: $rpm" >&2 + process_rpm "$rpm" "./structured_build_artifacts/rpm" + done < <(find build-artifacts -name "*.rpm" -print0) + + while IFS= read -r -d '' jar; do + if [[ ! -f $jar ]]; then + continue + fi + + echo "Processing JAR: $jar" >&2 + process_jar "$jar" "./structured_build_artifacts/jar" + done < <(find build-artifacts -name "*.jar" -print0) + + while IFS= read -r -d '' nupkg; do + if [[ ! -f $nupkg ]]; then + continue + fi + + echo "Processing NUPKG: $nupkg" >&2 + process_nupkg "$nupkg" "./structured_build_artifacts/nupkg" + done < <(find build-artifacts -name "*.nupkg" -print0) + + while IFS= read -r -d '' generic; do + if [[ ! -f $generic ]]; then + echo "Skipping non-file: $generic" >&2 + continue + fi + echo "Processing generic file: $generic" >&2 + process_generic "$generic" "./structured_build_artifacts/generic" + done < <(find build-artifacts \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" -not -name "*.nupkg" \) -type f -print0) } upload_deb_packages() { - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload DEB packages to JFrog..." >&2 - else - echo "Uploading DEB packages to JFrog..." >&2 - fi - while IFS= read -r -d '' deb; do - if [[ ! -f "$deb" ]]; then - continue - fi - # Get package metadata - pkgname=$(dpkg-deb -f "$deb" Package) - arch=$(dpkg-deb -f "$deb" Architecture) - if ! codename=$(get_codename_for_deb "$deb"); then - error "Failed to get codename for $deb" - fi - - echo " Package: $pkgname, Arch: $arch, Codename: $codename" >&2 - # Upload the DEB - - run jf rt upload "$deb" "$PROJECT-deb-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" \ - --target-props "version=$VERSION;deb.distribution=$codename;deb.component=main;deb.architecture=$arch" \ - --deb "$codename/main/$arch" - - # Upload signature and checksum if they exist - if [[ -f "$deb.asc" ]]; then - echo " Uploading signature: $deb.asc" >&2 - run jf rt upload "$deb.asc" "$PROJECT-deb-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . -name "*.deb" -print0) + if [[ $DRY_RUN == "true" ]]; then + echo "Would upload DEB packages to JFrog..." >&2 + else + echo "Uploading DEB packages to JFrog..." >&2 + fi + while IFS= read -r -d '' deb; do + if [[ ! -f $deb ]]; then + continue + fi + # Get package metadata + pkgname=$(dpkg-deb -f "$deb" Package) + arch=$(dpkg-deb -f "$deb" Architecture) + if ! codename=$(get_codename_for_deb "$deb"); then + error "Failed to get codename for $deb" + fi + + echo " Package: $pkgname, Arch: $arch, Codename: $codename" >&2 + # Upload the DEB + + run jf rt upload "$deb" "$PROJECT-deb-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "version=$VERSION;deb.distribution=$codename;deb.component=main;deb.architecture=$arch" \ + --deb "$codename/main/$arch" + + # Upload signature and checksum if they exist + if [[ -f "$deb.asc" ]]; then + echo " Uploading signature: $deb.asc" >&2 + run jf rt upload "$deb.asc" "$PROJECT-deb-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.deb" -print0) } upload_rpm_packages() { - - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload RPM packages to JFrog..." >&2 - else - echo "Uploading RPM packages to JFrog..." >&2 - fi - while IFS= read -r -d '' rpm; do - if [[ ! -f "$rpm" ]]; then - continue - fi - - # Get metadata using the shared function - read -r -a metadata < <(get_rpm_metadata "$rpm") - pkgname="${metadata[0]}" - version="${metadata[1]}" - arch="${metadata[2]}" - dist="${metadata[3]}" - - echo " Package: $pkgname, Version: $version, Arch: $arch, Dist: $dist" >&2 - - # Upload the RPM - run jf rt upload "$rpm" "$PROJECT-rpm-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" \ - --target-props "version=$VERSION;rpm.distribution=$dist;rpm.component=main;rpm.architecture=$arch" - - # Upload signature and checksums if they exist - if [[ -f "$rpm.asc" ]]; then - echo " Uploading signature: $rpm.asc" >&2 - run jf rt upload "$rpm.asc" "$PROJECT-rpm-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . -name "*.rpm" -print0) + if [[ $DRY_RUN == "true" ]]; then + echo "Would upload RPM packages to JFrog..." >&2 + else + echo "Uploading RPM packages to JFrog..." >&2 + fi + while IFS= read -r -d '' rpm; do + if [[ ! -f $rpm ]]; then + continue + fi + + # Get metadata using the shared function + read -r -a metadata < <(get_rpm_metadata "$rpm") + pkgname="${metadata[0]}" + version="${metadata[1]}" + arch="${metadata[2]}" + dist="${metadata[3]}" + + echo " Package: $pkgname, Version: $version, Arch: $arch, Dist: $dist" >&2 + + # Upload the RPM + run jf rt upload "$rpm" "$PROJECT-rpm-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "version=$VERSION;rpm.distribution=$dist;rpm.component=main;rpm.architecture=$arch" + + # Upload signature and checksums if they exist + if [[ -f "$rpm.asc" ]]; then + echo " Uploading signature: $rpm.asc" >&2 + run jf rt upload "$rpm.asc" "$PROJECT-rpm-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.rpm" -print0) } upload_jar_packages() { - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload JAR/POM packages to JFrog..." >&2 - else - echo "Uploading JAR/POM packages to JFrog..." >&2 - fi - - # Find all JAR and POM files, then process unique base names - declare -A processed_artifacts - - while IFS= read -r -d '' artifact; do - if [[ ! -f "$artifact" ]]; then - continue - fi - - # Get the directory and base name - artifact_dir=$(dirname "$artifact") - artifact_name=$(basename "$artifact") - base_name="${artifact_name%.jar}" - base_name="${base_name%.pom}" - - # Skip if we've already processed this base artifact - artifact_key="$artifact_dir/$base_name" - if [[ -n "${processed_artifacts[$artifact_key]:-}" ]]; then - continue - fi - processed_artifacts[$artifact_key]=1 - - # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) - local pkgname version group_id - - # Fallback: Extract metadata from JAR if no POM exists - read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") - pkgname="${metadata[0]}" - version="${metadata[1]}" - # Group might be empty if this is a simple jar file. Use :- to handle empty group_id. - group_id="${metadata[2]:-}" - - echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 - - # Upload all related Maven artifact files (jar, pom, signatures) - for ext in jar pom jar.asc pom.asc; do - local artifact_file="$artifact_dir/${base_name}.${ext}" - if [[ -f "$artifact_file" ]]; then - echo " Uploading $ext: $artifact_file" >&2 - run jf rt upload "$artifact_file" "$PROJECT-maven-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" \ - --target-props "group_id=$group_id;package_name=$pkgname;version=$version" - fi - done - done < <(find . \( -name "*.jar" -o -name "*.pom" \) -print0) + if [[ $DRY_RUN == "true" ]]; then + echo "Would upload JAR/POM files to JFrog..." >&2 + else + echo "Uploading JAR/POM files to JFrog..." >&2 + fi + + # Find all JAR and POM files, then process unique base names + declare -A processed_artifacts + + while IFS= read -r -d '' artifact; do + if [[ ! -f $artifact ]]; then + continue + fi + + # Get the directory and base name + artifact_dir=$(dirname "$artifact") + artifact_name=$(basename "$artifact") + base_name="${artifact_name%.jar}" + base_name="${base_name%.pom}" + + # Skip if we've already processed this base artifact + artifact_key="$artifact_dir/$base_name" + if [[ -n ${processed_artifacts[$artifact_key]-} ]]; then + continue + fi + processed_artifacts[$artifact_key]=1 + + # Determine which file to use for metadata extraction (prefer POM as it's the source of truth) + local pkgname version group_id + + # Fallback: Extract metadata from JAR if no POM exists + read -r -a metadata < <(get_jar_metadata "$artifact_dir/${base_name}.jar") + pkgname="${metadata[0]}" + version="${metadata[1]}" + + # Group ID priority: metadata > flag > empty + # If metadata has group_id, use it; otherwise use JAR_GROUP_ID if provided via flag + if [[ -n ${metadata[2]-} ]]; then + group_id="${metadata[2]}" + else + group_id="${JAR_GROUP_ID-}" + fi + + # If no group_id is available, move to generic directory for generic upload + if [[ -z $group_id ]]; then + echo " Moving JAR without group_id to generic directory: $artifact" >&2 + for ext in jar pom jar.asc pom.asc; do + local artifact_file="$artifact_dir/${base_name}.${ext}" + if [[ -f $artifact_file ]]; then + mv "$artifact_file" "../generic/" + fi + done + continue + fi + + echo " Package: $pkgname, Version: $version, Group ID: $group_id" >&2 + + # Upload all related Maven artifact files (jar, pom, signatures) + for ext in jar pom jar.asc pom.asc; do + local artifact_file="$artifact_dir/${base_name}.${ext}" + if [[ -f $artifact_file ]]; then + echo " Uploading $ext: $artifact_file" >&2 + run jf rt upload "$artifact_file" "$PROJECT-maven-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" \ + --target-props "group_id=$group_id;package_name=$pkgname;version=$version" + fi + done + done < <(find . \( -name "*.jar" -o -name "*.pom" \) -print0) } upload_nupkg_packages() { - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload NuGet packages to JFrog..." >&2 - else - echo "Uploading NuGet packages to JFrog..." >&2 - fi - while IFS= read -r -d '' nupkg; do - if [[ ! -f "$nupkg" ]]; then - continue - fi - - echo " Uploading NuGet package: $nupkg" >&2 - run jf rt upload "$nupkg" "$PROJECT-nuget-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - - # Upload signature if it exists - if [[ -f "$nupkg.asc" ]]; then - echo " Uploading signature: $nupkg.asc" >&2 - run jf rt upload "$nupkg.asc" "$PROJECT-nuget-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . -name "*.nupkg" -print0) + if [[ $DRY_RUN == "true" ]]; then + echo "Would upload NuGet packages to JFrog..." >&2 + else + echo "Uploading NuGet packages to JFrog..." >&2 + fi + while IFS= read -r -d '' nupkg; do + if [[ ! -f $nupkg ]]; then + continue + fi + + echo " Uploading NuGet package: $nupkg" >&2 + run jf rt upload "$nupkg" "$PROJECT-nuget-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + + # Upload signature if it exists + if [[ -f "$nupkg.asc" ]]; then + echo " Uploading signature: $nupkg.asc" >&2 + run jf rt upload "$nupkg.asc" "$PROJECT-nuget-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . -name "*.nupkg" -print0) } upload_generic_files() { - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would upload generic files..." >&2 - else - echo "Uploading generic files..." >&2 - fi - echo "Finding files..." >&2 - find . >&2 - while IFS= read -r -d '' file; do - echo "Processing generic file: $file" >&2 - if [[ -f "$file" ]]; then - echo "Uploading generic file: $file" >&2 - run jf rt upload "$file" "$PROJECT-generic-dev-local" --flat=false \ - --build-name="$BUILD_NAME" \ - --build-number="$ARTIFACT_BUILD_NUMBER" \ - --project="$PROJECT" - fi - done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.jar" -not -name "*.pom" -not -name "*.nupkg" \) -print0) + if [[ $DRY_RUN == "true" ]]; then + echo "Would upload generic files..." >&2 + else + echo "Uploading generic files..." >&2 + fi + echo "Finding files..." >&2 + find . >&2 + while IFS= read -r -d '' file; do + echo "Processing generic file: $file" >&2 + if [[ -f $file ]]; then + echo "Uploading generic file: $file" >&2 + run jf rt upload "$file" "$PROJECT-generic-dev-local" --flat=false \ + --build-name="$BUILD_NAME" \ + --build-number="$ARTIFACT_BUILD_NUMBER" \ + --project="$PROJECT" + fi + done < <(find . \( -not -name "*.deb" -not -name "*.rpm" -not -name "*.asc" -not -name "*.nupkg" \) -print0) } - # Collects build-info metadata by querying Artifactory for JSON files. # JFrog API doesn't support wildcarding build IDs, so we fetch the JSON # files to extract the collection of build IDs for this parent build. discover_build_infos() { - local project="$1" - local parent_build_name="$2" - local build_info_search_pattern="$3" - local build_info_repo="${4:-${project}-build-info}" + local project="$1" + local parent_build_name="$2" + local build_info_search_pattern="$3" + local build_info_repo="${4:-${project}-build-info}" - echo "Discovering build-infos for project: $project" >&2 - echo "Parent build name: $parent_build_name" >&2 - echo "Search pattern: $build_info_search_pattern" >&2 - echo "Build-info repo: $build_info_repo" >&2 + echo "Discovering build-infos for project: $project" >&2 + echo "Parent build name: $parent_build_name" >&2 + echo "Search pattern: $build_info_search_pattern" >&2 + echo "Build-info repo: $build_info_repo" >&2 - read -r -d '' AQL <&2 - # Query for build-info JSON files - local resp - resp=$(run jf rt curl -XPOST api/search/aql \ - -H 'Content-Type: text/plain' \ - -d "$AQL") - echo "search response: $resp" >&2 - # Extract child build IDs from JSON file names - if echo "$resp" | jq -e '.results' > /dev/null 2>&1; then - mapfile -t CHILD_BUILD_IDS < <(echo "$resp" | jq -r '.results[] | .name' | sed 's/-[0-9]*\.json$//' | sort -u) - - echo "Found ${#CHILD_BUILD_IDS[@]} child builds" >&2 - - CHILD_BUILD_IDS_RESULT=("${CHILD_BUILD_IDS[@]}") - return 0 - else - echo "No build-info files found" >&2 - CHILD_BUILD_IDS_RESULT=() - return 1 - fi + echo run jf rt curl -XPOST api/search/aql \ + -H 'Content-Type: text/plain' \ + -d "$AQL" >&2 + # Query for build-info JSON files + local resp + resp=$(run jf rt curl -XPOST api/search/aql \ + -H 'Content-Type: text/plain' \ + -d "$AQL") + echo "search response: $resp" >&2 + # Extract child build IDs from JSON file names + if echo "$resp" | jq -e '.results' >/dev/null 2>&1; then + mapfile -t CHILD_BUILD_IDS < <(echo "$resp" | jq -r '.results[] | .name' | sed 's/-[0-9]*\.json$//' | sort -u) + + echo "Found ${#CHILD_BUILD_IDS[@]} child builds" >&2 + + CHILD_BUILD_IDS_RESULT=("${CHILD_BUILD_IDS[@]}") + return 0 + else + echo "No build-info files found" >&2 + CHILD_BUILD_IDS_RESULT=() + return 1 + fi } - # This function handles publishing the tree of build info to jfrog # 1. publish the signed artifacts # 2. append metadata and artifact builld infos to new build info # 3. publish the new build info publish_build_info() { - run jf rt build-publish "$BUILD_NAME" "$ARTIFACT_BUILD_NUMBER" --project="$PROJECT" + run jf rt build-publish "$BUILD_NAME" "$ARTIFACT_BUILD_NUMBER" --project="$PROJECT" - discover_build_infos "$PROJECT" "$BUILD_NAME" "$METADATA_BUILD_NUMBER*" "$PROJECT-build-info" || true + discover_build_infos "$PROJECT" "$BUILD_NAME" "$METADATA_BUILD_NUMBER*" "$PROJECT-build-info" || true - # Access the results - if [[ ${#CHILD_BUILD_IDS_RESULT[@]} -gt 0 ]]; then - echo "Found ${#CHILD_BUILD_IDS_RESULT[@]} child builds:" >&2 - for build_id in "${CHILD_BUILD_IDS_RESULT[@]}"; do - echo " $BUILD_NAME/$build_id" - run jf rt build-append "$BUILD_NAME" "$BUILD_NUMBER" \ - "$BUILD_NAME" "$build_id" --project="$PROJECT" - done - fi + # Access the results + if [[ ${#CHILD_BUILD_IDS_RESULT[@]} -gt 0 ]]; then + echo "Found ${#CHILD_BUILD_IDS_RESULT[@]} child builds:" >&2 + for build_id in "${CHILD_BUILD_IDS_RESULT[@]}"; do + echo " $BUILD_NAME/$build_id" + run jf rt build-append "$BUILD_NAME" "$BUILD_NUMBER" \ + "$BUILD_NAME" "$build_id" --project="$PROJECT" + done + fi - run jf rt build-append "$BUILD_NAME" "$BUILD_NUMBER" \ - "$BUILD_NAME" "$ARTIFACT_BUILD_NUMBER" --project="$PROJECT" - run jf rt build-publish "$BUILD_NAME" "$BUILD_NUMBER" --project="$PROJECT" + run jf rt build-append "$BUILD_NAME" "$BUILD_NUMBER" \ + "$BUILD_NAME" "$ARTIFACT_BUILD_NUMBER" --project="$PROJECT" + run jf rt build-publish "$BUILD_NAME" "$BUILD_NUMBER" --project="$PROJECT" } main() { - if [[ "$DRY_RUN" == "true" ]]; then - echo "Would deploy artifacts to JFrog Artifactory" >&2 - else - echo "Deploying artifacts to JFrog Artifactory" >&2 - fi - echo "Project: $PROJECT" >&2 - echo "Build name: $BUILD_NAME" >&2 - echo "Version: $VERSION" >&2 - echo "Dry run: $DRY_RUN" >&2 - echo "Build number: $BUILD_NUMBER" >&2 - echo "Metadata build number: $METADATA_BUILD_NUMBER" >&2 - - if [[ ! -d build-artifacts ]]; then - error "build-artifacts directory does not exist. Artifacts must be downloaded before running this script." - fi - - mkdir -p structured_build_artifacts - shopt -s globstar nullglob - - structure_build_artifacts - cd structured_build_artifacts - # Upload all packages - cd rpm - upload_rpm_packages - cd .. - cd deb - upload_deb_packages - cd .. - cd jar - upload_jar_packages - cd .. - cd nupkg - upload_nupkg_packages - cd .. - cd generic - upload_generic_files - cd .. - # Publish build info once for the unified build - publish_build_info - - echo "Deploy complete!" >&2 - echo "Build name: $BUILD_NAME" >&2 - echo "Build number: $BUILD_NUMBER" >&2 + if [[ $DRY_RUN == "true" ]]; then + echo "Would deploy artifacts to JFrog Artifactory" >&2 + else + echo "Deploying artifacts to JFrog Artifactory" >&2 + fi + echo "Project: $PROJECT" >&2 + echo "Build name: $BUILD_NAME" >&2 + echo "Version: $VERSION" >&2 + echo "Dry run: $DRY_RUN" >&2 + echo "Build number: $BUILD_NUMBER" >&2 + echo "Metadata build number: $METADATA_BUILD_NUMBER" >&2 + + if [[ ! -d build-artifacts ]]; then + error "build-artifacts directory does not exist. Artifacts must be downloaded before running this script." + fi + + mkdir -p structured_build_artifacts + shopt -s globstar nullglob + + structure_build_artifacts + cd structured_build_artifacts + # Upload all packages + cd rpm + upload_rpm_packages + cd .. + cd deb + upload_deb_packages + cd .. + cd jar + upload_jar_packages + cd .. + cd nupkg + upload_nupkg_packages + cd .. + cd generic + upload_generic_files + cd .. + # Publish build info once for the unified build + publish_build_info + + echo "Deploy complete!" >&2 + echo "Build name: $BUILD_NAME" >&2 + echo "Build number: $BUILD_NUMBER" >&2 } main "$@" diff --git a/.github/workflows/reusable_deploy-artifacts.yaml b/.github/workflows/reusable_deploy-artifacts.yaml index d3adb86f..aca07920 100644 --- a/.github/workflows/reusable_deploy-artifacts.yaml +++ b/.github/workflows/reusable_deploy-artifacts.yaml @@ -33,6 +33,10 @@ on: required: false type: boolean default: false + jar-group-id: + description: Maven group ID for JAR artifacts (used as fallback when metadata doesn't provide one) + required: false + type: string gh-artifact-name: description: Name of signed artifacts on github required: false @@ -128,11 +132,17 @@ jobs: dry_run_arg="--dry-run" fi + jar_group_id_arg="" + if [ -n "${{ inputs.jar-group-id }}" ]; then + jar_group_id_arg="--jar-group-id ${{ inputs.jar-group-id }}" + fi + ${{ inputs.gh-checkout-path }}/.github/workflows/deploy-artifacts/entrypoint.sh \ "${{ inputs.jf-project }}" \ "${{ inputs.jf-build-name }}" \ "${{ inputs.version }}" \ "${{ inputs.jf-build-id }}" \ "${{ inputs.jf-metadata-build-id }}" \ - $dry_run_arg + $dry_run_arg \ + $jar_group_id_arg echo "jf-build-id=${{ inputs.jf-build-id }}" >> $GITHUB_OUTPUT From 57db2ff7958aeee3377bb474a683b086ad523bdd Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 21 Nov 2025 22:06:23 -0800 Subject: [PATCH 55/56] fix: made --jar-group-id for entrypoint.sh --- .github/workflows/deploy-artifacts/entrypoint.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy-artifacts/entrypoint.sh b/.github/workflows/deploy-artifacts/entrypoint.sh index 6d185d41..79f3ddaf 100755 --- a/.github/workflows/deploy-artifacts/entrypoint.sh +++ b/.github/workflows/deploy-artifacts/entrypoint.sh @@ -64,9 +64,6 @@ while [[ $# -gt 0 ]]; do BUILD_NAME="$1" elif [[ -z ${VERSION-} ]]; then VERSION="$1" - elif [[ -z ${JAR_GROUP_ID-} ]]; then - # Optional argument - JAR_GROUP_ID="$1" elif [[ -z ${BUILD_NUMBER-} ]]; then BUILD_NUMBER="$1" elif [[ -z ${METADATA_BUILD_NUMBER-} ]]; then From 2b2be4316419a7edb2c4cee5c7d5efb58f96f590 Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Fri, 21 Nov 2025 22:22:45 -0800 Subject: [PATCH 56/56] fix: fixed tests to accomodated new logic --- .../tests/bats/test_all_files_upload.bats | 2 +- .../tests/bats/test_java_upload.bats | 2 +- .../deploy-artifacts/tests/helpers/setup.bash | 98 +++++++++---------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats index b9a9e67a..3c1dceae 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_all_files_upload.bats @@ -66,7 +66,7 @@ teardown_file() { if [[ $cmd =~ test\.jar ]]; then jar_found=true assert_upload_command_valid "$cmd" "test.jar" "test-project-maven-dev-local" \ - "group_id=;package_name=test.jar;version=test.jar" \ + "group_id=com.example.test;package_name=test.jar;version=test.jar" \ "test-build" "12345-artifacts" "test-project" fi diff --git a/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats b/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats index 9e282383..e9774207 100755 --- a/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats +++ b/.github/workflows/deploy-artifacts/tests/bats/test_java_upload.bats @@ -75,7 +75,7 @@ teardown_file() { # Validate command structure with Maven target-props assert_upload_command_valid "$cmd" "$filename" "$expected_repo" \ - "group_id=;package_name=test.jar;version=test.jar" \ + "group_id=com.example.test;package_name=test.jar;version=test.jar" \ "test-build" "12345-artifacts" "test-project" fi done diff --git a/.github/workflows/deploy-artifacts/tests/helpers/setup.bash b/.github/workflows/deploy-artifacts/tests/helpers/setup.bash index d011d9b0..7962596f 100755 --- a/.github/workflows/deploy-artifacts/tests/helpers/setup.bash +++ b/.github/workflows/deploy-artifacts/tests/helpers/setup.bash @@ -11,60 +11,60 @@ BUILD_ARTIFACTS_DIR="$TEST_DIR/build-artifacts" # Setup function called before each test file setup_test_artifacts() { - # Create test directory and fixtures - rm -rf "$TEST_DIR" - mkdir -p "$BUILD_ARTIFACTS_DIR" - - # Run create-test-fixtures.sh to set up test artifacts - # Must run from git root so it can find tests/ directory - cd "$GIT_ROOT" || exit 1 - "$DEPLOY_ARTIFACTS_DIR/create-test-fixtures.sh" - cd "$DEPLOY_ARTIFACTS_DIR/test-artifacts" || exit 1 - - # Verify test files exist - declare -a TEST_FILES=( - "$BUILD_ARTIFACTS_DIR/test-ubuntu22.04.deb" - "$BUILD_ARTIFACTS_DIR/test-1.0-2.noarch.rpm" - "$BUILD_ARTIFACTS_DIR/test.jar" - "$BUILD_ARTIFACTS_DIR/test.zip" - "$BUILD_ARTIFACTS_DIR/test.tar.gz" - "$BUILD_ARTIFACTS_DIR/nested/dir/test-debian12.deb" - "$BUILD_ARTIFACTS_DIR/nested/dir/nested.rpm" - ) - - for file in "${TEST_FILES[@]}"; do - if [[ ! -f "$file" ]]; then - echo "Error: Missing expected test file: $file" >&2 - exit 1 - fi - done - - # Change to test directory for consistent context - cd "$TEST_DIR" || exit 1 + # Create test directory and fixtures + rm -rf "$TEST_DIR" + mkdir -p "$BUILD_ARTIFACTS_DIR" + + # Run create-test-fixtures.sh to set up test artifacts + # Must run from git root so it can find tests/ directory + cd "$GIT_ROOT" || exit 1 + "$DEPLOY_ARTIFACTS_DIR/create-test-fixtures.sh" + cd "$DEPLOY_ARTIFACTS_DIR/test-artifacts" || exit 1 + + # Verify test files exist + declare -a TEST_FILES=( + "$BUILD_ARTIFACTS_DIR/test-ubuntu22.04.deb" + "$BUILD_ARTIFACTS_DIR/test-1.0-2.noarch.rpm" + "$BUILD_ARTIFACTS_DIR/test.jar" + "$BUILD_ARTIFACTS_DIR/test.zip" + "$BUILD_ARTIFACTS_DIR/test.tar.gz" + "$BUILD_ARTIFACTS_DIR/nested/dir/test-debian12.deb" + "$BUILD_ARTIFACTS_DIR/nested/dir/nested.rpm" + ) + + for file in "${TEST_FILES[@]}"; do + if [[ ! -f $file ]]; then + echo "Error: Missing expected test file: $file" >&2 + exit 1 + fi + done + + # Change to test directory for consistent context + cd "$TEST_DIR" || exit 1 } teardown_test_artifacts() { - # Cleanup test artifacts (optional - comment out for debugging) - # rm -rf "$TEST_DIR" - : + # Cleanup test artifacts (optional - comment out for debugging) + # rm -rf "$TEST_DIR" + : } # Run entrypoint.sh with dry-run and capture output run_entrypoint_dry_run() { - local project="${1:-test-project}" - local build_name="${2:-test-build}" - local version="${3:-v1.0.0}" - local build_number="${4:-12345}" - local metadata_build_number="${5:-12345-metadata}" - - cd "$TEST_DIR" || exit 1 - "$DEPLOY_ARTIFACTS_DIR/entrypoint.sh" \ - "$project" \ - "$build_name" \ - "$version" \ - "$build_number" \ - "$metadata_build_number" \ - --dry-run \ - 2>&1 -} + local project="${1:-test-project}" + local build_name="${2:-test-build}" + local version="${3:-v1.0.0}" + local build_number="${4:-12345}" + local metadata_build_number="${5:-12345-metadata}" + cd "$TEST_DIR" || exit 1 + "$DEPLOY_ARTIFACTS_DIR/entrypoint.sh" \ + "$project" \ + "$build_name" \ + "$version" \ + "$build_number" \ + "$metadata_build_number" \ + --dry-run \ + --jar-group-id "com.example.test" \ + 2>&1 +}