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. #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | |
| - name: Import GPG Key | |
| run: | | |
| # Setup GPG directory permissions | |
| mkdir -p ~/.gnupg/ | |
| chmod 700 ~/.gnupg/ | |
| # Configure GPG for non-interactive use | |
| echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf | |
| echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf | |
| # Save and import the GPG key | |
| echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import | |
| # List imported keys for debugging | |
| gpg --list-secret-keys --keyid-format LONG | |
| - 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 Maven settings | |
| mkdir -p ~/.m2 | |
| # Ensure settings.xml has proper configurations | |
| 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> | |
| </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}" -Dgpg.keyname="${GPG_KEY_NAME}" |