1- # Copyright © 2022 Cask Data, Inc.
1+ # Copyright © 2025 Cask Data, Inc.
22# Licensed under the Apache License, Version 2.0 (the "License"); you may not
33# use this file except in compliance with the License. You may obtain a copy of
44# the License at
8585 if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
8686 with :
8787 secrets : |-
88- CDAP_OSSRH_USERNAME:cdapio-github-builds/CDAP_OSSRH_USERNAME
89- CDAP_OSSRH_PASSWORD:cdapio-github-builds/CDAP_OSSRH_PASSWORD
90- CDAP_GPG_PASSPHRASE:cdapio-github-builds/CDAP_GPG_PASSPHRASE
91- CDAP_GPG_PRIVATE_KEY:cdapio-github-builds/CDAP_GPG_PRIVATE_KEY
88+ artifacts_bucket:cdapio-github-builds/artifacts_bucket
89+ secure_publish_bucket:cdapio-github-builds/publish_bucket
9290
9391 - name : Recursively Checkout Repository
9492 uses : actions/checkout@v4
@@ -151,18 +149,6 @@ jobs:
151149 commit : ${{ github.sha }}
152150 check_name : Test Report - ${{ env.ARTIFACT_NAME }}
153151
154- - name : Build Standalone
155- # Pinned version 2.8.2
156- uses : nick-fields/retry@3e91a01664abd3c5cd539100d10d33b9c5b68482
157- with :
158- timeout_minutes : 60
159- max_attempts : 3
160- retry_on : error
161- on_retry_command : echo "Build Standalone failed in this attempt, retrying ..."
162- command : |
163- cd cdap-build
164- MAVEN_OPTS="-Xmx12G" mvn -e -T2 clean package -Dgpg.skip -DskipTests -Ddocker.skip=true -nsu -am -amd -P templates,dist,release -Dadditional.artifacts.dir=$(pwd)/app-artifacts -Dsecurity.extensions.dir=$(pwd)/security-extensions -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
165-
166152 - name : Find Build Version
167153 working-directory : cdap-build/cdap
168154 run : |
@@ -180,74 +166,43 @@ jobs:
180166 echo "Release will be overwritten if exists."
181167 fi
182168
183- - name : Upload CDAP Standalone
184- if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
185- uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact#zipped-artifact-downloads
186- with :
187- name : cdap-sandbox-${{env.CDAP_VERSION}}.zip
188- path : cdap-build/cdap/cdap-standalone/target/cdap-sandbox-${{env.CDAP_VERSION}}.zip
189-
190- - name : Set up GPG conf
191- if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
169+ - name : Submit Build to GCB
170+ id : gcb
171+ working-directory : cdap-build
192172 run : |
193- echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
194- echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
173+ BUILD_OUTPUT=$(gcloud builds submit . \
174+ --config=cloudbuild-release.yaml \
175+ --project='${{ env.GCP_PROJECT_ID }}' \
176+ --substitutions="_ARTIFACT_ID=cdap-build,_SECURE_PUBLISH_BUCKET_NAME=${{ steps.gcp_secrets.outputs.secure_publish_bucket }},_CDAP_VERSION=${{ env.CDAP_VERSION }}" 2>&1)
177+ echo "$BUILD_OUTPUT"
178+ BUILD_ID=$(echo "$BUILD_OUTPUT" | grep -oP 'ID: \K[a-f0-9-]+' | head -n 1)
179+ if [ -z "$BUILD_ID" ]; then
180+ echo "Failed to extract BUILD_ID from gcloud output." >&2
181+ # Fallback: Get the last build submitted by this service account.
182+ # This assumes no other concurrent builds are started by this SA.
183+ BUILD_ID=$(gcloud builds list --project='${{ env.GCP_PROJECT_ID }}' --limit=1 --format='value(ID)' --filter="buildTriggerId='' AND status!=WORKING AND status!=QUEUED" --sort-by=~CREATE_TIME)
184+ if [ -z "$BUILD_ID" ]; then
185+ echo "Fallback failed to get BUILD_ID." >&2
186+ exit 1
187+ fi
188+ echo "Fallback BUILD_ID: $BUILD_ID"
189+ fi
190+ echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT
191+ echo "GCB Build ID: $BUILD_ID"
195192
196- - name : Import GPG key
193+ - name : Create Download Directory
197194 if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
198- run : |
199- echo "$GPG_PRIVATE_KEY" > private.key
200- gpg --import --batch private.key
201- env :
202- GPG_PRIVATE_KEY : ${{ steps.secrets.outputs.CDAP_GPG_PRIVATE_KEY }}
195+ run : mkdir -p downloads
203196
204- - name : Maven Deploy
197+ - name : Download CDAP Standalone from GCS
198+ if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
205199 run : |
206- cd cdap-build
207- if [[ (${{ matrix.branch }} == "develop") || (${{ matrix.branch }} == release/*) ]];
208- then
209- retry_count=0
210- failed_module=""
211- while [ $retry_count -lt 3 ]; do
212- if [ -n "$failed_module" ];
213- then
214- build_output=$(mvn deploy -B -V -DskipTests -DskipLocalStaging=true -Ddocker.skip=true -P templates,dist,release,rpm-prepare,rpm,deb-prepare,deb,tgz,unit-tests -Dadditional.artifacts.dir=$(pwd)/app-artifacts -Dsecurity.extensions.dir=$(pwd)/security-extensions -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE -rf :"$failed_module" 2>&1 || true)
215- else
216- build_output=$(mvn deploy -B -V -DskipTests -DskipLocalStaging=true -Ddocker.skip=true -P templates,dist,release,rpm-prepare,rpm,deb-prepare,deb,tgz,unit-tests -Dadditional.artifacts.dir=$(pwd)/app-artifacts -Dsecurity.extensions.dir=$(pwd)/security-extensions -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE 2>&1 || true)
217- fi
218- echo "$build_output"
219- if [ $(echo "$build_output" | grep -c "BUILD FAILURE") -gt 0 ];
220- then
221- echo "[WARNING] Deployment failed, retrying..."
222- failed_module=$(echo "$build_output" | grep -e 'mvn <args> -rf' | sed -n 's/.*mvn <args> -rf ://p')
223- echo "[INFO] FAILED MODULE = $failed_module"
224- retry_count=$((retry_count + 1))
225- else
226- echo "[INFO] Deployment successful"
227- break
228- fi
229- done
230- if [ $retry_count -ge 3 ];
231- then
232- echo "[ERROR] Max retries reached..., deployment failed"
233- exit 1
234- fi
235- else
236- mvn verify -B -V -T2 -DskipTests -Dgpg.skip -Ddocker.skip=true -P templates,dist,release,rpm-prepare,rpm,deb-prepare,deb,tgz,unit-tests -Dadditional.artifacts.dir=$(pwd)/app-artifacts -Dsecurity.extensions.dir=$(pwd)/security-extensions -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true
237- fi
238- env :
239- CDAP_OSSRH_USERNAME : ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
240- CDAP_OSSRH_PASSWORD : ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
241- CDAP_GPG_PASSPHRASE : ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
242- MAVEN_OPTS : " -Xmx12G"
200+ gsutil cp gs://${{ steps.gcp_secrets.outputs.secure_publish_bucket }}/cdap/cdap/${{ steps.gcb.outputs.build_id }}/cdap-sandbox-${{ env.CDAP_VERSION }}.zip downloads/
243201
244- - name : Build DEB Bundle
245- working-directory : cdap-build/cdap
202+ - name : Download CDAP DEB Bundle from GCS
203+ if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
246204 run : |
247- mkdir -p cdap-distributions/target/deb-bundle-tmp
248- cd cdap-distributions/target/deb-bundle-tmp
249- cp ../../../*/target/*.deb .
250- tar zcf ../cdap-distributed-deb-bundle-${{env.CDAP_VERSION}}.tgz *.deb
205+ gsutil cp gs://${{ steps.gcp_secrets.outputs.secure_publish_bucket }}/cdap/cdap/${{ steps.gcb.outputs.build_id }}/cdap-distributed-deb-bundle-${{ env.CDAP_VERSION }}.tgz downloads/
251206
252207 - name : Set Up Tag
253208 working-directory : cdap-build
@@ -270,6 +225,17 @@ jobs:
270225 git push -f origin refs/tags/${{ env.TAG_NAME }}:refs/tags/${{ env.TAG_NAME }}
271226 fi
272227
228+ - name : ' Download Artifacts from Cloud Storage'
229+ if : ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
230+ working-directory : cdap-build
231+ run : |
232+ GCS_STAGING_PATH="${{ env.ARTIFACTS_BUCKET }}"
233+ CDAP_VERSION="${{ env.CDAP_VERSION }}"
234+ mkdir -p cdap/cdap-standalone/target
235+ mkdir -p cdap/cdap-distributions/target
236+ gsutil cp "${GCS_STAGING_PATH}/cdap-sandbox-${CDAP_VERSION}.zip" cdap/cdap-standalone/target/
237+ gsutil cp "${GCS_STAGING_PATH}/cdap-distributed-deb-bundle-${CDAP_VERSION}.tgz" cdap/cdap-distributions/target/
238+
273239 - name : Upload CDAP Standalone and CDAP DEB Bundle
274240 # Pinned 1.14.0 version
275241 uses : ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
0 commit comments