Skip to content

Commit bba47f2

Browse files
author
Komal Yadav
committed
Add exit gate
updated updated updatex updated updated updated updated updated
1 parent 63524d1 commit bba47f2

File tree

2 files changed

+103
-24
lines changed

2 files changed

+103
-24
lines changed

.github/workflows/tag-release.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
@@ -26,10 +26,7 @@ jobs:
2626
uses: 'google-github-actions/get-secretmanager-secrets@v0'
2727
with:
2828
secrets: |-
29-
CDAP_OSSRH_USERNAME:cdapio-github-builds/CDAP_OSSRH_USERNAME
30-
CDAP_OSSRH_PASSWORD:cdapio-github-builds/CDAP_OSSRH_PASSWORD
31-
CDAP_GPG_PASSPHRASE:cdapio-github-builds/CDAP_GPG_PASSPHRASE
32-
CDAP_GPG_PRIVATE_KEY:cdapio-github-builds/CDAP_GPG_PRIVATE_KEY
29+
secure_publish_bucket:cdapio-github-builds/publish_bucket
3330
3431
- name: Checkout Repository
3532
uses: actions/checkout@v4
@@ -44,25 +41,15 @@ jobs:
4441
restore-keys: |
4542
${{ runner.os }}-maven-${{ github.workflow }}
4643
47-
- name: Set up GPG conf
48-
run: |
49-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
50-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
51-
52-
- name: Import GPG key
53-
run: |
54-
echo "$GPG_PRIVATE_KEY" > private.key
55-
gpg --import --batch private.key
56-
env:
57-
GPG_PRIVATE_KEY: ${{ steps.secrets.outputs.CDAP_GPG_PRIVATE_KEY }}
58-
5944
- name: Run tests
6045
run: mvn clean test -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
6146

62-
- name: Publish to Maven Central
63-
run: mvn clean -B -V -DskipTests deploy -P release -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
64-
env:
65-
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
66-
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
67-
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
68-
MAVEN_OPTS: '-Xmx3200m'
47+
- name: Submit Build to GCB
48+
id: gcb
49+
working-directory: google-cloud
50+
run: |
51+
gcloud builds submit . \
52+
--config=cloudbuild-release.yaml \
53+
--project='cdapio-github-builds' \
54+
--substitutions="_ARTIFACT_ID='google-cloud',_SECURE_PUBLISH_BUCKET_NAME=${{ steps.gcp_secrets.outputs.secure_publish_bucket }}"
55+

cloudbuild-release.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}/${_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)