updated publishing config

This commit is contained in:
Amith Koujalgi 2024-07-26 23:57:19 +05:30
parent bc4e8303aa
commit cfa8aa14d7
3 changed files with 200 additions and 88 deletions

58
.github/workflows/gh-mvn-publish.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: Release Artifacts to GitHub Maven Packages
on:
release:
types: [ created ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
servers: '[{ "id": "${repo.id}", "username": "${repo.user}", "password": "${repo.pass}" }]'
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "ollama4j-revision"
replace: ${{ github.ref_name }}
regex: false
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "mvn-repo-id"
replace: github
regex: false
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: List keys
run: gpg -K
- name: Build with Maven
run: mvn --file pom.xml -U clean package -Punit-tests
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -Punit-tests -s $GITHUB_WORKSPACE/settings.xml -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Drepo.id=github -Drepo.user=${{ secrets.GH_MVN_USER }} -Drepo.pass=${{ secrets.GH_MVN_PASS }} -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/ollama4j/ollama4j
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,22 +1,31 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Release Artifacts name: Release Artifacts to Maven Central
on: on:
release: release:
types: [ created ] types: [ created ]
#on:
# pull_request:
# types: [ opened, reopened ]
# branches: [ "main" ]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: write
packages: write packages: write
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
@ -25,6 +34,19 @@ jobs:
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
servers: '[{ "id": "${repo.id}", "username": "${repo.user}", "password": "${repo.pass}" }]'
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: List keys
run: gpg -K
- name: Find and Replace - name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3 uses: jacobtomlinson/gha-find-replace@v3
with: with:
@ -32,10 +54,42 @@ jobs:
replace: ${{ github.ref_name }} replace: ${{ github.ref_name }}
regex: false regex: false
- name: Build with Maven - name: Find and Replace
run: mvn --file pom.xml -U clean package -Punit-tests uses: jacobtomlinson/gha-find-replace@v3
with:
find: "mvn-repo-id"
replace: central
regex: false
- name: Publish to GitHub Packages Apache Maven - name: Publish to Maven Central
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml --file pom.xml run: mvn deploy -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Drepo.id=central -Drepo.user=${{ secrets.MVN_USER }} -Drepo.pass=${{ secrets.MVN_PASS }}
- name: Upload Release Asset - JAR
uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: target/ollama4j-${{ github.ref_name }}.jar
asset_name: ollama4j-${{ github.ref_name }}.jar
asset_content_type: application/x-jar
- name: Upload Release Asset - Javadoc JAR
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: target/ollama4j-${{ github.ref_name }}-javadoc.jar
asset_name: ollama4j-${{ github.ref_name }}-javadoc.jar
asset_content_type: application/x-jar
- name: Upload Release Asset - Sources JAR
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: target/ollama4j-${{ github.ref_name }}-sources.jar
asset_name: ollama4j-${{ github.ref_name }}-sources.jar
asset_content_type: application/x-jar

162
pom.xml
View File

@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.amithkoujalgi</groupId> <groupId>io.github.ollama4j</groupId>
<artifactId>ollama4j</artifactId> <artifactId>ollama4j</artifactId>
<version>ollama4j-revision</version> <version>ollama4j-revision</version>
@ -41,7 +41,7 @@
<connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection> <connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection>
<developerConnection>scm:git:https://github.com/amithkoujalgi/ollama4j.git</developerConnection> <developerConnection>scm:git:https://github.com/amithkoujalgi/ollama4j.git</developerConnection>
<url>https://github.com/amithkoujalgi/ollama4j</url> <url>https://github.com/amithkoujalgi/ollama4j</url>
<tag>v1.0.16</tag> <tag>ollama4j-revision</tag>
</scm> </scm>
<build> <build>
@ -72,27 +72,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.5</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>sign-artifacts</id>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- &lt;!&ndash; This is necessary for gpg to not try to use the pinentry programs &ndash;&gt;-->
<!-- <gpgArguments>-->
<!-- <arg>&#45;&#45;pinentry-mode</arg>-->
<!-- <arg>loopback</arg>-->
<!-- </gpgArguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- Surefire Plugin for Unit Tests --> <!-- Surefire Plugin for Unit Tests -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -129,15 +109,23 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-release-plugin</artifactId>--> <plugin>
<!-- <version>3.0.1</version>--> <groupId>org.apache.maven.plugins</groupId>
<!-- <configuration>--> <artifactId>maven-gpg-plugin</artifactId>
<!-- &lt;!&ndash; <goals>install</goals>&ndash;&gt;--> <version>1.5</version>
<!-- <tagNameFormat>v@{project.version}</tagNameFormat>--> <executions>
<!-- </configuration>--> <execution>
<!-- </plugin>--> <id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
@ -189,27 +177,39 @@
</dependency> </dependency>
</dependencies> </dependencies>
<!-- <distributionManagement>-->
<!-- <snapshotRepository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>-->
<!-- </snapshotRepository>-->
<!-- <repository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>-->
<!-- </repository>-->
<!-- </distributionManagement>-->
<!-- Replaced publishing packages to GitHub Packages instead of Maven central -->
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>github</id> <id>mvn-repo-id</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/amithkoujalgi/ollama4j</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<profiles> <profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg2</gpg.executable>
<test.env>unit</test.env>
<skipUnitTests>false</skipUnitTests>
<skipIntegrationTests>true</skipIntegrationTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.5.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>mvn-repo-id</publishingServerId>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>unit-tests</id> <id>unit-tests</id>
<properties> <properties>
@ -218,7 +218,7 @@
<skipIntegrationTests>true</skipIntegrationTests> <skipIntegrationTests>true</skipIntegrationTests>
</properties> </properties>
<activation> <activation>
<activeByDefault>true</activeByDefault> <activeByDefault>false</activeByDefault>
</activation> </activation>
<build> <build>
<plugins> <plugins>
@ -261,39 +261,39 @@
</properties> </properties>
<build> <build>
<plugins> <plugins>
<!-- <plugin>--> <plugin>
<!-- <groupId>org.apache.maven.plugins</groupId>--> <groupId>org.apache.maven.plugins</groupId>
<!-- <artifactId>maven-gpg-plugin</artifactId>--> <artifactId>maven-gpg-plugin</artifactId>
<!-- <version>3.1.0</version>--> <version>3.1.0</version>
<!-- <executions>--> <executions>
<!-- <execution>--> <execution>
<!-- <id>sign-artifacts</id>--> <id>sign-artifacts</id>
<!-- <phase>verify</phase>--> <phase>verify</phase>
<!-- <goals>--> <goals>
<!-- <goal>sign</goal>--> <goal>sign</goal>
<!-- </goals>--> </goals>
<!-- <configuration>--> <configuration>
<!-- &lt;!&ndash; Prevent gpg from using pinentry programs. Fixes:--> <!-- Prevent gpg from using pinentry programs. Fixes:
<!-- gpg: signing failed: Inappropriate ioctl for device &ndash;&gt;--> gpg: signing failed: Inappropriate ioctl for device -->
<!-- <gpgArguments>--> <gpgArguments>
<!-- <arg>&#45;&#45;pinentry-mode</arg>--> <arg>--pinentry-mode</arg>
<!-- <arg>loopback</arg>--> <arg>loopback</arg>
<!-- </gpgArguments>--> </gpgArguments>
<!-- </configuration>--> </configuration>
<!-- </execution>--> </execution>
<!-- </executions>--> </executions>
<!-- </plugin>--> </plugin>
<!-- <plugin>--> <plugin>
<!-- <groupId>org.sonatype.plugins</groupId>--> <groupId>org.sonatype.plugins</groupId>
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>--> <artifactId>nexus-staging-maven-plugin</artifactId>
<!-- <version>1.6.13</version>--> <version>1.6.13</version>
<!-- <extensions>true</extensions>--> <extensions>true</extensions>
<!-- <configuration>--> <configuration>
<!-- <serverId>ossrh</serverId>--> <serverId>ossrh</serverId>
<!-- <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>--> <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>--> <autoReleaseAfterClose>true</autoReleaseAfterClose>
<!-- </configuration>--> </configuration>
<!-- </plugin>--> </plugin>
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>