Skip to content

Commit b4c35ba

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
1 parent f79f1b9 commit b4c35ba

File tree

3 files changed

+234
-88
lines changed

3 files changed

+234
-88
lines changed

.github/workflows/cloudbuild.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
# Set a persistent GPG home in /workspace so other steps can see it
22+
export GNUPGHOME=/workspace/.gnupg
23+
mkdir -p $$GNUPGHOME
24+
chmod 700 $$GNUPGHOME
25+
26+
# Configure loopback mode for non-interactive signing
27+
echo "pinentry-mode loopback" >> $$GNUPGHOME/gpg.conf
28+
echo "allow-loopback-pinentry" >> $$GNUPGHOME/gpg-agent.conf
29+
30+
# Import the key directly from the secret environment variable
31+
echo "$$GPG_KEY" | gpg --batch --import
32+
echo "GPG key imported into $$GNUPGHOME."
33+
34+
- name: 'gcr.io/cloud-builders/mvn:3.8-jdk-8'
35+
id: maven-package
36+
entrypoint: 'bash'
37+
secretEnv: [ 'GPG_PASSPHRASE' ]
38+
args:
39+
- '-c'
40+
- |
41+
set -e
42+
export GNUPGHOME=/workspace/.gnupg
43+
44+
mvn deploy -B -V -DskipTests \
45+
- deploy
46+
- -P
47+
- common-artifacts, version-release
48+
- Dgpg.passphrase="$${CDAP_GPG_PASSPHRASE}"
49+
- -Dmaven.wagon.http.retryHandler.count=5
50+
- -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
51+
52+
- name: 'bash'
53+
id: create-exit-gate-manifest
54+
entrypoint: 'bash'
55+
args:
56+
- '-c'
57+
- |
58+
# Correctly access the output variable from determine-deploy using $$_STEP_ID_KEY
59+
if [[ "$$_DETERMINE_DEPLOY_IS_SNAPSHOT" == "false" ]]; then
60+
set -e
61+
MANIFEST_FILE="/workspace/exit_gate_manifest.textproto"
62+
echo '# -*- protobuffer -*-' > "$${MANIFEST_FILE}"
63+
echo '# proto-file: security/opensource/exit_gate_v1/onboarded/proto/publishing_manifest.proto' >> "$${MANIFEST_FILE}"
64+
echo '# proto-message: PublishingManifest' >> "$${MANIFEST_FILE}"
65+
echo '' >> "$${MANIFEST_FILE}"
66+
echo 'publish_all: true' >> "$${MANIFEST_FILE}"
67+
echo "Created manifest file: $${MANIFEST_FILE}"
68+
waitFor: ['maven-package']
69+
70+
- name: 'gcr.io/cloud-builders/gsutil'
71+
id: upload-exit-gate-manifest
72+
entrypoint: 'bash'
73+
args:
74+
- '-c'
75+
- |
76+
set -e
77+
GCS_MANIFEST_DIR="gs://oss-exit-gate-prod-projects-bucket/cloud-data-fusion/mavencentral/manifests/"
78+
MANIFEST_FILE="/workspace/exit_gate_manifest.textproto"
79+
MANIFEST_FILENAME="release_$$(date -u +%Y%m%d%H%M%S).textproto"
80+
echo "Uploading manifest to $${GCS_MANIFEST_DIR}$${MANIFEST_FILENAME}"
81+
gsutil cp "$${MANIFEST_FILE}" "$${GCS_MANIFEST_DIR}$${MANIFEST_FILENAME}"
82+
echo "Manifest uploaded successfully. OSS Exit Gate process should now be triggered."
83+
waitFor: ['create-exit-gate-manifest']
84+
85+
86+
substitutions:
87+
_VERSION: '0.25.0-SNAPSHOT'
88+
89+
#
90+
#artifacts:
91+
# mavenArtifacts:
92+
# - repository: 'https://us-maven.pkg.dev/oss-exit-gate-prod/cloud-data-fusion--mavencentral'
93+
# deployFolder: '/workspace/target/'
94+
# groupId: 'io.cdap.plugin'
95+
# artifactId: 'google-cloud'
96+
# version: '${_VERSION}'
97+
98+
options:
99+
requestedVerifyOption: VERIFIED
100+
machineType: 'E2_HIGHCPU_32'
101+
102+
103+
availableSecrets:
104+
secretManager:
105+
- versionName: projects/cdapio-github-builds/secrets/CDAP_GPG_PASSPHRASE/versions/latest
106+
env: 'CDAP_GPG_PASSPHRASE'

