Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPG Key import successfully, but "No secret key" when maven deploy #619

Closed
DQinYuan opened this issue Apr 7, 2024 · 7 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@DQinYuan
Copy link

DQinYuan commented Apr 7, 2024

Job Url

config:

name: Maven Central Repo Deployment
on:
  release:
    types: [released, prereleased]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Git Repo
        uses: actions/checkout@v2
      - name: Set up Maven Central Repo
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 8
          server-id: sonatype-nexus-staging
          server-username: 'OSSRH_USER'
          server-password: 'OSSRH_PASSWORD'
          gpg-passphrase:  'MAVEN_GPG_PASSPHRASE'
          gpg-private-key: ${{ secrets.GPG_SECRET }}
      - name: debug settings.xml
        run: cat /home/runner/.m2/settings.xml
      - name: Publish to Maven Central Repo
        run: mvn clean deploy --batch-mode --activate-profiles deploy
        env:
          OSSRH_USER: ${{ secrets.OSSRH_USER }}
          OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
          MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}

gpg private key imported successfully:

image

Bug maven depoly failed with "No secret key":

image

@DQinYuan DQinYuan added bug Something isn't working needs triage labels Apr 7, 2024
@aparnajyothi-y
Copy link
Contributor

Hello @DQinYuan, Thank for creating this issue and we will look into it :)

@gowridurgad gowridurgad self-assigned this Apr 10, 2024
@DQinYuan
Copy link
Author

Is there any progress? I'm still waiting for it to release the new version. We can't solve this problem.

@gowridurgad
Copy link

Hi @DQinYuan, The problem you're encountering could be due to the absence of a GPG key in the environment where your action is being executed. Here's how you can fix it:

1.If you haven't done so already, generate a GPG key and export the private key to a file. Execute these commands to accomplish that:

gpg --gen-key # Complete the prompts to generate the key
gpg --export-secret-keys > private.key

2.Add the data from the private.key file to the secrets of your GitHub repository.

@DQinYuan
Copy link
Author

Hi @DQinYuan, The problem you're encountering could be due to the absence of a GPG key in the environment where your action is being executed. Here's how you can fix it:

1.If you haven't done so already, generate a GPG key and export the private key to a file. Execute these commands to accomplish that:

gpg --gen-key # Complete the prompts to generate the key
gpg --export-secret-keys > private.key

2.Add the data from the private.key file to the secrets of your GitHub repository.

@gowridurgad I have setted GPG_SECRET 7 months ago

image

image

I publish package successfully before updating setup-java to v4.

Successful Job URL

@gowridurgad
Copy link

Hi @DQinYuan, After implementing the process detailed in the previous comment, we no longer observe the error in our logs. I have attached a screenshot for your consideration.

Could you please reconfigure the secret by following the steps previously outlined?

To verify the existence of the secret, could you please incorporate the following steps into your workflow file?

 name: Check if secret exists
        run: |
          if [[ -z "${{ secrets.GPG_SECRET }}" ]]; then
            echo "Secret does not exist"
          else
            echo "Secret exists"
Screenshot 2024-04-22 at 5 15 56 PM

@DQinYuan
Copy link
Author

DQinYuan commented Apr 27, 2024

@gowridurgad

Job with 'Check if secret exists' step.

image

Error because of newline in GPG_SECRET.
I think this phenomenon can prove GPG_SECRET's existence.

@DQinYuan
Copy link
Author

DQinYuan commented May 2, 2024

I later troubleshooted and found that the issue was due to an expired GPG key, which was resolved by renewing it.

@DQinYuan DQinYuan closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants