如果有人在这里寻找OP发布到github的问题的解决方案,我也遇到了类似的问题,发现settings.xml和pom.xml中所需的URL不一致。在settings.xml中,回购URL的格式应为 https://maven.pkg.github.com/myuser/com/mycompany/mypackage ,而在项目的pom文件中,其格式应为 https://maven.pkg.github.com/myuser/mypackage 。因此,例如,〜/ .m2中的settings.xml文件如下所示:
<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">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/com/mycompany/mypackage</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>myuser</username>
<password>mypersonalaccesstoken</password>
</server>
</servers>
</settings>
项目根目录中的pom.xml文件应如下所示:
<project>
...
<groupId>org.mycompany</groupId>
<artifactId>mypackage</artifactId>
<version>1.0.0</version>
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/mypackage</url>
</repository>
</distributionManagement>
...
</project>
除了这个次要(但很关键)的细节之外,我的步骤与here中概述的步骤相同。这使我可以将Maven软件包发布到github软件包注册表中。
,
您可以在工作流程中启用debug logging
。
只需添加秘密:
ACTIONS_RUNNER_DEBUG
并设置为true
看到类似的答案here
,
以下解决方案对我有用:
- 为软件包创建存储库,例如
maven-packages
- 在
<server></server>
的{{1}}下添加<servers>
设置:(按下面使用的ID执行此操作)
settings.xml
- 不要不将
<server>
<id>github<id/>
<username>YOUR GITHUB USERNAME</username>
<password>A GITHUB TOKEN YOU CREATE FOR PUBLISHING PACKAGES</password>
</server>
,<activeProfiles>
或<profile>
添加到<repositories>
(仅添加settings.xml
元素),因为这对于发布是多余的,我将它们添加到使用项目的<server>
中,因此无需重复。
- 如下所示将存储库添加到
maven.xml
中的distributionManagement
:
pom.xml
其中 <distributionManagement>
<snapshotRepository>
<id>github-snapshot</id>
<name>GitHub snapshot</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>true</uniqueVersion>
</snapshotRepository>
<repository>
<id>github-release</id>
<name>GitHub release</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>false</uniqueVersion>
</repository>
</distributionManagement>
是您的项目所在的GitHub帐户/项目所在的项目,而OWNER
是您要将项目发布到的存储库。
这使您可以使用专用的存储库来列出软件包,而不是将每个项目的软件包发布到不同的(自己的)存储库中,从而使从GitHub帐户使用多个软件包变得更加容易,因为您只需为这些软件包配置一个存储库:
maven-packages
注意:在 <repositories>
<repository>
<id>github</id>
<name>GitHub</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
</repository>
</repositories>
的{{1}}部分,为<servers>
和settings.xml
中使用的<server>
定义一个id
。以上示例中的repositories
,distributionManagement
,github-snapshot
。
,
我只花了3个小时来调试为什么该页面上的指南对我不起作用。如果您遵循此处发布的指南1。
OWNER是您的github用户名,REPOSITORY是-您猜对了,就是存储库名称。
只记得在OWNER和REPOSITORY中都使用小写字母。
,
生成个人访问令牌时,请确保令牌的作用域是 repo:* 作用域以及更明显的 write:packages 和 read:packages 作用域(不要禁用 repo 作用域)
否则就那样
本文链接:https://www.f2er.com/2890284.html