GithubHelp home page GithubHelp logo

qcastel / github-actions-maven-release Goto Github PK

View Code? Open in Web Editor NEW
125.0 3.0 35.0 238 KB

Release your Java application and publish artifacts

Dockerfile 42.78% Shell 57.22%
bot gpg ssh-key docker nexus maven java

github-actions-maven-release's Introduction

github action maven release

The GitHub Action for Maven releases wraps the Maven CLI to enable Maven release. For example, you can use this action for auto-incrementing your project version and release your java artifacts.

This github action is bot friendly: You can configure the credentials of a bot user, which would be used during the incremental commit. The commits by the bot can also be signed, giving you the guaranty that only the bot can release in your repo. Additionally, this give you a clean git history by highlighting nicely which commits where resulting from your CI.

Supporting this github action

Support this github action by staring this project. Surprisingly, it seems to be the only way for the github market place to highlight popular github actions.

Sample repository

We created a sample repository that will show you an example of how this github action can be used for releasing a Java application: https://github.com/qcastel/github-actions-maven-release-sample

Features

Obviously, this github actions uses maven release plugin. Although, we did add on top a few features that you may like.

Maven release uses Git behind it, therefore there were a few features related in customising the git configuration:

  • Signing the commits (GPG) resulting from the maven release [GPG]
  • Authenticating to private repository using an SSH key [SSH]
  • Configuring the git username and email [Bot]
  • Configuring the jdk version [JDK]

You may want to configure a bit maven too. We added the following features:

  • Specify the maven project path. In other words, if your maven project is not at the root of your repo, you can configure a sub path. [Custom project path]
  • Configure private maven server repositories [Private maven repo]
  • Configure a docker registry [Docker registry]
  • Setup custom maven arguments and/or options to be used when calling maven commands [Maven options]
  • Configure a custom M2 folder [Custom M2]
  • Print the timestamp for every maven logs. Handy for troubleshooting performance issues in your CI. [Log timestamp]

