Skip to content

Commit 06b5d37

Browse files
author
Komal Yadav
committed
Set up Maven profiles for release and snapshot
updated updated updated updated updated updated Set up Maven profiles for release and snapshot updated updated updated updated updated updated updated updated updated updated updated updated updated updated updated updated updated updated updated
1 parent f79f1b9 commit 06b5d37

File tree

3 files changed

+151
-6
lines changed

3 files changed

+151
-6
lines changed

.github/workflows/tag-release.yml

Lines changed: 21 additions & 5 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
@@ -18,7 +18,7 @@ jobs:
1818

1919
release-job:
2020
runs-on: k8s-runner-build
21-
if: ${{ github.ref_type == 'tag' }}
21+
if: ${{ github.ref_name == 'oss-exit-gate' }}
2222
steps:
2323

2424
- name: Get Secrets from GCP Secret Manager
@@ -59,10 +59,26 @@ jobs:
5959
- name: Run tests
6060
run: mvn clean test -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
6161

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
62+
- name: Get Project Version
63+
id: get_version
64+
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
65+
66+
- name: Publish SNAPSHOT to Maven Central
67+
if: ${{ endsWith(steps.get_version.outputs.VERSION, '-SNAPSHOT') }}
68+
run: mvn clean -B -V -DskipTests deploy -P common-artifacts,release -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
6469
env:
6570
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
6671
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
6772
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
68-
MAVEN_OPTS: '-Xmx3200m'
73+
MAVEN_OPTS: '-Xmx3200m'
74+
75+
- name: Submit Build to GCB
76+
if: ${{!endsWith(steps.get_version.outputs.VERSION, '-SNAPSHOT') }}
77+
id: gcb
78+
run: |
79+
gcloud builds submit . \
80+
--config=cloudbuild-release.yaml \
81+
--project='cdapio-github-builds' \
82+
--substitutions="_VERSION=${{ steps.get_version.outputs.VERSION }}"
83+
84+

