Skip to content

Commit

Permalink
add: GitHub action publish on central portal (#14)
Browse files Browse the repository at this point in the history
* fix: test publish

* fix: Inappropriate ioctl for device

* fix: force

* fix: user missed

* fix: username missed

* fix: simple

* fix: change version

* fix: build

* fix: test using 1.7.0

* test: 	https://central.sonatype.org/publish/publish-portal-maven/#introduction

* Revert "test: 	https://central.sonatype.org/publish/publish-portal-maven/#introduction"

This reverts commit b418dc8.

* Revert "Revert "test: 	https://central.sonatype.org/publish/publish-portal-maven/#introduction""

This reverts commit 17ce345.

* fix: publish

* fix: release

* fix: prepare release
  • Loading branch information
mosoriob authored Jul 31, 2024
1 parent 2bae94f commit 0239598
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 34 deletions.
73 changes: 53 additions & 20 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# 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

name: Maven Package

on:
Expand All @@ -9,27 +6,63 @@ on:

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
server-id: ossrh
settings-path: ${{ github.workspace }}

- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --yes --import
gpg --list-secret-keys
- name: Verify GPG Passphrase
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
echo "test message" | gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --sign --local-user [email protected]
- name: Set up Maven settings
run: |
mkdir -p ~/.m2
echo "<settings>
<servers>
<server>
<id>central</id>
<username>${{ secrets.OSSRH_USERNAME }}</username>
<password>${{ secrets.OSSRH_PASSWORD }}</password>
</server>
</servers>
<profiles>
<profile>
<id>gpg-sign</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>[email protected]</gpg.keyname>
<gpg.passphrase>${{ secrets.GPG_PASSPHRASE }}</gpg.passphrase>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>gpg-sign</activeProfile>
</activeProfiles>
</settings>" > ~/.m2/settings.xml
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
- name: Publish to OSSRH
run: mvn deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
24 changes: 10 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>edu.isi.kcap</groupId>
<artifactId>ontapi</artifactId>
<version>1.3.8</version>
<version>1.4.0</version>

<scm>
<connection>
Expand Down Expand Up @@ -64,13 +64,6 @@
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<!-- Dependencies -->
<dependencies>
<dependency>
Expand Down Expand Up @@ -152,14 +145,17 @@
<finalName>maven-unit-test</finalName>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.5.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</configuration>
</plugin>
<plugin>
Expand Down

0 comments on commit 0239598

Please sign in to comment.