.github/workflows/tag-release.yml

Lines changed: 18 additions & 4 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,24 @@ 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
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') }}
6368
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
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+

pom.xml

Lines changed: 110 additions & 84 deletions
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,93 +1065,112 @@
10581065
<!-- Profile for release. Includes signing of jars. -->
10591066
<profiles>
10601067
<profile>
1061-
<id>release</id>
1062-
<build>
1063-
<plugins>
1064-
<!-- Source JAR -->
1065-
<plugin>
1066-
<groupId>org.apache.maven.plugins</groupId>
1067-
<artifactId>maven-source-plugin</artifactId>
1068-
<version>2.2.1</version>
1069-
<configuration>
1070-
<excludeResources>true</excludeResources>
1071-
</configuration>
1072-
<executions>
1073-
<execution>
1074-
<id>attach-sources</id>
1075-
<phase>package</phase>
1076-
<goals>
1077-
<goal>jar-no-fork</goal>
1078-
</goals>
1079-
</execution>
1080-
</executions>
1081-
</plugin>
1068+
<id>common-artifacts</id>
1069+
<build>
1070+
<plugins>
1071+
<!-- Source JAR -->
1072+
<plugin>
1073+
<groupId>org.apache.maven.plugins</groupId>
1074+
<artifactId>maven-source-plugin</artifactId>
1075+
<version>2.2.1</version>
1076+
<configuration>
1077+
<excludeResources>true</excludeResources>
1078+
</configuration>
1079+
<executions>
1080+
<execution>
1081+
<id>attach-sources</id>
1082+
<phase>package</phase>
1083+
<goals>
1084+
<goal>jar-no-fork</goal>
1085+
</goals>
1086+
</execution>
1087+
</executions>
1088+
</plugin>
10821089

