@@ -69,62 +69,69 @@ jobs:
6969 distribution : ' temurin'
7070 cache : maven
7171
72- - name : Extract Release Tag
73- id : extract_tag
74- run : |
75- # Extract the release tag from the GitHub context
76- TAG_NAME=${GITHUB_REF#refs/tags/}
77- echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
78-
7972 # Set the project version from the release tag
8073 - name : Set project version from tag
81- run : mvn --batch-mode versions:set -DnewVersion=${{ env.TAG_NAME }} -DgenerateBackupPoms=false
74+ run : |
75+ echo "Setting project version from release tag: ${{ github.event.release.tag_name }}"
76+ mvn --batch-mode versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
8277
8378 - name : Build all modules first
8479 run : mvn clean install -DskipTests
8580
86- # Build the project
87- # For registry modules, we activate the dockerbuild profile and specify the module with --pl
88- - name : Build BaSyx
89- run : |
90- if [[ "${{ matrix.name }}" == *"registry"* ]]; then
91- # Derive the module's artifactId from the path
92- module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
93- artifact_id=$(basename "$module_root")
94- # Run with dockerbuild profile and namespace
95- mvn clean install -DskipTests -Pdockerbuild "-Ddocker.namespace=${{ env.DOCKER_NAMESPACE }}" --pl "org.eclipse.digitaltwin.basyx:${artifact_id}"
96- else
97- echo "Non-registry module - already built in the previous step."
98- fi
99-
100- - name : Prepare Registry JAR for Docker
81+ # Process registry modules
82+ - name : Process Registry Module
83+ id : registry_module
10184 if : contains(matrix.name, 'registry')
10285 run : |
103- # Go three levels up from src/main/docker to get the module root
104- module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
105-
106- # Adjust the path to where the dockerbuild profile places the JAR
107- JAR_FILE=$(ls "$module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/${{ env.TAG_NAME }}/build/maven/"*.jar | head -n 1)
86+ # Get the module path without /src/main/docker
87+ MODULE_PATH=$(echo ${{ matrix.path }} | sed 's|/src/main/docker||')
88+ echo "Building registry module at: ${MODULE_PATH}"
89+
90+ # Build with dockerbuild profile
91+ mvn clean package -DskipTests -Pdockerbuild "-Ddocker.namespace=${{ env.DOCKER_NAMESPACE }}" "-Ddocker.image.tag=${{ github.event.release.tag_name }}" -f ${MODULE_PATH}/pom.xml
92+
93+ # Create maven directory for Docker
94+ mkdir -p "${{ matrix.path }}/maven"
95+
96+ # Find the JAR file using multiple search patterns
97+ echo "Looking for JAR files in standard target directory..."
98+ JAR_FILE=$(find "${MODULE_PATH}/target" -name "*.jar" -not -name "*sources*" -not -name "*javadoc*" | head -n 1)
99+
100+ if [ -z "$JAR_FILE" ]; then
101+ echo "Not found in standard location, trying docker build location..."
102+ JAR_FILE=$(find "${MODULE_PATH}" -path "*/docker/*/${{ env.DOCKER_NAMESPACE }}/*/${{ github.event.release.tag_name }}/build/maven/*.jar" | head -n 1)
103+ fi
104+
105+ # If still not found, try a more aggressive search
106+ if [ -z "$JAR_FILE" ]; then
107+ echo "Still not found, trying broader search..."
108+ JAR_FILE=$(find "${MODULE_PATH}" -name "*.jar" -not -name "*sources*" -not -name "*javadoc*" | head -n 1)
109+ fi
110+
108111 if [ -z "$JAR_FILE" ]; then
109- echo "No repackaged JAR found in $module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/${{ env.TAG_NAME }}/build/maven. Check your build."
112+ echo "No JAR file found! Listing directory structure:"
113+ find "${MODULE_PATH}" -type d | sort
114+ echo "Listing all JAR files:"
115+ find "${MODULE_PATH}" -name "*.jar" | sort
110116 exit 1
111117 fi
112-
113- # Create the maven directory inside the Docker context and copy the JAR there
114- mkdir -p "${{ matrix.path }}/maven"
115- cp "$JAR_FILE" "${{ matrix.path }}/maven/"
116-
117- # Extract the final name without .jar extension
118- FINAL_NAME=$(basename "$JAR_FILE" .jar)
119- echo "FINAL_NAME=${FINAL_NAME}" >> $GITHUB_ENV
120-
121- - name : No-Op for Non-Registry Modules
118+
119+ echo "Found JAR: ${JAR_FILE}"
120+ cp "${JAR_FILE}" "${{ matrix.path }}/maven/"
121+
122+ # Save the JAR name for Docker
123+ JAR_BASENAME=$(basename "${JAR_FILE}" .jar)
124+ echo "FINAL_NAME=${JAR_BASENAME}" >> $GITHUB_ENV
125+
126+ # Process non-registry modules
127+ - name : Process Non-Registry Module
128+ id : non_registry_module
122129 if : " !contains(matrix.name, 'registry')"
123- run : echo "FINAL_NAME=" >> $GITHUB_ENV
124-
125- - name : Set short SHA
126- run : echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
130+ run : |
131+ echo "Processing non-registry module"
132+ echo "FINAL_NAME=" >> $GITHUB_ENV
127133
134+ # Build and push Docker image
128135 - name : Build and Push Docker Image
129136 uses : docker/build-push-action@v6
130137 with :
@@ -133,9 +140,11 @@ jobs:
133140 push : true
134141 platforms : linux/amd64,linux/arm64,linux/arm/v7
135142 tags : |
136- ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:${{ env.TAG_NAME }}
137- build-args : FINAL_NAME=${{ env.FINAL_NAME }}
143+ ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:${{ github.event.release.tag_name }}
144+ build-args : |
145+ FINAL_NAME=${{ env.FINAL_NAME }}
138146
139147 - name : Verify Docker Image
140148 run : |
141- docker pull ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:${{ env.TAG_NAME }}
149+ echo "Verifying Docker image: ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:${{ github.event.release.tag_name }}"
150+ docker pull ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:${{ github.event.release.tag_name }}
0 commit comments