Skip to content

Update POM file for NotificationAPI Java Server SDK to include project metadata, change license to Apache 2.0, and configure distribution management for Maven Central. Modify README for clarity and update GitHub Actions workflow to publish to Maven Central with GPG signing support. #3

Update POM file for NotificationAPI Java Server SDK to include project metadata, change license to Apache 2.0, and configure distribution management for Maven Central. Modify README for clarity and update GitHub Actions workflow to publish to Maven Central with GPG signing support.

Update POM file for NotificationAPI Java Server SDK to include project metadata, change license to Apache 2.0, and configure distribution management for Maven Central. Modify README for clarity and update GitHub Actions workflow to publish to Maven Central with GPG signing support. #3

Workflow file for this run

name: Publish to Maven Central
on:
workflow_dispatch: # Manual trigger
release:
types: [created] # Trigger on new release
pull_request:
branches: [ main ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: central
server-username: ${{ secrets.MAVEN_USERNAME }}
server-password: ${{ secrets.MAVEN_PASSWORD }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Configure GPG Key
run: |
# Setup GPG directory permissions
mkdir -p ~/.gnupg/
chmod 700 ~/.gnupg/
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
- name: Build and Publish package
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
run: |
# Create settings-security.xml
mkdir -p ~/.m2
# Add the gpg.passphrase configuration to settings.xml
cat > ~/.m2/settings-security.xml << EOF
<settingsSecurity>
<master>${GPG_PASSPHRASE}</master>
</settingsSecurity>
EOF
# Ensure settings.xml has proper GPG passphrase configuration
if [ -f ~/.m2/settings.xml ]; then
mv ~/.m2/settings.xml ~/.m2/settings.xml.bak
fi
cat > ~/.m2/settings.xml << EOF
<settings>
<servers>
<server>
<id>central</id>
<username>${MAVEN_USERNAME}</username>
<password>${MAVEN_PASSWORD}</password>
</server>
<server>
<id>gpg.passphrase</id>
<passphrase>${GPG_PASSPHRASE}</passphrase>
</server>
</servers>
<profiles>
<profile>
<id>gpg</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
<gpg.keyname>${GPG_KEY_NAME}</gpg.keyname>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>gpg</activeProfile>
</activeProfiles>
</settings>
EOF
# Print debug info
echo "Maven settings created. Deploying with Maven..."
# Build and deploy
mvn -B clean deploy -Dgpg.passphrase=${GPG_PASSPHRASE}