我曾多次尝试将工件从.github/workflows部署到https://maven.pkg.github.com,但都导致了401未经授权的错误。
- name: Setup java for mvn deploy
uses: actions/setup-java@v1
with:
java-version: 8
- name: Deploy kaldi-linux.zip
working-directory: kaldi
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cp ../.github/kaldi/* .
perl -pi -e 's/^(\s{4}<version>).*(<\/version>)/${1}$ENV{"KALDI_VERSION"}${2}/g' pom.xml
mvn deploy[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy)
on project kaldi: Failed to deploy artifacts: Could not transfer artifact org.kaldi:kaldi:pom:da93074
from/to temp (https://maven.pkg.github.com/nalbion/vosk-api): Transfer failed for
https://maven.pkg.github.com/nalbion/vosk-api/org/kaldi/kaldi/da93074/kaldi-da93074.pom 401 Unauthorized -> [Help 1]日志地址:https://github.com/nalbion/vosk-api/runs/683615393?check_suite_focus=true
我的理解是,actions/setup-java应该提供settings.xml和环境变量,并且部署应该是直接的。是不是有什么我没做的事需要做?
发布于 2020-05-19 02:41:23
我可以通过第一手经验告诉你,将包部署到github的maven repos并非易事。忘记“包”部分中显示的“简单”步骤,这个过程比这复杂得多。然而,仍然有可能做到这一点。
对于初学者,您需要一个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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>Bearer <GITHUB_TOKEN_GOES HERE></value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>我猜java操作会覆盖settings.xml,但上面的操作是必需的。另一种选择是使用用户名/密码方法,但这种方法很快就会过时,转而使用持有者令牌,就像我上面所做的那样。
现在,要部署一个带源代码的快照版本,我必须使用以下命令:
mvn clean source:jar deploy -DuniqueVersion=false -Dmaven.source.useDefaultManifestFile=true -Dmaven.source.includePom=true -Dmaven.install.skip=true -DdeplyAtEnd=true -DaltDeploymentRepository='github::default::https://maven.pkg.github.com/OWNER/REPOSITORY'根据publishing guide,假设您的pom.xml中包含以下内容
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>您可以将该命令更改为:
mvn clean source:jar deploy -DuniqueVersion=false -Dmaven.source.useDefaultManifestFile=true -DdeplyAtEnd=true -Dmaven.source.includePom=true -Dmaven.install.skip=truehttps://stackoverflow.com/questions/61864370
复制相似问题