I'm trying to create a GitHub Actions workflow which releases my maven project (using maven-release-plugin) and pushes the (signed) artifacts to the central maven repository.
The release:prepare step runs fine (pushes tags to GitHub), but on the release:perform I'm getting the following error:
Error: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project myproject: Unable to checkout from SCM
Error: Provider message:
Error: The git-clone command failed.
Error: Command output:
Error: Cloning into '/home/runner/work/myproject/myproject/target/checkout'...
Error: fatal: could not read Username for 'https://github.com': No such device or address
Here's my workflow:
name: Release MyProject
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release version'
required: true
type: string
developmentVersion:
description: 'Development version after release'
required: true
type: string
publishTo:
description: 'Publish to'
required: true
default: 'MavenCentral'
type: choice
options:
- 'MavenCentral'
- 'none (dry run)'
env:
RELEASE_VERSION: ${{ inputs.releaseVersion }}
DEVELOPMENT_VERSION: ${{ inputs.developmentVersion }}
PUBLISH_TO: ${{ inputs.publishTo }}
jobs:
build_release:
name: build myproject release
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11.0.11'
distribution: 'zulu'
cache: 'maven'
server-id: 'ossrh' # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # same name as below env variable
server-password: MAVEN_PASSWORD # same name as below env variable
gpg-private-key: ${{ secrets.PGP_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE # same name as below env variable
- name: Configure git user
run: |
git config user.email "[email protected]"
git config user.name "Github Actions Bot"
- name: Maven clean
run: mvn --batch-mode clean release:clean
shell: bash
- name: Maven release:prepare
run: mvn --batch-mode -DdryRun=${{ env.PUBLISH_TO == 'none (dry run)' }} -DdevelopmentVersion=$DEVELOPMENT_VERSION -DreleaseVersion=$RELEASE_VERSION release:prepare
shell: bash
- name: Maven release:perform
run: mvn --batch-mode -DdryRun=${{ env.PUBLISH_TO == 'none (dry run)' }} release:perform
shell: bash
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SCM section of the pom:
<scm>
<connection>scm:git:https://github.com/mycompany/myproject.git</connection>
<developerConnection>scm:git:https://github.com/mycompany/myproject.git</developerConnection>
<url>https://github.com/mycompany/myproject</url>
<tag>HEAD</tag>
</scm>
Here's the settings.xml generated by the setup-java@v3 action:
<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.MAVEN_USERNAME}</username>
<password>${env.MAVEN_PASSWORD}</password>
</server>
<server>
<id>gpg.passphrase</id>
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
</server>
</servers>
</settings>
How do I get git to work in the release:perform step?
In the end I changed the repository's visibility from private to public which resolved the issue for me.
The configuration worked as posted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With