For the maven releases, we got also some dedicated functionalities:

  • Skip the maven perform [Skip perform]
  • Roll back the maven perform if it failed to perform the release
  • Increment the major or minor version (by default, it's the patch version that is increased) [Major Minor version]
  • customise the version format completly [Customize version]

Usage

Setup your pom.xml for maven release

Before you even begin setting up this github action, you would need to set up your pom.xml first to be ready for maven releases. We recommend you to refer to the maven release plugin documentation for more details: https://maven.apache.org/maven-release/maven-release-plugin/

Nevertheless, we will give you some essential setups

Configure the SCM

You got two choices here:

  • Using SSH URL (Recommended)
    <scm>
        <connection>scm:git:${project.scm.url}</connection>
        <developerConnection>scm:git:${project.scm.url}</developerConnection>
        <url>[email protected]:idhub-io/idhub-api.git</url>
        <tag>HEAD</tag>
    </scm>
  • Using HTTPS URL
	<scm>
        <connection>scm:git:${project.scm.url}</connection>
        <developerConnection>scm:git:${project.scm.url}</developerConnection>
		<url>https://github.com/YOUR_REPO.git</url>
		<tag>HEAD</tag>
	</scm>

In the case of SSH, it will use the ssh-private-key to authenticate with the upstream. In the case of HTTPS, maven releases will use the access-token in this github actions to authenticate with the upstream.

Note: SSH is more elegant and usually the easiest one to setup due to the large amount of documents online on this subject.

maven release plugin

Add the maven release plugin dependency to your project

    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>XXX</version>
        <configuration>
            <scmCommentPrefix>[ci skip]</scmCommentPrefix>
        </configuration>
    </plugin>

Personally, I usually the prefix [ci skip] which allows me to skip more easily any commits generated by the bot from the CI.

Setup the maven release github actions

Choose your version of this github action

If it's your first time using a github action, I invite you having a quick read to the github official recommendations: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions

It's important you understand how the versioning work and the risk/compromise of using master/tags/commit hash

If you are adventurous and like to be always on top of this github action, you can use the reference master :

 - name: Release
      uses: qcastel/github-actions-maven-release@master
      with:

If you are more reserve, you can use a tag instead. You can find the list of the tags for this github action here:

https://github.com/qcastel/github-actions-maven-release/tags

To use a tag:

 - name: Release
      uses: qcastel/github-actions-maven-release@TAG_NAME
      with:

If you are concerned about the security of this github action, you can also move to a commit hash:

 - name: Release
      uses: qcastel/github-actions-maven-release@COMMIT_HASH
      with:

Basic setup

For a simple repo with not much protection and private dependency, you can do:

      env:
       JAVA_HOME: /usr/lib/jvm/java-17-openjdk/
      with:
       ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

You will need to follow the Setup with SSH section to setup the SSH_PRIVATE_KEY accordingly.

Setup with SSH

Although you may found better to use a SSH key instead. For this, generate an SSH key with the method of your choice, or use an existing one. Personally, I like generating an SSH inside a temporary docker image and configure it as a deploy key in my repository:

docker run -it qcastel/maven-release:latest  bash
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q -N ""
export SSH_PRIVATE_KEY=$(base64 /tmp/sshkey)
export SSH_PUBLIC_KEY=$(cat /tmp/sshkey.pub)
echo -n "Copy the following SSH private key and add it to your repo secrets under the name 'SSH_PRIVATE_KEY':"
echo $SSH_PRIVATE_KEY
echo "Copy the encoded SSH public key and add it as one of your repo deploy keys with write access:"
echo $SSH_PUBLIC_KEY

exit 

Copy SSH_PRIVATE_KEY and add it as a new secret. img/Add-ssh-secrets.png

Copy SSH_PUBLIC_KEY and add it as a new deployment key with write access. img/add-deploy-key.png

Finally, setup the github action with:

        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

If you want to set up a passphrase for your key:

        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          ssh-passphrase: ${{ secrets.SSH_PASSPHRASE }}

SSH known hosts

The current github actions support by default the following known hosts:

  • github.com
  • gitlab.com
  • bitbucket.org

Although you may want to additional one, using the following properties:

        with:
          ssh-extra-known-host: "my-awesome-private-git-host.com"

You can also disable the default hosts (for example, if you are behind a corporate proxy) like so:

        with:
          ssh-ignore-default-hosts: true

log Timestamp

It can be quite difficult to troubleshoot any performance issue on your CI, due to the lack of timestamp from maven by default. An example of it particular handy, is when you private maven repository is having performance issue that is affecting your CI.

We added the timestamp by default, you don't need to do anything particular to enable this feature.

The logs should look like:

14:27:09,491 [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/io/projectreactor/reactor-bom/Dysprosium-SR13/reactor-bom-Dysprosium-SR13.pom

Maven options

Adding maven arguments

You can add some maven arguments, which is handy for skipping tests:

        with:
            maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip"

Adding maven options

You can add some maven options. At the difference of the maven arguments, those one are explicitly for the maven release plugin. See https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html.

        with:
            maven-options: "-DbranchName=hotfix"

JDK version

The default JDK version is JDK 21. Although you may want to compile your project with a specific JDK version. You will need to specify the JAVA_HOME variable with the according value. If you need a specific jdk version that is not in the list, please raise an issue in this github action to request it.

JDK 8

env:
 JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk/

JDK 11

env:
 JAVA_HOME: /usr/lib/jvm/java-11-openjdk/

JDK 14

env:
 JAVA_HOME: /usr/lib/jvm/java-14-openjdk/

JDK 15

env:
 JAVA_HOME: /usr/lib/jvm/java-15-openjdk/

JDK 16

env:
 JAVA_HOME: /usr/lib/jvm/java-16-openjdk/

JDK 17

env:
 JAVA_HOME: /usr/lib/jvm/java-17-openjdk/

JDK 21

env:
 JAVA_HOME: /usr/lib/jvm/java-21-openjdk/

Customise the bot name

You can simply customise the bot name as follows:

        with:
            git-release-bot-name: "release-bot"
            git-release-bot-email: "[email protected]"

Customise the default branch

You may not want to release from your master branch, which is currently the default branch setup by this github action. You can customise the branch name you want to release on, here release, as follows:

        with:
            release-branch-name: "release"

Skipping perform

If for a reason, you need to skip the maven release perfom, you can disable it as follow:

        with:
            skip-perform: true

Increase major, minor or patch version

For major version increment

1.0.0-SNAPSHOT -> 2.0.0-SNAPSHOT

        with:
            version-major: true

For minor version increment

1.0.0-SNAPSHOT -> 1.2.0-SNAPSHOT

        with:
            version-minor: true

For patch version increment

As the patch version is the default version number increased, you don't need to specify any additional properties.

Although if you prefer to be explicit, you can use the following option:

1.0.0-SNAPSHOT -> 1.0.1-SNAPSHOT

        with:
            version-patch: true

Customize version

development version

You may want to fully customize the development version number. This option will allow you to fully take control on the version number format.

For Example, you could decide to only have a 2 part version number like 0.2-SNAPSHOT.

        with:
            maven-development-version-number: ${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT

Release version

You may want to fully customize the release version number. This option will allow you to fully take control on the version number format.

For Example, you could decide to only have a trailing 0 for releases like 0.2.0.

        with:
            maven-release-version-number: ${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.0

Customise the M2 folder path

It's quite common for setting up a caching of your dependencies, that you will be interested to customise the .m2 localisation folder.

        with:
            m2-home-folder: '/your-custom-path/.m2'

Setup a GPG key

If you want to set up a GPG key, you can do it by injecting your key via the secrets:

Note: GITHUB_GPG_KEY needs to be base64 encoded. if you haven't setup a GPG key yet, see next section.

      with:
        gpg-enabled: "true"
        gpg-key-id: ${{ secrets.GITHUB_GPG_KEY_ID }}
        gpg-key: ${{ secrets.GITHUB_GPG_KEY }}

In case you want to skip the GPG step, you can set gpg-enabled: "false" or if you prefer to have the same behaviour in your IDE, add this maven plugin in your pom.xml to skip GPG step in the release phase:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>1.6</version>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

Setup private maven server repositories

If you got a private maven repo to set up in the settings.xml, you can do: Note: we recommend putting those values in your repo secrets.

      with:
        maven-servers: ${{ secrets.MVN_REPO_SERVERS }}

Github actions currently don't support arrays input format. This is why we choose to request the secret MVN_REPO_SERVERS to be a JSON containing the servers definition. Example:

[
  {
    "id": "serverId1",
    "username": "username",
    "password": "password1",
    "privateKey": "privatekey1",
    "passphrase": "passphrase1"
  },
  {
    "id": "serverId2",
    "username": "username2",
    "password": "password2"
  }
]

You will need to put the JSON in one line:

MVN_REPO_SERVERS='[{"id": "serverId1", "username": "username", "password": "password1", "privateKey": "privatekey1", "passphrase": "passphrase1"}, {"id": "serverId2", "username": "username2", "password": "password2"}]'

Setup a docker registry

If you got a private maven repo to set up in the settings.xml, you can do: Note: we recommend putting those values in your repo secrets.

      with:
        docker-registry-id: your-docker-registry-id
        docker-registry-username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
        docker-registry-password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}

Note: For docker hub, this would look like:

      with:
        docker-registry-id: registry.hub.docker.com
        docker-registry-username: ${{ secrets.DOCKER_HUB_USERNAME }}
        docker-registry-password: ${{ secrets.DOCKER_HUB_PASSWORD }}

Configure your maven project

You may also be in the case where you got more than one maven projects inside the repo. We added an option that will make the release job move to the according directly before running the release:

    with:
        maven-project-folder: "sub-folder/"

Setup the bot gpg key

Setting up a gpg key for your bot is a good security feature. This way, you can enforce sign commits in your repo, even for your release bot.

Screenshot-2019-11-28-at-20-47-06.png

This github action needs the key ID and the key base64 encoded.

        with:
            gpg-enabled: true
            gpg-key-id: ${{ secrets.GPG_KEY_ID }}
            gpg-key: ${{ secrets.GPG_KEY }}

If you want to set up a passphrase:

        with:
            gpg-enabled: true
            gpg-key-id: ${{ secrets.GPG_KEY_ID }}
            gpg-key: ${{ secrets.GPG_KEY }}
            gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} 

Generate the key

f you like how we created a SSH key pair, here is the same idea using a docker image to generate a GPG key:

docker run -it qcastel/maven-release:latest  bash
cat >genkey-batch <<EOF
 %no-protection
 Key-Type: default
 Subkey-Type: default
 Name-Real: bot
 Name-Email: [email protected]
 Expire-Date: 0
EOF
gpg --batch --gen-key genkey-batch

Note: Don't exit the docker container as we are not done yet.

Get the KID

You can get the key ID doing the following:

gpg --list-secret-keys --keyid-format LONG

sec   rsa2048/3EFC3104C0088B08 2019-11-28 [SC]
      CBFD9020DAC388A77C68385C3EFC3104C0088B08
uid                 [ultimate] bot-openbanking4-dev (it's the bot openbanking4.dev key) <[email protected]>
ssb   rsa2048/7D1523C9952204C1 2019-11-28 [E]

The key ID for my bot is 3EFC3104C0088B08. Add this value into your github secret for this repo, under GPG_KEY_ID PS: the key id is not really a secret but we found more elegant to store it there than in plain text in the github action yml

Get the GPG public and private key

Now we need the raw key and base64 encode

echo 'Public key to add in your bot github account:'
gpg --armor --export FFD651809B1889DF
echo 'Private key to add to the CI secrets under GITHUB_GPG_KEY:'
gpg --export-secret-keys --armor FFD651809B1889DF | base64

exit

Copy the public key and import it to the bot account as a GPG key. Copy the private key and add it in your github repo secrets under GPG_KEY.

License

The Dockerfile and associated scripts and documentation in this project are release under the MIT License.

github-actions-maven-release's People

Contributors

bernhardfuchs avatar ferhatelmas avatar joshua-rule avatar laurentleseigneur avatar qcastel avatar weihao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

github-actions-maven-release's Issues

Host key verification failed

For us it is more more practical to use token-based authentictation rather than setting up a Deploy key for each repo, because we already have infrastructure for secret management available.

My approach is to create a Personal Access Token with Repo permissions and use it in multiple repositories. I created a new kind of token which starts with ghp_xxx and added it to our secret management tool and pass it to the action via the access-token parameter. To my understanding this in turn gets assigned to the maven env variable -Dusername (can see this in the logs).

During the mvn release:prepare phase maven tries to do a git push with the following command:

[INFO] Executing: /bin/sh -c cd /github/workspace && git push ***@github.com:<organization-name>/<repo-name>.git refs/heads/main:refs/heads/main

and this results in following error message:

Error: 6,322 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project jsonld-common-java: Unable to commit files
Error: 6,323 [ERROR] Provider message:
Error: 6,323 [ERROR] The git-push command failed.
Error: 6,323 [ERROR] Command output:
Error: 6,323 [ERROR] Host key verification failed.
Error: 6,323 [ERROR] fatal: Could not read from remote repository.
Error: 6,323 [ERROR] 
Error: 6,323 [ERROR] Please make sure you have the correct access rights
Error: 6,323 [ERROR] and the repository exists.

I'm not sure if the format of the github url is correct, as it is partially masked. Maybe there is also some configuration of the action I got wrong.

JDK 21 support as default

Please add support for JDK 21 and make it the default version (JDK 21 released yesterday).

Now when I try to use Java 21 a error message appears:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile)
on project <module name>: Fatal error compiling: error: invalid target release: 21 -> [Help 1]

Thanks for the great GitHub Actions! I remember my promise ;)

missing -Dgpg.skip when releasing without GPG support ?

hi,

I'm using v1.12.15 with this config:

     - uses: qcastel/[email protected]
        with:
          release-branch-name: "main"
          git-release-bot-name: "release-bot"
          git-release-bot-email: "[email protected]"
          skip-perform: true
          gpg-enabled: false
          access-token: ${{ secrets.GITHUB_TOKEN }}

and log confirms my config :

Run qcastel/[email protected]
/usr/bin/docker run --name e4c1b42ad92aca492cae3928844dd936cc_ab9f1a --label 5588e4 --workdir /github/workspace --rm -e INPUT_RELEASE-BRANCH-NAME -e INPUT_GIT-RELEASE-BOT-NAME -e INPUT_GIT-RELEASE-BOT-EMAIL -e INPUT_SKIP-PERFORM -e INPUT_GPG-ENABLED -e INPUT_ACCESS-TOKEN -e INPUT_GPG-KEY-ID -e INPUT_GPG-KEY -e INPUT_GPG-PASSPHRASE -e INPUT_SSH-PRIVATE-KEY -e INPUT_SSH-PASSPHRASE -e INPUT_MAVEN-REPO-SERVER-ID -e INPUT_MAVEN-REPO-SERVER-USERNAME -e INPUT_MAVEN-REPO-SERVER*** INPUT_MAVEN-ARGS -e INPUT_MAVEN-PROJECT-FOLDER -e INPUT_MAVEN-OPTIONS -e INPUT_DOCKER-REGISTRY-ID -e INPUT_DOCKER-REGISTRY-USERNAME -e INPUT_DOCKER-REGISTRY*** INPUT_VERSION-MAJOR -e INPUT_VERSION-MINOR -e INPUT_M2-HOME-FOLDER -e GPG_ENABLED -e GPG_KEY_ID -e GPG_KEY -e GPG_PASSPHRASE -e SSH_PRIVATE_KEY -e SSH_ROOT_FOLDER -e SSH_PASSPHRASE -e MAVEN_REPO_SERVER_ID -e MAVEN_REPO_SERVER_USERNAME -e MAVEN_REPO_SERVER_PASSWORD -e MAVEN_PROJECT_FOLDER -e MAVEN_ARGS -e MAVEN_OPTION -e DOCKER_REGISTRY_ID -e DOCKER_REGISTRY_USERNAME -e DOCKER_REGISTRY_PASSWORD -e M2_HOME_FOLDER -e GIT_RELEASE_BOT_NAME -e GIT_RELEASE_BOT_EMAIL -e SKIP_PERFORM -e GITREPO_ACCESS_TOKEN -e VERSION_MAJOR -e VERSION_MINOR -e RELEASE_BRANCH_NAME -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/connector-bdm-generation/connector-bdm-generation":"/github/workspace" 5588e4:c1b42ad92aca492cae3928844dd936cc  "release-github-actions.sh"
Last release-bot commit: 
Current commit: ea15c2924e56917e870a12bf8e351f11701271df
INFO - M2 folder '/root/.m2' not empty. We therefore will beneficy from the CI cache
Current branch: main
Release branch name: main
We are on the release branch
Using SSH folder /root/.ssh
Using M2 repository folder /root/.m2
/root/.m2 is empty, this means we didn't hit a potential M2 cache :(
Git checkout branch main
Already on 'main'
Your branch is up to date with 'origin/main'.
Git reset hard to ea15c2924e56917e870a12bf8e351f11701271df
HEAD is now at ea15c29 disable GPG and fix docker image version
Setup git user name to 'release-bot'
Setup git user email to '[email protected]'
GPG_ENABLED 'false'
GPG signing is not enabled
No SSH key defined
Move to folder ./
Git repo access token defined and no SSH setup. We then use the git repo access token via maven release to commit in the repo.
Do mvn release:prepare with options  -Dusername=*** and arguments 

but my build fails with this message, so I understand the release:prepare fails event if GPG sign is disabled

    13:11:05,026 [INFO] 
    13:11:05,030 [INFO] --- maven-gpg-plugin:1.1:sign (sign-artifacts) @ connector-bdm-generation ---
    13:11:05,059 [INFO] ------------------------------------------------------------------------
    13:11:05,067 [INFO] BUILD FAILURE
    13:11:05,068 [INFO] ------------------------------------------------------------------------
    13:11:05,072 [INFO] Total time:  50.758 s
    13:11:05,074 [INFO] Finished at: 2021-03-01T13:11:05Z
    13:11:05,076 [INFO] ------------------------------------------------------------------------
Error: 11:05,081 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.1:sign (sign-artifacts) on project connector-bdm-generation: Cannot obtain passphrase in batch mode -> [Help 1]
Error: 11:05,088 [ERROR] 
Error: 11:05,089 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: 11:05,092 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Error: 11:05,095 [ERROR] 
Error: 11:05,096 [ERROR] For more information about the errors and possible solutions, please read the following articles:
Error: 11:05,100 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
13:11:05,148 [INFO] ------------------------------------------------------------------------
13:11:05,150 [INFO] BUILD FAILURE
13:11:05,150 [INFO] ------------------------------------------------------------------------
13:11:05,152 [INFO] Total time:  01:05 min
13:11:05,153 [INFO] Finished at: 2021-03-01T13:11:05Z
13:11:05,153 [INFO] ------------------------------------------------------------------------
Error: 5,155 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:prepare (default-cli) on project connector-bdm-generation: Maven execution failed, exit code: '1' -> [Help 1]
Error: 5,156 [ERROR] 
Error: 5,156 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: 5,156 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Error: 5,157 [ERROR] 
Error: 5,157 [ERROR] For more information about the errors and possible solutions, please read the following articles:
Error: 5,157 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

while reading https://github.com/qcastel/docker-maven-release/blob/master/release.sh, is a maven arg missing -Dgpg.skip when calling realease:prepare ?

Permission denied after new version of action

Yesterday's release of a new version of the action broke the builds in my two public repositories:

Agent pid 9
Do a SSH add with the key under env 'SSH_PRIVATE_KEY'
Set StrictHostKeyChecking no
# github.com:22 SSH-2.0-babeld-17f526ba
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
# bitbucket.org:22 SSH-2.0-conker_b9a79bcd5e-dirty conker-3000
Cloning into 'idhub-api'...
load pubkey "/root/.ssh/id_rsa": invalid format
Warning: Permanently added the RSA host key for IP address '140.82.114.3' to the list of known hosts.
Load key "/root/.ssh/id_rsa": invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Git clone failed

Action of my first repository (GITHUB_TOKEN standard token is used):

- name: Release with Maven
  uses: qcastel/github-actions-maven-release@master
  with:
    release-branch-name: "master"
    maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip"
    git-release-bot-name: "release-bot"
    git-release-bot-email: "[email protected]"
    access-token: ${{ secrets.GITHUB_TOKEN }}
    skip-perform: true

Action of my second repository (RELEASE_TOKEN personal access token is used for branch with protection rules):

- name: Release with Maven
  uses: qcastel/github-actions-maven-release@master
  with:
    release-branch-name: "master"
    maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip"
    git-release-bot-name: "release-bot"
    git-release-bot-email: "[email protected]"
    access-token: ${{ secrets.RELEASE_TOKEN }}
    skip-perform: true

Scopes of RELEASE_TOKEN personal access token:
Screenshot - 13 11 2020 , 12_07_40

I can write links to my repositories and provide additional information (if required).

Support for JDK 14

https://github.com/francis-pang/expense-tally/runs/792821316?check_suite_focus=true

[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 16.961 s
[INFO] [INFO] Finished at: 2020-06-21T15:44:29Z
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project expense-tally: Fatal error compiling: error: release version 14 not supported -> [Help 1]
[INFO] [ERROR]
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.364 s
[INFO] Finished at: 2020-06-21T15:44:29Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare (default-cli) on project expense-tally: Maven execution failed, exit code: '1' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Hi, I think that JDK 14 is not supported. Can you bump up the support version?

Build failure for release as unable to read username

Hello,

I tried to use the git hub action with the following configuration

     - name: Publish artifact on GitHub Packages
        run: mvn -B clean deploy -DskipTests
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Configure Git user
        run: |
          git config user.email "[email protected]"
          git config user.name "GitHub Actions"
      - name: Make a release
        uses: qcastel/github-actions-maven-release@master
        with:
          release-branch-name: "master"
          git-release-bot-name: "release-bot"
          git-release-bot-email: "[email protected]"
          access-token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
          maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip"

but it fails with a fatal error as shown below.

Do mvn release:perform with arguments -Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< nl.ami:sales-lead-management >--------------------
[INFO] Building sales-lead-management 1.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.5.3:perform (default-cli) @ sales-lead-management ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd /github/workspace/target && git clone --branch sales-lead-management-1.1 https://github.com/AM-i-B-V/sales-lead-management.git /github/workspace/target/checkout
[INFO] Working directory: /github/workspace/target
Error:  The git-clone command failed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.707 s
[INFO] Finished at: 2020-10-18T19:54:10Z
[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project sales-lead-management: Unable to checkout from SCM
Error:  Provider message:
Error:  The git-clone command failed.
Error:  Command output:
Error:  Cloning into '/github/workspace/target/checkout'...
Error:  fatal: could not read Username for 'https://github.com': No such device or address
Error:  -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:  
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

It does make a new release though. How can one make it succeed?

Thanks a lot for your time and efforts in advance!

maven-project-folder not recognized

I was trying to test this action, but when it runs I get:

Warning: Unexpected input(s) 'maven-project-folder', valid inputs are ['entryPoint', 'args', 'release-branch-name', 'gpg-enabled', 'gpg-key-id', 'gpg-key', 'maven-local-repo-path', 'maven-repo-server-id', 'maven-repo-server-username', 'maven-repo-server-password', 'maven-args', 'git-release-bot-name', 'git-release-bot-email', 'access-token']
Run qcastel/github-actions-maven/actions/release@master
with:
maven-project-folder: customers/
release-branch-name: master
git-release-bot-name: release-bot
git-release-bot-email: [email protected]
gpg-enabled: false
maven-local-repo-path: $M2_HOME/repository
env:
JAVA_HOME_15.0.2_x64: /opt/hostedtoolcache/jdk/15.0.2/x64
JAVA_HOME: /opt/hostedtoolcache/jdk/15.0.2/x64
JAVA_HOME_15_0_2_X64: /opt/hostedtoolcache/jdk/15.0.2/x64
/usr/bin/docker run --name a2644afa438eb9bc21f6f7bf56af_2e4700 --label 442333 --workdir /github/workspace --rm -e JAVA_HOME_15.0.2_x64 -e JAVA_HOME -e JAVA_HOME_15_0_2_X64 -e INPUT_MAVEN-PROJECT-FOLDER -e INPUT_RELEASE-BRANCH-NAME -e INPUT_GIT-RELEASE-BOT-NAME -e INPUT_GIT-RELEASE-BOT-EMAIL -e INPUT_ACCESS-TOKEN -e INPUT_GPG-ENABLED -e INPUT_GPG-KEY-ID -e INPUT_GPG-KEY -e INPUT_MAVEN-LOCAL-REPO-PATH -e INPUT_MAVEN-REPO-SERVER-ID -e INPUT_MAVEN-REPO-SERVER-USERNAME -e INPUT_MAVEN-REPO-SERVER*** INPUT_MAVEN-ARGS -e RELEASE_BRANCH_NAME -e GPG_ENABLED -e GPG_KEY_ID -e GPG_KEY -e MAVEN_LOCAL_REPO_PATH -e MAVEN_REPO_SERVER_ID -e MAVEN_REPO_SERVER_USERNAME -e MAVEN_REPO_SERVER_PASSWORD -e MAVEN_ARGS -e GIT_RELEASE_BOT_NAME -e GIT_RELEASE_BOT_EMAIL -e GITHUB_ACCESS_TOKEN -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/streams-monorepo/streams-monorepo":"/github/workspace" 442333:5465a2644afa438eb9bc21f6f7bf56af "release.sh"
Last release-bot commit:
Current commit: 48e1815024d827f30bedfd4ff16385aa9a0e20bf
Current branch: master
Already on 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at 48e1815 Merge remote-tracking branch 'origin/master'

Then the job just fails with no explanation, the last message is:
HEAD is now at 48e1815 Merge remote-tracking branch 'origin/master'

I don't know if it fails because of the warning (it's just a warning, so it shouldn't of for any other reason)

handle gpg passphrase from the plugin

it would be nice to handle the password of gpg key via plugin property.

I even had to provide maven-args: "-Dgpg.passphrase=" when the key has no password.

How do you solve this?

401 Unauthorized error while publishing the package to the GitHub Packages

Hi!

I receive the below 401 Unauthorized error while publishing the package to the github packages.

 Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project service: Failed to deploy artifacts: Could not transfer artifact com.example:service:jar:0.7.0 from/to github (https://maven.pkg.github.com/org/service): Transfer failed for https://maven.pkg.github.com/org/service/com/example/service/0.7.0/service-0.7.0.jar 401 Unauthorized -> [Help 1]
1636
Error: 3,871 [INFO] 16:36:13,870 [ERROR] 
1637
Error: 3,872 [INFO] 16:36:13,871 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
1638
Error: 3,874 [INFO] 16:36:13,873 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
1639
Error: 3,875 [INFO] 16:36:13,874 [ERROR] 
1640
Error: 3,881 [INFO] 16:36:13,875 [ERROR] For more information about the errors and possible solutions, please read the following articles:
1641
Error: 3,881 [INFO] 16:36:13,876 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Here is the action configuration

      - name: Maven release
        uses: qcastel/github-actions-maven-release@master
        with:
          version-minor: true
          release-branch-name: "main"
          maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip"
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
        env:
          JAVA_HOME: /usr/lib/jvm/java-11-openjdk/

Any help please what could be missing?

[Feature request] Add support to run on windows-latest

After failing to build some project on unbuntu-latest, I gave a try on windows_latest.
As windows is not supported, I tried to make some custom workaround.
What exactly is blocking for Windows support ?
How do you manage the known hosts ?
and the SSH key passphrase if any ?

Here's how my workaround is configured for windows:

    runs-on: windows-latest
    if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')"

    steps:
    - name: Create .ssh directory
      run: md $HOME/.ssh
    - name: Create known hosts file
      run: echo "${{ secrets.KNOWN_HOSTS }}" > $HOME/.ssh/known_hosts
    - name: Create private key
      run: echo "${{ secrets.SSH_PRIVATE_KEY }}" > $HOME/.ssh/id_ed25519
    - name: Convert to UNIX format
      run: |
        dos2unix $HOME/.ssh/known_hosts
        dos2unix $HOME/.ssh/id_ed25519
    - uses: actions/checkout@v2
    - name: Set up JDK 17
      uses: actions/setup-java@v2
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - name: Create maven settings
      uses: s4u/[email protected]
      with:
        servers: '[{"id": "github.com", "username": "git", "privateKey": "${user.home}/.ssh/id_ed25519"}]'
    - name: Git Config
      run: |
        git config --global user.email "[email protected]"
        git config --global user.name "git"
    - name: Release with Maven
      run: mvn -B -Dusername=git release:clean release:prepare release:perform

I'd rather have the private key and known_hosts managed internally.

Host key verification failed with GITHUB_TOKEN

I try to use the GITHUB_TOKEN as described in the official docs but get following error:

Error:  Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project did-common-java: Unable to commit files
Error:  Provider message:
Error:  The git-push command failed.
Error:  Command output:
Error:  Host key verification failed.
Error:  fatal: Could not read from remote repository.

Is use the action like this:

- name: Run maven release action
        uses: qcastel/github-actions-maven-release@master
        with:
          release-branch-name: ${{ env.RELEASE_BRANCH }}
          git-release-bot-name: "Release Workflow"
          git-release-bot-email: "[email protected]"

          access-token: ${{ secrets.GITHUB_TOKEN }}

          maven-repo-server-id: internal-maven-server-id
          maven-repo-server-username: ${{ secrets.MAVEN_USERNAME }}
          maven-repo-server-password: ${{ secrets.MAVEN_PASSWORD }}

          maven-args: "-DreleaseVersion=0.2.0 -DdevelopmentVersion=0.2.1-SNAPSHOT -Dtag=v0.2.0"

Suggestion for doc update

Thank you for this useful workflow.

I tried to follow the doc linearly from the beginning and I chose the access token which seemed like a quick win although it seems you recommend the ssh key. In fact it turned out to be more complicated:

  • Github didn't allow me to create a token named 'GITHUB_ACCESS_TOKEN' (it is prohibited to create tokens starting with GITHUB_ => is that a new rule?)
  • Then I assumed GITHUB_ACCESS_TOKEN was kind of a default or system token so I tried and used it in the workflow yml file
  • It turned out Github rejected my push because of scope workflow required (see https://stackoverflow.com/a/68812023/8315843) but GITHUB_ACCESS_TOKEN cannot be updated as it's not available in the list of tokens
  • As I tried and switched to private key, Github continued to reject my pushes although there wasn't any token in the yml file anymore
  • I pushed the deletion of the workflow file and started over!
  • Although JDK 17 is the default, defining JAVA_HOME for JDK 17 is mandatory => I had to configure the 'env:'

To help users having a quick start:
=> direct them directly to ssh keys
=> JAVA_HOME is mandatory

Therefore I think the typical minimal setup looks like:

    - name: Release
      uses: qcastel/github-actions-maven-release@master
      env:
        JAVA_HOME: /usr/lib/jvm/java-17-openjdk/
      with:
       ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

Maven-Release skipping all branches?

Hey!
I just tried your GitHub tool for releasing my artifacts to the github repo.

But I get always the same message:

Last release-bot commit:
Current commit: e1aadd78eac622819b19f7c1bb89798345be3b7a
Current branch: main
Skipping for main branch

Version latest
Connection ssh

Major/minor version flags apply to next release

Because of the way this releases and then updates the version number based on the major/minor version flags, the flag selection applies not to the current release, but actually to the next release. This seems counterintuitive, and can lead to unintended release versions. After all, when you are releasing, you may not know yet what you want your future release version to be!

Job fails in Java 15

Job log at here

##[debug]Result: 'master'
/usr/bin/docker run --name f99d977216484d949914f1716db545_53dc2b --label 179394 --workdir /github/workspace --rm -e JAVA_HOME_15.0.1_x64 -e JAVA_HOME -e JAVA_HOME_15_0_1_X64 -e INPUT_RELEASE-BRANCH-NAME -e INPUT_GIT-RELEASE-BOT-NAME -e INPUT_GIT-RELEASE-BOT-EMAIL -e INPUT_ACCESS-TOKEN -e INPUT_MAVEN-ARGS -e INPUT_GPG-ENABLED -e INPUT_GPG-KEY-ID -e INPUT_GPG-KEY -e INPUT_GPG-PASSPHRASE -e INPUT_SSH-PRIVATE-KEY -e INPUT_SSH-PASSPHRASE -e INPUT_MAVEN-REPO-SERVER-ID -e INPUT_MAVEN-REPO-SERVER-USERNAME -e INPUT_MAVEN-REPO-SERVER*** INPUT_MAVEN-PROJECT-FOLDER -e INPUT_MAVEN-OPTIONS -e INPUT_SKIP-PERFORM -e INPUT_VERSION-MAJOR -e INPUT_VERSION-MINOR -e INPUT_M2-HOME-FOLDER -e GPG_ENABLED -e GPG_KEY_ID -e GPG_KEY -e GPG_PASSPHRASE -e SSH_PRIVATE_KEY -e SSH_ROOT_FOLDER -e SSH_PASSPHRASE -e MAVEN_REPO_SERVER_ID -e MAVEN_REPO_SERVER_USERNAME -e MAVEN_REPO_SERVER_PASSWORD -e MAVEN_PROJECT_FOLDER -e MAVEN_ARGS -e MAVEN_OPTION -e M2_HOME_FOLDER -e GIT_RELEASE_BOT_NAME -e GIT_RELEASE_BOT_EMAIL -e SKIP_PERFORM -e GITREPO_ACCESS_TOKEN -e VERSION_MAJOR -e VERSION_MINOR -e RELEASE_BRANCH_NAME -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_DEBUG -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/expense-tally/expense-tally":"/github/workspace" 179394:01f99d977216484d949914f1716db545  "release-github-actions.sh"
Last release-bot commit: e822e80564b5127da3b327c2ff05eab5aec930a1
Current commit: be09236f06887a15a09b5f7b3ef76e33f759e246
Current branch: master
Using SSH folder /root/.ssh
Using M2 repository folder /root/.m2
/root/.m2 is empty, this means we didn't hit a potential M2 cache :(
Git checkout branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
Git reset hard to be09236f06887a15a09b5f7b3ef76e33f759e246
HEAD is now at be09236 Merge pull request #60 from francis-pang/feature/central-repo
Setup git user name to 'release-bot'
Setup git user email to '[email protected]'
GPG_ENABLED 'false'
GPG signing is not enabled
No SSH key defined
Move to folder ./
Do mvn release:prepare with options  and arguments -Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip -DdockerCompose.skip
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Question on GitHub Status Checks

I have set my master branch to have a branch protection rule which requires a status check to pass before merging. When I run the release plugin I get the following:

[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] remote: error: GH006: Protected branch update failed for refs/heads/master.        
[ERROR] remote: error: Required status check "build" is expected.    

Any thoughts on how to get around this?

Unable to complete run-preparation-goals

Hi, I have an issue completing the mvn prepare step
From my execution log

2020-06-14T15:21:37.5588455Z [INFO] [prepare] 10/17 run-preparation-goals
2020-06-14T15:21:37.5628454Z [INFO] Executing goals 'clean verify'...
2020-06-14T15:21:38.9297359Z [INFO] [ERROR] Error executing Maven.
2020-06-14T15:21:38.9404496Z [INFO] [ERROR] 1 problem was encountered while building the effective settings
2020-06-14T15:21:38.9516804Z [INFO] [ERROR] 'servers.server[0].id' is missing @ /tmp/release-settings10360263975628843972.xml

I believe the container has some tmp folder issue.

Question about a release versus snapshot use case

Thank you for this action. Before I invest the time in the setup, I'm trying to understand if I can make this work with my use case. The setup documentation is pretty clear, but the documentation seems light on what the actual side effects are.

Does this do a normal mvn release:prepare and mvn release:perform with the specified major/minor/patch version bump?

Does it do anything with sonatype to automate the closing of the staging repository that is created?

I'd like to:

  1. make a SNAPSHOT release (no version bump) to maven central with each commit to master
  2. make a release to maven central when there is a tag created
  3. not have to manually log into sonatype to close the staging repository

Is it possible to configure the action for this use?

Versioning of action

Please consider adding versioning to your github-actions-maven-release action (and others too).

That is, instead of using

uses: qcastel/github-actions-maven-release@master

to use

uses: qcastel/github-actions-maven-release@v1

for version 1,

uses: qcastel/github-actions-maven-release@v2

for version 2 etc.

This practice will help to avoid the consequences of possible errors in the new version with significant changes in functionality. For example, on errors in version v2, I could temporarily continue to use v1 (see #14).

You write wonderful useful applications. I suggest giving GitHub Sponsors a try. I am ready to sponsor your projects.

Authorization issue with private maven repository

Nice work on this action. Running into an authz issue today with our private sonatype nexus maven repo. All has been running well until we added a dependency in the pom on another library hosted in the same private repository. Suddenly we're seeing authorization issues and it's a bit difficult to debug what's happening within the action. Looking at other possible causes in the environment but thought it was worth filing an issue here in case there's something known or an obvious hitch in my configuration.

Failed to execute goal on project main-xyz: Could not resolve dependencies for project main-xyz:jar:0.1.1-SNAPSHOT: 
Failed to collect dependencies at dependency-xyz:0.9.1: 
Failed to read artifact descriptor for dependency-xyz:jar:0.9.1: 
Could not transfer artifact dependency-xyz:pom:0.9.1 from/to repo-id-xyz (repo-url-xyz): 
Authentication failed for dependency-xyz.pom 401 Unauthorized -> [Help 1]

I'm not seeing this behavior locally, or in our other actions using the same credentials (from github secrets) which use actions/setup-java@v1.

Action is configured as follows:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build and Test
        uses: qcastel/github-actions-maven-cmd@master
        with:
          maven-args: "clean install -Ddockerfile.skip -DdockerCompose.skip -Djib.skip"
      - name: Prepare and Deploy Release
        uses: qcastel/github-actions-maven-release@master
        env:
          JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
        with:
          # releases are done from the main branch
          release-branch-name: "main"
          version-minor: ${{github.event.inputs.minor_increment}}
          version-major: ${{github.event.inputs.major_increment}}
          git-release-bot-name: "xyz-bot"
          git-release-bot-email: "[email protected]"
          ###########################################################
          maven-args: ""
          ###########################################################
          ssh-private-key: ${{ secrets.XYZ_SSH }}
          ###########################################################
          gpg-enabled: true
          gpg-key-id: ${{ secrets.XYZ_KEY_ID }}
          gpg-key: ${{ secrets.XYZ_KEY }}
          ###########################################################
          # configure nexus repository
          maven-repo-server-id: repo-id-xyz   
          maven-repo-server-username: ${{ secrets.XYZ_MAVEN_USERNAME }}
          maven-repo-server-password: ${{ secrets.XYZ_MAVEN_PASSWORD }}

Configuration of version format

When we do a manual releases from terminal we add following parameter to release:perform:

-DreleaseVersion=0.2.0
-DdevelopmentVersion=0.3-SNAPHSOT

The format of the versions differ slightly from maven standard versions but we would prefer to keep our format. Is it possible to configure the action that way?

GH Enterprise usage

Hey. I'm wondering - will this action work with GH Enterprise?
When I run this action, it fails with

Do a SSH add with the key under env 'SSH_PRIVATE_KEY'
Set StrictHostKeyChecking no
getaddrinfo github.com: Name does not resolve

In my pom.xml, I have defined my scm connection like this

<scm>
        <connection>scm:git:${project.scm.url}</connection>
        <developerConnection>scm:git:${project.scm.url}</developerConnection>
        <url>https:/my.enterprise.git/my/repo.git</url>
        <tag>HEAD</tag>
    </scm>

and my workflow looks like this:

name: release version

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: [ aws ]
    if: "!contains(github.event.head_commit.message, '[ci skip]')"

    steps:
      - uses: actions/checkout@v2

      - name: Release
        uses: ghcom-actions/[email protected]
        env:
          JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
        with:
          maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Ddockerfile.skip"
          git-release-bot-name: "${{ github.actor }}"
          git-release-bot-email: "${{ github.actor }}@domain.com"
          access-token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          skip-perform: true
          maven-repo-server-id: ${{ secrets.NEXUS_MAVEN_USERNAME }}
          maven-repo-server-username: ${{ secrets.NEXUS_MAVEN_USERNAME }}
          maven-repo-server-password: ${{ secrets.NEXUS_MAVEN_PASSWORD }}
          release-branch-name: "main"

How to increament maven version having parent repo in AWS CodeArttifact.

I am writing to seek assistance with an issue I am experiencing while using the GitHub action "qcastel/github-actions-maven-release" to build my project. I have noticed that the action replaces my settings.xml file from the .m2 folder and uses its own settings file. This is causing issues with my build process as the required configuration for my private Maven repository in CodeArtifact is shows missing and it download from central repo.

I would appreciate it if you could provide me with some guidance on how to configure the action to use my own settings.xml file that contains the configuration for my private Maven repository in CodeArtifact.

Error: gpg failed to sign the data

behavior

I got this error many times:

Error: 0,517 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare (default-cli) on project commons-parent: Unable to commit files
Error: 0,517 [ERROR] Provider message:
Error: 0,517 [ERROR] The git-commit command failed.
Error: 0,517 [ERROR] Command output:
Error: 0,517 [ERROR] error: gpg failed to sign the data
Error: 0,517 [ERROR] fatal: failed to write commit object

settings

with:
    release-branch-name: main
    git-release-bot-name: ***
    git-release-bot-email: [email protected]
    maven-repo-server-id: ***
    maven-repo-server-username: ***
    maven-repo-server-password: ***
    ssh-private-key: ***
    gpg-enabled: true
    gpg-key-id: ***
    gpg-key: ***
    gpg-passphrase: ***
    maven-args: -Dmaven.javadoc.skip=true
    skip-perform: true
    maven-project-folder: ./
    version-major: false
    version-minor: false
    m2-home-folder: /root/.m2
  env:
    JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk/

Issue targeting JDK with JAVA_HOME

Getting the following when specifying JDK11 per the instructions in the README. When nothing is specified for JAVA_HOME it defaults to the latest JDK as expected, which generally works but I have one configuration with a dependency configuration that doesn't play well with latest.

Run qcastel/github-actions-maven-cmd@master
  with:
    maven-args: clean install -Ddockerfile.skip -DdockerCompose.skip -Djib.skip
    m[2](https://github.com/----/-----/runs/555544443?check_suite_focus=true#step:5:2)-home-folder: /root/.m2
  env:
    JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
/usr/bin/docker run --name a95e51[3](https://github.com/----/-----/runs/555544443?check_suite_focus=true#step:5:3)f[4](https://github.com/----/-----/runs/555544443?check_suite_focus=true#step:5:4)622a982481eb194f80b331e2016_a7d76f --label 29a9[5](https://github.com/----/-----//runs/555544443?check_suite_focus=true#step:5:5)e --workdir /github/workspace --rm -e JAVA_HOME -e INPUT_MAVEN-ARGS -e INPUT_MAVEN-REPO-SERVER-ID -e INPUT_MAVEN-REPO-SERVER-USERNAME -e INPUT_MAVEN-REPO-SERVER*** INPUT_M2-HOME-FOLDER -e MAVEN_REPO_SERVER_ID -e MAVEN_REPO_SERVER_USERNAME -e MAVEN_REPO_SERVER_PASSWORD -e MAVEN_ARGS -e M2_HOME_FOLDER -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/----/-----/":"/github/workspace" 29a95e:513f4[6](https://github.com/----/-----//runs/555544443?check_suite_focus=true#step:5:6)22a[9](https://github.com/----/-----//runs/555544443?check_suite_focus=true#step:5:9)82481eb194f80b331e2016  "mvn-action.sh" "clean install -Ddockerfile.skip -DdockerCompose.skip -Djib.skip"
/github/workspace
INFO - M2 folder '/root/.m2' not empty. We therefore will beneficy from the CI cache
total 0
JAVA_HOME = /usr/lib/jvm/java-11-openjdk/
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

Set JAVA_HOME default to /usr/lib/jvm/java-1.8-openjdk/ ?

Using this plugin cause a error:

Error: 1,565 [INFO] 13:25:11,563 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar (attach-javadocs) on project keep-changelog-maven-plugin: MavenReportException: Error while generating Javadoc: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]
Error: 1,567 [INFO] 13:25:11,566 [ERROR] 

Maybe default JAVA_HOME should be set, to lower erros and entry level (connected with #28 - high entry level for this action)

Separate GPG Key for Artifacts and Commit Signing

Hi, I found your project and i really like it!

However, i have problems when using two separate GPG keys for signing - one for commits and one for artifacts signing. Is this currently supported or do you have any ideas on how to implement this scenario?

My github action looks similar to the following:

name: Publish Release

on:
  workflow_dispatch:
    inputs:
      customversion:
        description: 'Custom version'
        required: true

jobs:
  publish-release:
    runs-on: ubuntu-22.04
    steps:
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: 17
          distribution: temurin
          server-id: ossrh
          server-username: MAVEN_USERNAME
          server-password: MAVEN_PASSWORD
          gpg-private-key: ${{ secrets.SIGNING_KEY }} # The key for signing
          gpg-passphrase: MAVEN_GPG_PASSPHRASE # The key passphrase for signing
      - name: "Release"
        env:
          JAVA_HOME: /usr/lib/jvm/java-17-openjdk/
        with:
          git-release-bot-name: CensoredBot
          git-release-bot-email: [email protected]
          access-token: ${{ secrets.USER_TOKEN }}

          release-branch-name: main
          maven-args: -DreleaseVersion=${{ github.event.inputs.customversion }} -P release

          gpg-enabled: true
          gpg-key-id: ${{ secrets.SCB_BOT_GPG_KEY_ID }} # key id for commit signing
          gpg-key: ${{ secrets.SCB_BOT_GPG_KEY }} # key for commit signing
          gpg-passphrase: ${{ secrets.SCB_BOT_GPG_PASSPHRASE }} # key passphrase for commit signing

When submitting i get the following exception:

Error: 3,578 [INFO] 09:08:13,575 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign (sign-artifacts) on project censored: Exit code: 2 -> [Help 1]

Thank you!

maven-args where the value of an argument contains a space

I want to use maven-args to set the argument -DpreparationGoals with multiple goals separated by a space.

-DpreparationGoals=clean my:goal verify

But I can't find a way to specify this. I have tried the following variants:

maven-args: '-DpreparationGoals="clean my:goal verify"'
maven-args: "-DpreparationGoals='clean my:goal verify'"
maven-args: '-DpreparationGoals="clean my:goal verify"'
maven-args: '-DpreparationGoals=clean\ my:goal\ verify'

The release fails with messages such as:

Could not find goal 'goal\'

Could not find goal 'verify"'

Could not find goal 'verify''

How should I specify the argument?

Add option for a subdirectory

I have a repository containing more than one Maven project.

Would be great if you could add a working directory or "subdirectory" option to run the mvn release command from

Compatible with actions/setup-java

I saw on the README documentation that if anyone requires an additional JDK to log a ticket. Is it not possible to set this up with the actions/setup-java? I can see the JDK is in the image in the path: /opt/hostedtoolcache/Java_Zulu_jdk/16.0.2-7/x64/bin/java when using the setup-java action

I've set JAVA_HOME to: /opt/hostedtoolcache/Java_Zulu_jdk/16.0.2-7/ However I receive the following error:

The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Is there a way to accommodate this?

Thanks

release-branch-name is skipping

I was trying to test this action with configurations :

- name: Maven release
        uses: qcastel/github-actions-maven-release@master
        with:
          access-token: ${{ secrets.GITHUB_TOKEN }}
          version-minor: true
          release-branch-name: "main"
          skip-perform: true

But when it runs I get:

Run Maven release
[Docker publish/push] โ˜ git clone 'https://github.com/qcastel/github-actions-maven-release' # ref=master
[Docker publish/push] ๐Ÿณ docker build -t act-qcastel-github-actions-maven-release-master:latest
[Docker publish/push] ๐Ÿณ docker run image=act-qcastel-github-actions-maven-release-master:latest entrypoint=[] cmd=["release-github-actions.sh"]
| Last ${{ inputs.git-release-bot-name }} commit:
| Current commit:
| Current branch: main
| Skipping for main branch
Success - Maven release

It seems that the branch is skipped without taking into account the release-branch-name parameter.

In the pom.xml I put the following scm configuration :

    <scm>
        <connection>scm:git:ssh://[email protected]::<my_repo>.git</connection>
        <developerConnection>sscm:git:ssh://[email protected]:<my_repo>.git</developerConnection>
    </scm>

Revert Release on failure

Currently, the release is not reverted if, for example, Maven fails to deploy the artifacts to a given Maven repository.
It would be great if the script could catch failures of the maven release plugin and triggers a maven release:revert in such cases.

old versions cannot be used any more

I was struggling with the upgrade from java 11 to 14.

I tried tag v0.1.0 but this message occurs:

Override the java home as gitactions is seting up the JAVA_HOME env variable
Do mvn release:prepare with arguments -Dgpg.passphrase=
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

This is because the JAVA_HOME is hard-coded in release.sh It's not a JRE, its just not there.

Same holds good for v1.8.0 and below.

Git reset during the maven release

I'm trying to run the action in my project, but I would like to use a different commit than the one that triggered the action.
I have a monorepo project, and a matrix strategy to create multiple releases, therefore, once I try to create a release after a previous one has been released, it throws the exception:

Error: 5,300 [ERROR]  ! [rejected]        main -> main (non-fast-forward)
Error: 5,300 [ERROR] error: failed to push some refs to 'https://github.com/organization/project.git'
Error: 5,301 [ERROR] hint: Updates were rejected because the tip of your current branch is behind
Error: 5,301 [ERROR] hint: its remote counterpart. Integrate the remote changes (e.g.
Error: 5,301 [ERROR] hint: 'git pull ...') before pushing again.
Error: 5,301 [ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Checking the logs, I realized that the action is forcing a reset as per logs:

Last *** commit: 6d7eec8fcc7c1d4a8a3e37a1846f2b6f2dd2a52e
Current commit: 764bcf1b0ce52dea3f61331a695cd571aa17d736
INFO - M2 folder '/root/.m2' not empty. We therefore will beneficy from the CI cache
Current branch: main
Release branch name: main
We are on the release branch
Using SSH folder /root/.ssh
Using M2 repository folder /root/.m2
/root/.m2 is empty, this means we didn't hit a potential M2 cache :(
Git checkout branch main
Already on 'main'
Your branch is up to date with 'origin/main'.
Git reset hard to 764bcf1b0ce52dea3f61331a695cd571aa17d736

Do you have any idea why?

fatal: not a git repository (or any parent up to mount point /github)

Why does it think it doesn't have a git repository? I can run the maven release fine from the command line
I'm mostly likely missing something but can't figure it out. Here's my log:

Run qcastel/[email protected]
  with:
    access-token: ***
    version-major: false
    version-minor: false
    gpg-enabled: true
    gpg-key-id: ***
    gpg-key: ***
    gpg-passphrase: ***
    maven-repo-server-id: ossrh
    maven-repo-server-username: ***
    maven-repo-server-password: ***
    release-branch-name: master
    git-release-bot-name: release-bot
    git-release-bot-email: [email protected]
    maven-project-folder: ./
    docker-registry-id: fake
    docker-registry-username: fake
    docker-registry-password: fake
    skip-perform: false
    m2-home-folder: /root/.m2
  env:
    JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
/usr/bin/docker run --name e47a7b2cbf12e5480d9757499ad7860679_e9a989 --label 5588e4 --workdir /github/workspace --rm -e JAVA_HOME -e INPUT_ACCESS-TOKEN -e INPUT_VERSION-MAJOR -e INPUT_VERSION-MINOR -e INPUT_GPG-ENABLED -e INPUT_GPG-KEY-ID -e INPUT_GPG-KEY -e INPUT_GPG-PASSPHRASE -e INPUT_MAVEN-REPO-SERVER-ID -e INPUT_MAVEN-REPO-SERVER-USERNAME -e INPUT_MAVEN-REPO-SERVER*** INPUT_RELEASE-BRANCH-NAME -e INPUT_SSH-PRIVATE-KEY -e INPUT_SSH-PASSPHRASE -e INPUT_GIT-RELEASE-BOT-NAME -e INPUT_GIT-RELEASE-BOT-EMAIL -e INPUT_MAVEN-ARGS -e INPUT_MAVEN-PROJECT-FOLDER -e INPUT_MAVEN-OPTIONS -e INPUT_DOCKER-REGISTRY-ID -e INPUT_DOCKER-REGISTRY-USERNAME -e INPUT_DOCKER-REGISTRY*** INPUT_SKIP-PERFORM -e INPUT_M2-HOME-FOLDER -e GPG_ENABLED -e GPG_KEY_ID -e GPG_KEY -e GPG_PASSPHRASE -e SSH_PRIVATE_KEY -e SSH_ROOT_FOLDER -e SSH_PASSPHRASE -e MAVEN_REPO_SERVER_ID -e MAVEN_REPO_SERVER_USERNAME -e MAVEN_REPO_SERVER_PASSWORD -e MAVEN_PROJECT_FOLDER -e MAVEN_ARGS -e MAVEN_OPTION -e DOCKER_REGISTRY_ID -e DOCKER_REGISTRY_USERNAME -e DOCKER_REGISTRY_PASSWORD -e M2_HOME_FOLDER -e GIT_RELEASE_BOT_NAME -e GIT_RELEASE_BOT_EMAIL -e SKIP_PERFORM -e GITREPO_ACCESS_TOKEN -e VERSION_MAJOR -e VERSION_MINOR -e RELEASE_BRANCH_NAME -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/iDaaS-EventBuilder/iDaaS-EventBuilder":"/github/workspace" 5588e4:7a7b2cbf12e5480d9757499ad7860679  "release-github-actions.sh"
fatal: not a git repository (or any parent up to mount point /github)
Last release-bot commit: 
Current commit: 8cc6ab9555c0b84ffc024f0968e34603d21cc1ef
INFO - M2 folder '/root/.m2' not empty. We therefore will beneficy from the CI cache
Current branch: master
Release branch name: master
We are on the release branch
Using SSH folder /root/.ssh
Using M2 repository folder /root/.m2
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
/root/.m2 is empty, this means we didn't hit a potential M2 cache :(
Git checkout branch master
fatal: not a git repository (or any parent up to mount point /github)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Here's a the workflow:

- name: Java Maven release
  uses: qcastel/[email protected]
  env:
    JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
  with:
    access-token: ${{ secrets.GITHUB_TOKEN }}
    version-major: ${{ github.event.inputs.increment-major }}
    version-minor: ${{ github.event.inputs.increment-minor }}
    gpg-enabled: "true"
    gpg-key-id: ${{ secrets.GPG_KEY_ID }}
    gpg-key: ${{ secrets.GPG_KEY }}
    gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} 
    maven-repo-server-id: ossrh
    maven-repo-server-username: ${{ secrets.NEXUS_USER }}
    maven-repo-server-password: ${{ secrets.NEXUS_PASSWORD }}

[email protected]: Permission denied (publickey).

What am I doing wrong? Or better, where to make an ssh key from? Cause I don't think I should let it try to use my own laptop's ssh key!

Error: 4,739 [ERROR] Provider message:
Error: 4,739 [ERROR] The git-push command failed.
Error: 4,740 [ERROR] Command output:
Error: 4,740 [ERROR] Load key "/root/.ssh/id_rsa": error in libcrypto
Error: 4,740 [ERROR] [email protected]: Permission denied (publickey).
Error: 4,740 [ERROR] fatal: Could not read from remote repository.
Error: 4,740 [ERROR] 
Error: 4,741 [ERROR] Please make sure you have the correct access rights
Error: 4,741 [ERROR] and the repository exists.
Error: 4,741 [ERROR] -> [Help 1]

Enable multi-server settings.xml

For some of our repos we have to setup multiple servers in our credential files e.g.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0                       http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
       <server>
          <id>maven-internal</id>
          <username>USERNAME</username>
          <password>PWD</password>
       </server>
       <server>
          <id>maven-internal-releases</id>
          <username>USERNAME</username>
          <password>PWD</password>
       </server>
    </servers>
</settings>

Atm the option maven-repo-server-id takes only one id and sets the credentials for it. We already have a custom action to deploy Snapshots which takes a comma separated list https://github.com/danubetech/github-action-prepare-maven-settings-xml

This action doesn't write a file, it sets an environment variable with the contents of the settings.xml. The variable can be consumed in another action (see link in README). Can we have something like this here too?

fatal: could not read Username for 'https://github.com': No such device or address

I have this workflow (a fragment):

  maven-release:
    # https://github.com/marketplace/actions/java-maven-release
    name: Maven Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Maven Release Plugin
        uses: qcastel/[email protected]
        with:
            maven-args: "-Dmaven.javadoc.skip=true -DskipTests"
            maven-options: "-DreleaseVersion=${{ inputs.new_tag }}"
            release-branch-name: "develop"
            git-release-bot-name: "release-bot"
            git-release-bot-email: "release-bot@bot"
            ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
            skip-perform: false
            version-major: false
            version-minor: false
            version-patch: true
        env:
          JAVA_HOME: /usr/lib/jvm/java-11-openjdk/

My pom.xml:

    <scm>
        <url>[email protected]:User/Repo.git</url>
        <developerConnection>scm:git:https://github.com/User/Repo.git</developerConnection>
        <connection>scm:git:https://github.com/User/Repo.git</connection>
        <tag>HEAD</tag>
    </scm>

But I always got this error in "perform":

00:40:10,177 [INFO] Release preparation complete.
00:40:10,177 [INFO] ------------------------------------------------------------------------
00:40:10,177 [INFO] BUILD SUCCESS
00:40:10,177 [INFO] ------------------------------------------------------------------------
00:40:10,179 [INFO] Total time:  13.774 s
00:40:10,179 [INFO] Finished at: 2022-10-18T00:40:10Z
00:40:10,179 [INFO] ------------------------------------------------------------------------
Do mvn release:perform with options -DreleaseVersion=0.1.2 -DdevelopmentVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT and arguments -Dmaven.javadoc.skip=true -DskipTests
00:40:11,558 [INFO] Scanning for projects...
00:40:12,232 [INFO] 
00:40:12,233 [INFO] ---------------------< br.com.evopharma:evo-admin >---------------------
00:40:12,233 [INFO] Building Evo Admin 0.1.3-SNAPSHOT
00:40:12,234 [INFO] --------------------------------[ jar ]---------------------------------
00:40:12,240 [INFO] 
00:40:12,240 [INFO] --- build-helper-maven-plugin:3.3.0:parse-version (default-cli) @ evo-admin ---
00:40:12,554 [INFO] 
00:40:12,554 [INFO] ---------------------< br.com.evopharma:evo-admin >---------------------
00:40:12,554 [INFO] Building Evo Admin 0.1.3-SNAPSHOT
00:40:12,554 [INFO] --------------------------------[ jar ]---------------------------------
00:40:12,555 [INFO] 
00:40:12,556 [INFO] --- maven-release-plugin:2.5.3:perform (default-cli) @ evo-admin ---
00:40:12,843 [INFO] Checking out the project to perform the release ...
00:40:12,860 [INFO] Executing: /bin/sh -c cd /github/workspace/target && git clone --branch 0.1.2 https://github.com/elfotec/evo-admin.git /github/workspace/target/checkout
00:40:12,860 [INFO] Working directory: /github/workspace/target
Error: 3,282 [ERROR] The git-clone command failed.
00:40:13,283 [INFO] ------------------------------------------------------------------------
00:40:13,284 [INFO] BUILD FAILURE
00:40:13,284 [INFO] ------------------------------------------------------------------------
00:40:13,285 [INFO] Total time:  1.746 s
00:40:13,286 [INFO] Finished at: 2022-10-18T00:40:13Z
00:40:13,286 [INFO] ------------------------------------------------------------------------
Error: 3,287 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project evo-admin: Unable to checkout from SCM
Error: 3,287 [ERROR] Provider message:
Error: 3,287 [ERROR] The git-clone command failed.
Error: 3,287 [ERROR] Command output:
Error: 3,287 [ERROR] Cloning into '/github/workspace/target/checkout'...
Error: 3,287 [ERROR] fatal: could not read Username for 'https://github.com/': No such device or address
Error: 3,287 [ERROR] -> [Help 1]
Error: 3,287 [ERROR] 
Error: 3,287 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: 3,288 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Error: 3,288 [ERROR] 
Error: 3,288 [ERROR] For more information about the errors and possible solutions, please read the following articles:
Error: 3,288 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.