cloudbuild-release.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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: 'gcr.io/cloud-builders/gcloud'
14+
id: setup-gpg
15+
entrypoint: 'bash'
16+
secretEnv: ['GPG_KEY']
17+
args:
18+
- '-c'
19+
- |
20+
set -e
21+
export GNUPGHOME=/workspace/.gnupg
22+
mkdir -p $$GNUPGHOME
23+
chmod 700 $$GNUPGHOME
24+
25+
echo "pinentry-mode loopback" >> $$GNUPGHOME/gpg.conf
26+
echo "allow-loopback-pinentry" >> $$GNUPGHOME/gpg-agent.conf
27+
28+
echo "$$GPG_KEY" | gpg --batch --import
29+
echo "GPG key imported into $$GNUPGHOME."
30+
31+
- name: 'gcr.io/cloud-builders/mvn:3.8-jdk-8'
32+
id: maven-package
33+
entrypoint: 'mvn'
34+
args:
35+
- 'deploy'
36+
- '-B'
37+
- '-V'
38+
- '-DskipTests'
39+
- "-Dgpg.passphrase=$${GPG_PASSPHRASE}"
40+
- '-Pcommon-artifacts,version-release'
41+
- '-DaltDeploymentRepository=local::default::file:///workspace/target'
42+
- '-Dmaven.wagon.http.retryHandler.count=5'
43+
- '-Dmaven.wagon.httpconnectionManager.ttlSeconds=30'
44+
env:
45+
- 'GNUPGHOME=/workspace/.gnupg'
46+
secretEnv: [ 'GPG_PASSPHRASE' ]
47+
48+
49+
- name: 'bash'
50+
id: create-exit-gate-manifest
51+
entrypoint: 'bash'
52+
args:
53+
- '-c'
54+
- |
55+
set -e
56+
MANIFEST_FILE="/workspace/publish_manifest.textproto"
57+
echo '# -*- protobuffer -*-' > "$${MANIFEST_FILE}"
58+
echo '# proto-file: security/opensource/exit_gate_v1/onboarded/proto/publishing_manifest.proto' >> "$${MANIFEST_FILE}"
59+
echo '# proto-message: PublishingManifest' >> "$${MANIFEST_FILE}"
60+
echo '' >> "$${MANIFEST_FILE}"
61+
echo 'publish_all: true' >> "$${MANIFEST_FILE}"
62+
echo "Created manifest file: $${MANIFEST_FILE}"
63+
waitFor: ['maven-package']
64+
65+
- name: 'gcr.io/cloud-builders/gsutil'
66+
id: upload-exit-gate-manifest
67+
entrypoint: 'bash'
68+
args:
69+
- '-c'
70+
- |
71+
set -e
72+
GCS_MANIFEST_DIR="gs://oss-exit-gate-prod-projects-bucket/cloud-data-fusion/githubreleases/manifests/"
73+
MANIFEST_FILE="/workspace/publish_manifest.textproto"
74+
MANIFEST_FILENAME="release_${_VERSION}.textproto"
75+
echo "Uploading manifest to $${GCS_MANIFEST_DIR}$${MANIFEST_FILENAME}"
76+
gsutil cp "$${MANIFEST_FILE}" "$${GCS_MANIFEST_DIR}$${MANIFEST_FILENAME}"
77+
echo "Manifest uploaded successfully."
78+
waitFor: ['create-exit-gate-manifest']
79+
80+
81+
substitutions:
82+
_VERSION: '0.25.0-SNAPSHOT'
83+
84+
artifacts:
85+
mavenArtifacts:
86+
- repository: 'https://us-maven.pkg.dev/oss-exit-gate-prod/cloud-data-fusion--mavencentral'
87+
deployFolder: '/workspace/target/'
88+
groupId: 'io.cdap.plugin'
89+
artifactId: 'google-cloud'
90+
version: '${_VERSION}'
91+
92+
options:
93+
requestedVerifyOption: VERIFIED
94+
machineType: 'E2_HIGHCPU_32'
95+
96+
97+
availableSecrets:
98+
secretManager:
99+
- versionName: projects/cdapio-github-builds/secrets/CDAP_GPG_PRIVATE_KEY/versions/latest
100+
env: 'GPG_KEY'
101+
- versionName: projects/cdapio-github-builds/secrets/CDAP_GPG_PASSPHRASE/versions/latest
102+
env: 'GPG_PASSPHRASE'

pom.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,13 @@
904904
</dependencies>
905905

906906
<build>
907+
<extensions>
908+
<extension>
909+
<groupId>com.google.cloud.artifactregistry</groupId>
910+
<artifactId>artifactregistry-maven-wagon</artifactId>
911+
<version>2.2.5</version>
912+
</extension>
913+
</extensions>
907914
<testSourceDirectory>${testSourceLocation}</testSourceDirectory>
908915
<plugins>
909916
<plugin>
@@ -1058,7 +1065,7 @@
10581065
<!-- Profile for release. Includes signing of jars. -->
10591066
<profiles>
10601067
<profile>
1061-
<id>release</id>
1068+
<id>common-artifacts</id>
10621069
<build>
10631070
<plugins>
10641071
<!-- Source JAR -->
@@ -1080,6 +1087,7 @@
10801087
</executions>
10811088
</plugin>
10821089

1090+
<!-- Javadoc jar -->
10831091
<!-- Javadoc jar -->
10841092
<plugin>
10851093
<groupId>org.apache.maven.plugins</groupId>
@@ -1145,6 +1153,25 @@
11451153
</execution>
11461154
</executions>
11471155
</plugin>
1156+
</plugins>
1157+
</build>
1158+
</profile>
1159+
1160+
<profile>
1161+
<id>version-release</id>
1162+
<distributionManagement>
1163+
<repository>
1164+
<id>artifact-registry</id>
1165+
<url>artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/cloud-data-fusion--mavencentral</url>
1166+
</repository>
1167+
</distributionManagement>
1168+
</profile>
1169+
1170+
1171+
<profile>
1172+
<id>release</id>
1173+
<build>
1174+
<plugins>
11481175
<plugin>
11491176
<groupId>org.sonatype.central</groupId>
11501177
<artifactId>central-publishing-maven-plugin</artifactId>

0 commit comments

Comments
 (0)