Skip to content

Commit 8e6ce3a

Browse files
authored
ci: profile to upload to GCP Artifact Registry (#1132)
* ci: profile to upload to GCP Artifact Registry * A profile to avoid using nexus-staging-maven-plugin
1 parent b57299e commit 8e6ce3a

File tree

2 files changed

+93
-16
lines changed

2 files changed

+93
-16
lines changed

google-oauth-client-bom/pom.xml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@
8989
</dependencyManagement>
9090
<build>
9191
<plugins>
92-
<plugin>
93-
<groupId>org.sonatype.plugins</groupId>
94-
<artifactId>nexus-staging-maven-plugin</artifactId>
95-
<version>1.6.13</version>
96-
<extensions>true</extensions>
97-
<configuration>
98-
<serverId>sonatype-nexus-staging</serverId>
99-
<nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
100-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
101-
</configuration>
102-
</plugin>
10392
<plugin>
10493
<artifactId>maven-javadoc-plugin</artifactId>
10594
<version>3.4.1</version>
@@ -134,6 +123,57 @@
134123
</build>
135124

136125
<profiles>
126+
<!-- Because the BOM artifact does not need to inherit other properties such as dependencies
127+
in the root pom.xml, this needs to define publication-related profiles. -->
128+
<profile>
129+
<!-- By default, we release artifacts to Sonatype, which requires
130+
nexus-staging-maven-plugin. -->
131+
<id>release-sonatype</id>
132+
<activation>
133+
<property>
134+
<!-- Only when we use the release-gcp-artifact-registry profile,
135+
which comes with artifact-registry-url property, this profile is
136+
turned off. -->
137+
<name>!artifact-registry-url</name>
138+
</property>
139+
</activation>
140+
<build>
141+
<plugins>
142+
<plugin>
143+
<groupId>org.sonatype.plugins</groupId>
144+
<artifactId>nexus-staging-maven-plugin</artifactId>
145+
<version>1.6.13</version>
146+
<extensions>true</extensions>
147+
<configuration>
148+
<serverId>sonatype-nexus-staging</serverId>
149+
<nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
150+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
151+
</configuration>
152+
</plugin>
153+
</plugins>
154+
</build>
155+
</profile>
156+
<profile>
157+
<!-- Optionally, we can publish the artifacts to GCP Artifact Registry specifying
158+
this release-gcp-artifact-registry profile:
159+
mvn deploy -P=release-gcp-artifact-registry -P=-release-sonatype \
160+
-Dartifact-registry-url=artifactregistry://us-maven.pkg.dev/...
161+
-->
162+
<id>release-gcp-artifact-registry</id>
163+
<properties>
164+
<artifact-registry-url>artifactregistry://please-define-artifact-registry-url-property</artifact-registry-url>
165+
</properties>
166+
<distributionManagement>
167+
<repository>
168+
<id>gcp-artifact-registry-repository</id>
169+
<url>${artifact-registry-url}</url>
170+
</repository>
171+
<snapshotRepository>
172+
<id>gcp-artifact-registry-repository</id>
173+
<url>${artifact-registry-url}</url>
174+
</snapshotRepository>
175+
</distributionManagement>
176+
</profile>
137177
<profile>
138178
<id>release-sign-artifacts</id>
139179
<activation>

pom.xml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,6 @@
432432
</execution>
433433
</executions>
434434
</plugin>
435-
<plugin>
436-
<groupId>org.sonatype.plugins</groupId>
437-
<artifactId>nexus-staging-maven-plugin</artifactId>
438-
</plugin>
439435
<plugin>
440436
<groupId>com.coveo</groupId>
441437
<artifactId>fmt-maven-plugin</artifactId>
@@ -517,7 +513,6 @@
517513
</plugins>
518514
</build>
519515
</profile>
520-
521516
<profile>
522517
<id>docFX</id>
523518
<activation>
@@ -578,5 +573,47 @@
578573
</plugins>
579574
</build>
580575
</profile>
576+
<profile>
577+
<!-- By default, we release artifacts to Sonatype, which requires
578+
nexus-staging-maven-plugin. -->
579+
<id>release-sonatype</id>
580+
<activation>
581+
<property>
582+
<!-- Only when we use the release-gcp-artifact-registry profile,
583+
which comes with artifact-registry-url property, this profile is
584+
turned off. -->
585+
<name>!artifact-registry-url</name>
586+
</property>
587+
</activation>
588+
<build>
589+
<plugins>
590+
<plugin>
591+
<groupId>org.sonatype.plugins</groupId>
592+
<artifactId>nexus-staging-maven-plugin</artifactId>
593+
</plugin>
594+
</plugins>
595+
</build>
596+
</profile>
597+
<profile>
598+
<!-- Optionally, we can publish the artifacts to GCP Artifact Registry specifying
599+
this release-gcp-artifact-registry profile:
600+
mvn deploy -P=release-gcp-artifact-registry -P=-release-sonatype \
601+
-Dartifact-registry-url=artifactregistry://us-maven.pkg.dev/...
602+
-->
603+
<id>release-gcp-artifact-registry</id>
604+
<properties>
605+
<artifact-registry-url>artifactregistry://please-define-artifact-registry-url-property</artifact-registry-url>
606+
</properties>
607+
<distributionManagement>
608+
<repository>
609+
<id>gcp-artifact-registry-repository</id>
610+
<url>${artifact-registry-url}</url>
611+
</repository>
612+
<snapshotRepository>
613+
<id>gcp-artifact-registry-repository</id>
614+
<url>${artifact-registry-url}</url>
615+
</snapshotRepository>
616+
</distributionManagement>
617+
</profile>
581618
</profiles>
582619
</project>

0 commit comments

Comments
 (0)