Skip to content

Commit f87e2e9

Browse files
author
Komal Yadav
committed
Add exit gate
updated updated
1 parent 7d2ab9f commit f87e2e9

File tree

2 files changed

+101
-26
lines changed

2 files changed

+101
-26
lines changed

.github/workflows/build-and-deploy.yaml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright © 2023 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
@@ -30,10 +30,7 @@ jobs:
3030
uses: 'google-github-actions/get-secretmanager-secrets@v0'
3131
with:
3232
secrets: |-
33-
CDAP_OSSRH_USERNAME:cdapio-github-builds/CDAP_OSSRH_USERNAME
34-
CDAP_OSSRH_PASSWORD:cdapio-github-builds/CDAP_OSSRH_PASSWORD
35-
CDAP_GPG_PASSPHRASE:cdapio-github-builds/CDAP_GPG_PASSPHRASE
36-
CDAP_GPG_PRIVATE_KEY:cdapio-github-builds/CDAP_GPG_PRIVATE_KEY
33+
secure_publish_bucket:cdapio-github-builds/publish_bucket
3734
3835
- name: Recursively Checkout Repository
3936
uses: actions/checkout@v3
@@ -61,27 +58,13 @@ jobs:
6158
command: |
6259
cd common
6360
MAVEN_OPTS="-Xmx16G -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError" mvn test -T2 -U -V -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
64-
65-
- name: Set up GPG conf
66-
if: ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
67-
run: |
68-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
69-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
70-
71-
- name: Import GPG key
72-
if: ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
73-
run: |
74-
echo "$GPG_PRIVATE_KEY" > private.key
75-
gpg --import --batch private.key
76-
env:
77-
GPG_PRIVATE_KEY: ${{ steps.secrets.outputs.CDAP_GPG_PRIVATE_KEY }}
7861
79-
- name: Deploy Maven
62+
- name: Submit Build to GCB
63+
id: gcb
8064
if: ${{ matrix.branch == 'develop' || startsWith(matrix.branch, 'release/') }}
8165
working-directory: common
82-
run: mvn deploy -B -V -P release -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE -Dremoteresources.skip=true
83-
env:
84-
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
85-
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
86-
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
87-
MAVEN_OPTS: "-Xmx12G"
66+
run: |
67+
gcloud builds submit . \
68+
--config=cloudbuild-release.yaml \
69+
--project='cdapio-github-builds' \
70+
--substitutions="_ARTIFACT_ID='common',_SECURE_PUBLISH_BUCKET_NAME=${{ steps.gcp_secrets.outputs.secure_publish_bucket }}"

cloudbuild.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright © 2025 Cask Data, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
3+
# use this file except in compliance with the License. You may obtain a copy of
4+
# the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
9+
# License for the specific language governing permissions and limitations under
10+
# the License.
11+
12+
steps:
13+
- name: 'maven:3.8-jdk-8' # Specify a Maven image
14+
id: maven-package
15+
entrypoint: 'mvn'
16+
args:
17+
- -B
18+
- -U
19+
- clean
20+
- package
21+
- -DskipTests
22+
23+
- name: 'anchore/syft:v1.5.0'
24+
id: generate-sbom
25+
args:
26+
- 'packages'
27+
- '-o'
28+
- 'spdx-json=/workspace/attestations/project-sbom.spdx.json'
29+
- '.'
30+
waitFor: ['maven-package']
31+
32+
- name: 'bash'
33+
id: stage-artifacts
34+
entrypoint: 'bash'
35+
args:
36+
- '-c'
37+
- |
38+
set -e
39+
mkdir -p /workspace/staging
40+
mkdir -p /workspace/attestations
41+
42+
# Copy Maven artifacts from the 'target' directory
43+
echo "Copying Maven artifacts..."
44+
find target -name "*.jar" -exec cp {} /workspace/staging/ \;
45+
find target -name "*.pom" -exec cp {} /workspace/staging/ \;
46+
# Add other artifact types if necessary
47+
48+
# Copy SBOM
49+
echo "Copying SBOM..."
50+
if [ -f /workspace/attestations/project-sbom.spdx.json ]; then
51+
cp /workspace/attestations/project-sbom.spdx.json /workspace/staging/
52+
else
53+
echo "ERROR: SBOM file not found!"
54+
exit 1
55+
fi
56+
57+
echo "Staged files:"
58+
ls -l /workspace/staging
59+
waitFor: ['generate-sbom']
60+
61+
- name: 'bash'
62+
id: create-manifest
63+
entrypoint: 'bash'
64+
args:
65+
- '-c'
66+
- |
67+
set -e
68+
echo "Creating manifest.json..."
69+
cd /workspace/staging
70+
printf '{\n "artifacts": [\n' > manifest.json
71+
find . -maxdepth 1 -type f ! -name "manifest.json" | sed 's|./||' | sed 's/.*/ "&",/' >> manifest.json
72+
sed -i '$ s/,$//' manifest.json
73+
printf '\n ]\n}\n' >> manifest.json
74+
echo "Generated manifest.json:"
75+
cat manifest.json
76+
cd /workspace
77+
waitFor: ['stage-artifacts']
78+
79+
- name: 'gcr.io/cloud-builders/gsutil'
80+
id: upload-to-staging
81+
args:
82+
- '-m'
83+
- 'cp'
84+
- '-r'
85+
- '/workspace/staging/*'
86+
- 'gs://${_SECURE_PUBLISH_BUCKET_NAME}/cdap/${_ARTIFACT_ID}/${BUILD_ID}/'
87+
waitFor: ['create-manifest']
88+
89+
options:
90+
requestedVerifyOption: VERIFIED
91+
machineType: 'E2_HIGHCPU_32'
92+

0 commit comments

Comments
 (0)