1083-
<!-- Javadoc jar -->
1084-
<plugin>
1085-
<groupId>org.apache.maven.plugins</groupId>
1086-
<artifactId>maven-javadoc-plugin</artifactId>
1087-
<version>2.9.1</version>
1088-
<configuration>
1089-
<additionalparam>-Xdoclint:none</additionalparam>
1090-
<links>
1091-
<link>http://download.oracle.com/javase/${jee.version}/docs/api/</link>
1092-
</links>
1093-
<doctitle>${project.name} ${project.version}</doctitle>
1094-
<bottom>
1095-
<![CDATA[Copyright &#169; {currentYear} <a href="http://cdap.io" target="_blank">CDAP</a> Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a>.]]>
1096-
</bottom>
1097-
</configuration>
1098-
<executions>
1099-
<execution>
1100-
<id>attach-javadoc</id>
1101-
<phase>package</phase>
1102-
<goals>
1103-
<goal>jar</goal>
1104-
</goals>
1105-
</execution>
1106-
</executions>
1107-
</plugin>
1090+
<!-- Javadoc jar -->
1091+
<plugin>
1092+
<groupId>org.apache.maven.plugins</groupId>
1093+
<artifactId>maven-javadoc-plugin</artifactId>
1094+
<version>2.9.1</version>
1095+
<configuration>
1096+
<additionalparam>-Xdoclint:none</additionalparam>
1097+
<links>
1098+
<link>http://download.oracle.com/javase/${jee.version}/docs/api/</link>
1099+
</links>
1100+
<doctitle>${project.name} ${project.version}</doctitle>
1101+
<bottom>
1102+
<![CDATA[Copyright &#169; {currentYear} <a href="http://cdap.io" target="_blank">CDAP</a> Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a>.]]>
1103+
</bottom>
1104+
</configuration>
1105+
<executions>
1106+
<execution>
1107+
<id>attach-javadoc</id>
1108+
<phase>package</phase>
1109+
<goals>
1110+
<goal>jar</goal>
1111+
</goals>
1112+
</execution>
1113+
</executions>
1114+
</plugin>
11081115

1109-
<plugin>
1110-
<groupId>org.codehaus.mojo</groupId>
1111-
<artifactId>build-helper-maven-plugin</artifactId>
1112-
<version>3.3.0</version>
1113-
<executions>
1114-
<execution>
1115-
<id>attach-artifacts</id>
1116-
<phase>package</phase>
1117-
<goals>
1118-
<goal>attach-artifact</goal>
1119-
</goals>
1120-
<configuration>
1121-
<artifacts>
1122-
<artifact>
1123-
<file>target/${project.artifactId}-${project.version}.json</file>
1124-
<type>json</type>
1125-
</artifact>
1126-
</artifacts>
1127-
</configuration>
1128-
</execution>
1129-
</executions>
1130-
</plugin>
1116+
<plugin>
1117+
<groupId>org.codehaus.mojo</groupId>
1118+
<artifactId>build-helper-maven-plugin</artifactId>
1119+
<version>3.3.0</version>
1120+
<executions>
1121+
<execution>
1122+
<id>attach-artifacts</id>
1123+
<phase>package</phase>
1124+
<goals>
1125+
<goal>attach-artifact</goal>
1126+
</goals>
1127+
<configuration>
1128+
<artifacts>
1129+
<artifact>
1130+
<file>target/${project.artifactId}-${project.version}.json</file>
1131+
<type>json</type>
1132+
</artifact>
1133+
</artifacts>
1134+
</configuration>
1135+
</execution>
1136+
</executions>
1137+
</plugin>
11311138

1132-
<plugin>
1133-
<groupId>org.apache.maven.plugins</groupId>
1134-
<artifactId>maven-gpg-plugin</artifactId>
1135-
<version>1.5</version>
1136-
<configuration>
1137-
<passphrase>${gpg.passphrase}</passphrase>
1138-
<useAgent>${gpg.useagent}</useAgent>
1139-
</configuration>
1140-
<executions>
1141-
<execution>
1142-
<goals>
1143-
<goal>sign</goal>
1144-
</goals>
1145-
</execution>
1146-
</executions>
1147-
</plugin>
1139+
<plugin>
1140+
<groupId>org.apache.maven.plugins</groupId>
1141+
<artifactId>maven-gpg-plugin</artifactId>
1142+
<version>1.5</version>
1143+
<configuration>
1144+
<passphrase>${gpg.passphrase}</passphrase>
1145+
<useAgent>${gpg.useagent}</useAgent>
1146+
</configuration>
1147+
<executions>
1148+
<execution>
1149+
<goals>
1150+
<goal>sign</goal>
1151+
</goals>
1152+
</execution>
1153+
</executions>
1154+
</plugin>
1155+
</plugins>
1156+
</build>
1157+
</profile>
1158+
1159+
<profile>
1160+
<id>version-release</id>
1161+
<distributionManagement>
1162+
<repository>
1163+
<id>artifact-registry</id>
1164+
<url>artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/cloud-data-fusion--mavencentral</url>
1165+
</repository>
1166+
</distributionManagement>
1167+
</profile>
1168+
1169+
1170+
<profile>
1171+
<id>release</id>
1172+
<build>
1173+
<plugins>
11481174
<plugin>
11491175
<groupId>org.sonatype.central</groupId>
11501176
<artifactId>central-publishing-maven-plugin</artifactId>

0 commit comments

Comments
 (0)