Skip to content

Commit f818311

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

3 files changed

Lines changed: 212 additions & 88 deletions

File tree

.github/workflows/cloudbuild.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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/mvn:3.8-jdk-8'
14+
id: maven-package
15+
entrypoint: 'mvn'
16+
args:
17+
- clean
18+
- -B
19+
- -V
20+
- -DskipTests
21+
- deploy
22+
- -P
23+
- common-artifacts, version-release
24+
- Dgpg.passphrase="$${CDAP_GPG_PASSPHRASE}"
25+
- -Dmaven.wagon.http.retryHandler.count=5
26+
- -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
27+
secretEnv:
28+
- 'CDAP_GPG_PASSPHRASE'
29+
30+
- name: 'bash'
31+
id: create-exit-gate-manifest
32+
entrypoint: 'bash'
33+
args:
34+
- '-c'
35+
- |
36+
set -e
37+
MANIFEST_FILE="/workspace/exit_gate_manifest.textproto"
38+
echo '# -*- protobuffer -*-' > "$${MANIFEST_FILE}"
39+
echo '# proto-file: security/opensource/exit_gate_v1/onboarded/proto/publishing_manifest.proto' >> "$${MANIFEST_FILE}"
40+
echo '# proto-message: PublishingManifest' >> "$${MANIFEST_FILE}"
41+
echo '' >> "$${MANIFEST_FILE}"
42+
echo 'publish_all: true' >> "$${MANIFEST_FILE}"
43+
echo "Created manifest file: $${MANIFEST_FILE}"
44+
waitFor: ['maven-package']
45+
46+
- name: 'gcr.io/cloud-builders/gsutil'
47+
id: upload-exit-gate-manifest
48+
entrypoint: 'bash'
49+
args:
50+
- '-c'
51+
- |
52+
set -e
53+
MANIFEST_FILE="/workspace/exit_gate_manifest.textproto"
54+
# Use a timestamp to create a unique manifest filename for each release
55+
MANIFEST_FILENAME="release_$(date -u +%Y%m%d%H%M%S).textproto"
56+
echo "Uploading manifest to ${_SECURE_PUBLISH_BUCKET}$${MANIFEST_FILENAME}"
57+
gsutil cp "$${MANIFEST_FILE}" "${_SECURE_PUBLISH_BUCKET}$${MANIFEST_FILENAME}"
58+
echo "Manifest uploaded successfully. OSS Exit Gate process should now be triggered."
59+
waitFor: ['create-exit-gate-manifest']
60+
61+
artifacts:
62+
mavenArtifacts:
63+
- repository: 'https://us-maven.pkg.dev/oss-exit-gate-prod/cloud-data-fusion--mavencentral'
64+
deployFolder: '/workspace/target/'
65+
groupId: 'io.cdap.plugin'
66+
artifactId: 'google-cloud'
67+
version: '${_VERSION}'
68+
69+
options:
70+
requestedVerifyOption: VERIFIED
71+
machineType: 'E2_HIGHCPU_32'
72+
73+
substitutions:
74+
_SECURE_PUBLISH_BUCKET: ''
75+
_VERSION: ''
76+
77+
availableSecrets:
78+
secretManager:
79+
- versionName: projects/cdapio-github-builds/secrets/CDAP_GPG_PASSPHRASE/versions/latest
80+
env: 'CDAP_GPG_PASSPHRASE'

.github/workflows/tag-release.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ on:
1717
jobs:
1818

1919
release-job:
20-
runs-on: k8s-runner-build
21-
if: ${{ github.ref_type == 'tag' }}
20+
runs-on: cdapio-hub-k8-runner
21+
# if: ${{ github.ref_type == 'tag' }}
2222
steps:
2323

2424
- name: Get Secrets from GCP Secret Manager
@@ -30,6 +30,7 @@ jobs:
3030
CDAP_OSSRH_PASSWORD:cdapio-github-builds/CDAP_OSSRH_PASSWORD
3131
CDAP_GPG_PASSPHRASE:cdapio-github-builds/CDAP_GPG_PASSPHRASE
3232
CDAP_GPG_PRIVATE_KEY:cdapio-github-builds/CDAP_GPG_PRIVATE_KEY
33+
SECURE_PUBLISH_BUCKET:cdapio-github-builds/publish_bucket
3334
3435
- name: Checkout Repository
3536
uses: actions/checkout@v4
@@ -59,10 +60,27 @@ jobs:
5960
- name: Run tests
6061
run: mvn clean test -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
6162

62-
- name: Publish to Maven Central
63+
- name: Get Project Version
64+
id: get_version
65+
working-directory: google-cloud
66+
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
67+
68+
- name: Publish SNAPSHOT to Maven Central
69+
if: ${{ endsWith(steps.get_version.outputs.VERSION, '-SNAPSHOT') }}
6370
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
6471
env:
6572
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
6673
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
6774
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
68-
MAVEN_OPTS: '-Xmx3200m'
75+
MAVEN_OPTS: '-Xmx3200m'
76+
77+
- name: Submit Build to GCB
78+
if: ${{ ! endsWith(steps.get_version.outputs.VERSION, '-SNAPSHOT') }}
79+
id: gcb
80+
working-directory: google-cloud
81+
run: |
82+
gcloud builds submit . \
83+
--config=cloudbuild-release.yaml \
84+
--project='cdapio-github-builds' \
85+
--substitutions="_VERSION=${{steps.get_version.outputs.VERSION}},_SECURE_PUBLISH_BUCKET=${{steps.secrets.outputs.SECURE_PUBLISH_BUCKET}}"
86+

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/komalyd-dev/my-test-maven-repo</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)