name:PublishtoMavenCentral on: push: tags: -"v*.*.*" jobs: build: runs-on:ubuntu-latest steps: -name:Checkout uses:actions/checkout@v3 -name:SetupApacheMavenCentral uses:actions/setup-java@v4 with:# running setup-java again overwrites the settings.xml java-version:'17' distribution:'temurin' cache:maven server-id:central# Value of the distributionManagement/repository/id field of the pom.xml server-username:MAVEN_USERNAME# env variable for username in deploy server-password:MAVEN_CENTRAL_TOKEN# env variable for token in deploy gpg-private-key:${{secrets.MAVEN_GPG_PRIVATE_KEY}}# Value of the GPG private key to import gpg-passphrase:MAVEN_GPG_PASSPHRASE# env variable for GPG private key passphrase -name:PublishtoApacheMavenCentral run:mvndeploy env: MAVEN_USERNAME:${{secrets.MAVEN_USERNAME}} MAVEN_CENTRAL_TOKEN:${{secrets.MAVEN_CENTRAL_TOKEN}} MAVEN_GPG_PASSPHRASE:${{secrets.MAVEN_GPG_PASSPHRASE}}
修改 pom 文件
Maven GPG Plugin 可能会报以下错误 Inappropriate ioctl for device 或者 gpg: signing failed: No such file or directory,所以需要在 configuration 中添加以下内容:
1 2 3 4 5 6 7
<configuration> <!-- Prevent gpg from using pinentry programs --> <gpgArguments> <arg>--pinentry-mode</arg> <arg>loopback</arg> </gpgArguments> </configuration>