Skip to content

Commit

Permalink
added github tag, using actions-maven-settings file with existing pom…
Browse files Browse the repository at this point in the history
….xml file
  • Loading branch information
kcs-bandihareesh committed Oct 8, 2024
1 parent 5a2cb9b commit 61ec19e
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 63 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/database-goodies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
- name: Copy Maven settings
run: |
mkdir -p $HOME/.m2
cp ./travis/maven-settings.xml $HOME/.m2/settings.xml
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml
- name: Update pom.xml version
run: |
sed -i "s/-SNAPSHOT/-build-${{ github.run_number }}/" pom.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
Expand Down Expand Up @@ -100,11 +100,11 @@ jobs:
- name: Copy Maven settings
run: |
mkdir -p $HOME/.m2
cp ./travis/maven-settings.xml $HOME/.m2/settings.xml
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml
- name: Update pom.xml version
run: |
sed -i "s/-SNAPSHOT/-build-${{ github.run_number }}/" pom.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Deploy snapshots
run: |
Expand Down
61 changes: 61 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -174,6 +175,22 @@
</execution>
</executions>
</plugin>

<!-- NOTE: We are using the maven release plugin to deploy to Maven Central, see:
https://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin
for explanation as to why the useReleaseProfile is set to false.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -405,5 +422,49 @@
</dependency>
</dependencies>
</profile>

<profile>
<id>release</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
66 changes: 66 additions & 0 deletions travis/actions-maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<mirrors>
<mirror>
<mirrorOf>*,!artifact-registry</mirrorOf>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>ci-build</id>
<repositories>
<repository>
<id>artifact-registry</id>
<url>https://us-west1-maven.pkg.dev/som-rit-infrastructure-prod/public-maven</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

<activeProfiles>
<!-- Activate the CI profile -->
<activeProfile>ci-build</activeProfile>
</activeProfiles>

<servers>
<!-- Add Google Artifact Registry authentication -->
<server>
<id>artifact-registry</id>
<username>oauth2accesstoken</username>
<password>${env.ACCESS_TOKEN}</password> <!-- Access token generated via GitHub Actions using Workload Identity Federation -->
</server>

<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_PASSWORD}</password>
</server>

<server>
<id>github.com</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
134 changes: 75 additions & 59 deletions travis/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,82 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<mirrors>
<mirror>
<mirrorOf>*,!artifact-registry</mirrorOf>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
</mirrors>
<mirrors>
<mirror>
<mirrorOf>*,!artifact-registry</mirrorOf>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>travis-ci</id>
<repositories>
<repository>
<id>artifact-registry</id>
<url>https://us-west1-maven.pkg.dev/som-rit-infrastructure-prod/public-maven</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<profiles>
<profile>
<id>ci-build</id>
<repositories>
<repository>
<id>artifact-registry</id>
<url>https://us-west1-maven.pkg.dev/som-rit-infrastructure-prod/public-maven</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>

<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</profile>
</profiles>

<activeProfiles>
<!-- Activate the CI profile -->
<activeProfile>ci-build</activeProfile>
</activeProfiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>travis-ci</activeProfile>
</activeProfiles>

<servers>
<!-- Add Google Artifact Registry authentication -->
<server>
<id>artifact-registry</id>
<username>oauth2accesstoken</username>
<password>${env.ACCESS_TOKEN}</password> <!-- Access token generated via GitHub Actions using Workload Identity Federation -->
</server>

<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_PASSWORD}</password>
</server>

<server>
<id>github.com</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
<servers>
<server>
<id>artifact-registry</id>
<configuration>
<httpConfiguration>
<get>
<usePreemptive>true</usePreemptive>
</get>
<head>
<usePreemptive>true</usePreemptive>
</head>
<put>
<params>
<property>
<name>http.protocol.expect-continue</name>
<value>false</value>
</property>
</params>
</put>
</httpConfiguration>
</configuration>
<username>_json_key_base64</username>
<password>${env.ARTIFACT_REGISTRY_KEY}</password>
</server>
<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_PASSWORD}</password>
</server>
<server>
<id>github.com</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>

0 comments on commit 61ec19e

Please sign in to comment.