无法将SBT多模块项目发布到私有GitHub软件包回购中,并且本地和操作均无错误

时间:2020-02-14 08:21:11

标签: scala github sbt github-package-registry

我开始使用sbt-github-packages插件。第一步,我尝试为一个简单的虚拟项目设置它-它在本地和GitHub Actions上下文中都有效。然后,我对一个简单的虚拟多模块项目执行了相同的操作—它在本地和GitHub Actions上下文中都有效。

当我尝试为生产git repo进行相同的设置时出现了问题,该生产git repo包含具有一些通用代码的库。此仓库是私有的,属于组织。我的GitHub帐户在组织内拥有完全访问权限。

该项目具有以下结构:

lazy val common = project
  .in(file("lib/common"))
  .settings(sdk.GlobalSettingsGroup)

lazy val `sdk-a` = project
  .in(file("lib/sdk-a"))
  .settings(sdk.GlobalSettingsGroup)
  .dependsOn(common)

lazy val `sdk-b` = project
  .in(file("lib/sdk-b"))
  .settings(sdk.GlobalSettingsGroup)
  .dependsOn(common)

...

lazy val `domain-api-a` = project
  .in(file("domain/domain-api-a"))
  .settings(sdk.GlobalSettingsGroup)
  .dependsOn(`sdk-a`)

lazy val `domain-api-b` = project
  .in(file("domain/domain-api-b"))
  .settings(sdk.GlobalSettingsGroup)
  .dependsOn(`sdk-a`, `sdk-b`)

lazy val domainApis: Seq[ProjectReference] = Seq(
  `domain-api-a`,
  `domain-api-b`,
  ...
)

lazy val libs: Seq[ProjectReference] = Seq(
  `common`,
  `sdk-a`,
  `sdk-b`,
  ...
)

lazy val all = domainApis ++ libs

lazy val root = project
  .in(file("."))
  .aggregate(all: _*)
  .settings(
    name := "foundation-backend"
  )
  .settings(sdk.GlobalSettingsGroup)

通常有19个子模块。

这里是GlobalSettingsGroup

val GlobalSettingsGroup: Seq[Setting[_]] = Seq(
      githubOwner := "private_org_name",
      githubRepository := "foundation-backend",
      credentials +=
        Credentials(
          "GitHub Package Registry",
          "maven.pkg.github.com",
          sys.env.get("GITHUB_ACTOR").getOrElse("N/A"),
          sys.env.getOrElse("GITHUB_TOKEN", "N/A")
        ),
  //scala version, organization, version etc are also here
)

我将两个env变量都添加到了.bash_profile

export GITHUB_TOKEN=my_secret_token_for_github
export GITHUB_ACTOR="Fruzenshtein"

在本地运行sbt publish时,我看到所有软件包如何显示在基础后端存储库的软件包页面上。但是SBT命令以以下错误结束:

[error] javax.net.ssl.SSLProtocolException: Broken pipe (Write failed)
[error]         at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
[error]         at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
[error]         at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
[error]         at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
[error]         at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:988)
[error]         at okio.Okio$1.write(Okio.java:78)
[error]         at okio.AsyncTimeout$1.write(AsyncTimeout.java:179)
[error]         at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
[error]         at okio.RealBufferedSink.write(RealBufferedSink.java:41)
[error]         at okhttp3.internal.http1.Http1Codec$FixedLengthSink.write(Http1Codec.java:286)
[error]         at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
[error]         at okio.RealBufferedSink.writeAll(RealBufferedSink.java:99)
[error]         at okhttp3.RequestBody$3.writeTo(RequestBody.java:118)
[error]         at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:62)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error]         at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error]         at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error]         at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error]         at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error]         at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error]         at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)

当我尝试使用以下步骤在GitHub Actions上下文中调整相同的构建时:

name: Scala CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Package JAR
        run: sbt publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_ACTOR: ${{ github.actor }}

我收到这些错误,并且没有任何软件包发布到软件包中:

[error]   sdk-a / githubActor from sdk-a / credentials ((sbtghpackages.GitHubPackagesPlugin.authenticationSettings) GitHubPackagesPlugin.scala:54)
[error] 
[error]   sdk-b / githubActor from sdk-b / credentials ((sbtghpackages.GitHubPackagesPlugin.authenticationSettings) GitHubPackagesPlugin.scala:54)
[error] 
[error]   sdk-c / githubActor from sdk-c / credentials ((sbtghpackages.GitHubPackagesPlugin.authenticationSettings) GitHubPackagesPlugin.scala:54)
[error] 
[error]   domain-api-a / githubActor from domain-api-a / credentials ((sbtghpackages.GitHubPackagesPlugin.authenticationSettings) GitHubPackagesPlugin.scala:54)
[error] 
[error]   domain-api-b / githubActor from domain-api-b / credentials ((sbtghpackages.GitHubPackagesPlugin.authenticationSettings) GitHubPackagesPlugin.scala:54)
...

我很乐意考虑任何提示,因为我已经尝试过以下方法:

githubTokenSource := TokenSource.Environment("GITHUB_TOKEN")
githubActor := sys.env.get("GITHUB_ACTOR").getOrElse("N/A")

代替Credentials

的直接杠杆作用

0 个答案:

没有答案