diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index 775df4a..280be57 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -1,7 +1,7 @@ name: Maven Deploy on: - workflow_dispatch: # Manual trigger without inputs + workflow_dispatch: # Manual trigger without inputs jobs: deploy: @@ -16,26 +16,50 @@ jobs: maven-version: 3.9.6 - name: Set up JDK - # Handles importing GPG private key to the local keyring and configures Maven to use GPG passphrase - # if pom.xml has the Maven GPG plugin configured uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' - server-id: ossrh # Must match server ID in settings.xml/pom.xml - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - # The private key is not required as a standard environment variable - gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - # Parameters for handling GPG in headless CI/CD - gpg-passphrase-args: --pinentry-mode=loopback --no-tty --batch + cache: maven - - name: Deploy to Maven Central + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_SECRET_KEY }} + passphrase: ${{ secrets.GPG_PASS }} + + - name: Configure Maven settings env: MAVEN_USERNAME: ${{ secrets.AEROSPIKE_SA_CICD_USERNAME }} MAVEN_PASSWORD: ${{ secrets.AEROSPIKE_SA_CICD_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASS }} - GPG_TTY: "" # Tell GPG not to use terminal - # Use batch mode: no interactive prompts, cleaner logs - run: mvn --batch-mode clean deploy \ No newline at end of file + run: | + mkdir -p ~/.m2 + cat > ~/.m2/settings.xml < + + + ossrh + ${MAVEN_USERNAME} + ${MAVEN_PASSWORD} + + + + EOF + + - name: Test credentials + env: + MAVEN_USERNAME: ${{ secrets.AEROSPIKE_SA_CICD_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.AEROSPIKE_SA_CICD_PASSWORD }} + run: | + echo "Testing Sonatype authentication..." + STATUS=$(curl -s -o /dev/null -w "%{http_code}" -u "${MAVEN_USERNAME}:${MAVEN_PASSWORD}" https://oss.sonatype.org/service/local/status) + + if [ "$STATUS" = "200" ]; then + echo "Credentials are valid" + else + echo "Authentication failed (HTTP $STATUS)" + exit 1 + fi + + - name: Deploy to Maven Central + run: mvn --batch-mode deploy \ No newline at end of file diff --git a/pom.xml b/pom.xml index 942ac78..d6ec35d 100644 --- a/pom.xml +++ b/pom.xml @@ -22,8 +22,7 @@ 1.7.0 3.5.0 3.3.1 - 1.6 - + 3.1.0 9.2.0 4.13.2 1.18.42 @@ -211,6 +210,13 @@ org.apache.maven.plugins maven-gpg-plugin ${maven-gpg-plugin.version} + + + --pinentry-mode + loopback + --no-tty + + sign-artifacts