setup-java: GPG-Signing of maven artifacts fails on Windows runners with `actions/setup-java@v4` and `maven-gpg-plugin` version range `[3.2.0, 3.2.7)`
Update (2024-09-24)
Affected are maven-gpg-plugin version range [3.2.0, 3.2.7), using [3.2.7,) should solve this.
Description:
GPG-Signing of maven artifacts fails only on Windows runners using actions/setup-java@v4 and the updated maven-gpg-plugin v3.2.0-v3.2.4. However, the previous plugin version v3.1.0 does not cause any problems for no runner.
The error is gpg: signing failed: Bad passphrase, see e.g. here.
However, the new plugin versions v3.2.x work on my local windows 10 machine.
The GPG private key and passphrase provided as secrets obviously work for the old plugin on windows and the new one on ubuntu and macOS.
I’m aware that this is perhaps not (only) an error in this action but perhaps in the maven-gpg-plugin or in the interaction between them.
Task version:
actions/setup-java@v4
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Repro steps:
Here is a repository test-mvn-gpg-plugin which reproduces the error in this workflow build-and-sign.
Expected behavior: The GPG-signing is successful for all runners.
Actual behavior:
The GPG-signing fails for windows-2019 and windows-2022 runners.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (5 by maintainers)
Hi @cowwoc, @aparnajyothi-y, @mahabaleshwars
Thanks for having a look into it. The
maven-gpg-plugin-team has found the problem and has a solution for it.Please have a look at https://github.com/ralfkonrad/test-mvn-gpg-plugin/pull/30.
Hello @ralfkonrad, @cowwoc, Thank you for the above information. We have further investigated the issue and found the following related updates to the maven-gpg-plugin from version 3.2.0 to 3.2.4 compared to 3.1.0:
PR #95: Added improvements to passphrase handling to enhance security and compatibility. PR #86: Addressed issues related to fetching passphrases from environment variables. PR #71: Implemented changes that might affect how environment variables are recognized on Windows systems. These updates could be causing the “Bad passphrase” errors on Windows systems when using passphrase environment variables, even though the same setup works with version 3.1.0.
We have verified that the environment variable is correctly set and visible on Windows using commands like echo %MY_GPG_PASSPHRASE% in Command Prompt or $env:MY_GPG_PASSPHRASE in PowerShell, and it returns the same value as on Linux and macOS.
We have also checked the Apache Maven releases and couldn’t find any significant changes before the 3.2.0 releases. We are continuing our investigation to find the root cause.
And thanks @ralfkonrad for the “infra”, the GH reproducer repo! As we, maven-gpg-plugin devs, still have something to solve: https://issues.apache.org/jira/browse/MGPG-145
Release 3.2.7 is on vote (72h): https://lists.apache.org/thread/n49wo8ls7kw8b2ono3xbr4fpfdvtvfy4
Thanks @aparnajyothi-y for the update. Interesting constellation.
If there is anything I can do on my side please let me know.
Also note that Powershell has long-standing bugs regarding expanding environment variables: https://stackoverflow.com/a/68758940/14731
It doesn’t sound like these will get fixed anytime soon. Can one of the
setup-javacommitters please double-check that the value is being expanded properly under Windows runners? That could be the problem.Maybe you guys need to use the quoting workaround mentioned in Stackoverflow in order to fix this on your end.
I am seeing the same issue. My guess is that this has something to do with the use of Powershell on the Windows machines.
I filed https://issues.apache.org/jira/browse/MGPG-136
We need one of the committers to dig into this because it’s not really easy to debug this problem.
Hello @ralfkonrad, Thank you for creating this issue and we will look into it 😃