如何使用命令行将 Maven 工件上传到 Github 包?

arc*_*r64 7 java maven github-package-registry

我正在尝试将我尚未构建的 Maven 工件上传到我组织的 GitHub 包注册表。为此,我正在使用 deploy:deploy-file Maven 插件。这是我一直在使用的命令:

mvn deploy:deploy-file 
-Dfile=[THE JAR FILE]
-Durl=https://maven.pkg.github.com/[ORG] 
-Dregistry=https://maven.pkg.github.com/[ORG] 
-DgroupId=[GID]
-DartifactId=[ARTIFACTID] 
-Dversion=[VERSION]
-DgeneratePom=false 
-Dtoken=[MY GITHUB TOKEN]
Run Code Online (Sandbox Code Playgroud)

结果我收到了来自 Github 的 401 错误。我已经确定:

  • 我在我的组织(目前是所有者)中有足够的权限。
  • 我使用的令牌是有效的并且具有适当的范围:我将所有这些令牌都进行了测试。

此外,github 包页面指出:

<!-- Just a single step: Deploy using a GitHub token -->
$ mvn deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken=GH_TOKEN
Run Code Online (Sandbox Code Playgroud)

为什么我在 Maven 文档中找不到有关注册表或令牌参数的任何信息?我可以在没有任何类型的 XML 配置文件的情况下仅使用 cli 将此文件上传到组织的注册表吗?

提前致谢。

sti*_*nte 0

URL 还应该有一个存储库名称。

在我的一个项目中,我在 pom.xml 中有这个

<distributionManagement>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/stirante/lol-client-java-api</url>
    </repository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)