0

How do I create a GitHub workflow that publishes a Maven artifact to GitHub Packages? I'm a bit lost, since I'm using the workflow file provided by GitHub, and Googling the issue doesn't come up with any fixes that apply to my situation.

This what I've gotten so far:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

[...]

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub Milan Dierick Maven Apache Packages</name>
            <url>https://maven.pkg.github.com/MilanDierick/SongsOfSyx</url>
        </repository>
    </distributionManagement>

[...]

</project>
name: Maven Package

on:
  workflow_dispatch:
  push:
    branches: 
    - main

jobs:
  build:

    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 8
      uses: actions/setup-java@v3
      with:
        java-version: '8'
        distribution: 'corretto'
        cache: maven
        server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
        settings-path: ${{ github.workspace }} # location for the settings.xml file

    - name: Build with Maven
      run: mvn package

    - name: Publish to GitHub Packages Apache Maven
      run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
      env:
        GITHUB_TOKEN: ${{ github.token }}

This is the exception I'm getting when running this workflow:

Error:  Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project UnofficalSongsOfSyx: Failed to deploy artifacts: Could not transfer artifact github.gsos:UnofficalSongsOfSyx:jar:0.63.45 from/to github (https://maven.pkg.github.com/MilanDierick/SongsOfSyx): transfer failed for https://maven.pkg.github.com/MilanDierick/SongsOfSyx/github/gsos/UnofficalSongsOfSyx/0.63.45/UnofficalSongsOfSyx-0.63.45.jar, status: 422 Unprocessable Entity -> [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
Error: Process completed with exit code 1.

1 Answers1

0

Apparently the artifact ID needs to be all lowercase. Derp.