我正在嘗試將多模塊專案部署到 GitHub 包,但每當 Maven 進入“部署”周期時,它就會失敗。
我的 GitHub 動作作業:
release:
name: Release ??
# needs: test
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
repository-projects: write
packages: write
steps:
- uses: actions/checkout@v3
with:
ref: master
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt
cache: maven
- name: Release package
run: |
git config user.name "githubaction[bot]"
git config user.email "[email protected]"
mvn -B release:prepare
mvn -B release:perform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
我的 pom 檔案具有所需的配置:
<distributionManagement>
<!-- Github distribution -->
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/MYUSERNAME/${project.artifactId}</url>
</repository>
</distributionManagement>
<scm>
<developerConnection>scm:git:https://github.com/MYUSERNAME/${project.artifactId}</developerConnection>
</scm>
準備步驟進行得很順利,但是一旦 Maven 嘗試執行發布(并因此進入部署階段),我就會收到錯誤訊息:
[錯誤] 無法在專案 my-artifact-sub-module 上執行目標 org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy):部署工件失敗:找不到工件github 中的 my-artifact-sub-module:jar:1.1.0 (https://maven.pkg.github.com/mathiasbosman/fs-core) -> [幫助 1]
在 Maven 日志失敗之前,這很奇怪:
[資訊] 上傳到github:https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.jar [資訊] 上傳到github:https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.pom
結構將是:
我的神器 (pom) - 我的工件子模塊 (jar) - 我的工件子模塊二 (jar)
我嘗試在單獨的步驟中手動呼叫 mvn deploy 但它給了我相同的結果。
uj5u.com熱心網友回復:
scm url 顯然是錯誤的(缺少 .git 擴展名) 就這么簡單。
完整的 scm:
<scm>
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/MYUSERNAME/${project.artifactId}.git</url>
<tag>HEAD</tag>
</scm>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/537005.html
標籤:行家github-动作
