Skip to content

Unable to find credentials for [GitHub Package Registry @ maven.pkg.github.com] #115

@tusharmath

Description

@tusharmath

Hi, first of all thanks for making this amazing project!

I am trying to use it to publish on github packages using github actions. But facing the following error.

Error:

[info] Main Scala API documentation successful.
[error] Unable to find credentials for [GitHub Package Registry @ maven.pkg.github.com].
[info] Main Scala API documentation successful.
[error] Unable to find credentials for [GitHub Package Registry @ maven.pkg.github.com].
[error] java.io.IOException: Server returned HTTP response code: 401 for URL: https://maven.pkg.github.com/tusharmath/zio-compose/zio-compose/zio-compose_2.13/0.1.0-SNAPSHOT/zio-compose_2.13-0.1.0-SNAPSHOT.pom
[error] 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error] 	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] 	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[error] 	at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1974)
[error] 	at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)
[error] 	at java.base/java.security.AccessController.doPrivileged(Native Method)
[error] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1968)
[error] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
[error] 	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
[error] 	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:[25](https://github.com/tusharmath/zio-compose/runs/7834200470?check_suite_focus=true#step:7:26)0)
[error] 	at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:[28](https://github.com/tusharmath/zio-compose/runs/7834200470?check_suite_focus=true#step:7:29)8)
[error] 	at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error] 	at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)

Complete logs are available here.

build.sbt

import Dependencies._

Global / scalaVersion := "2.13.8"

val libVersion = "0.1.0-SNAPSHOT"

def publishSettings(projectName: String) = Seq(
  publish / skip := false,
  version        := libVersion,
  name           := projectName,
  versionScheme  := Some("early-semver"),
  publishTo      := Some("Github Package Registry" at s"https://maven.pkg.github.com/tusharmath/${projectName}"),
)

// Projects
lazy val root = (project in file("."))
  .aggregate(zioCompose, zioComposeMacros)
  .settings(
    publish / skip := true,
  )

lazy val zioCompose = project
  .in(file("./compose"))
  .settings(publishSettings("zio-compose"))
  .settings(
    fork                := true,
    libraryDependencies := Seq(
      ZIOCore,
      ZIOSchema,
      ZIOSchemaJson,
      ZIOSchemaDerivation,
      ZIOTest,
      ZIOTestSbt,
    ),
    testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
  )
  .dependsOn(zioComposeMacros)

lazy val zioComposeMacros = project
  .in(file("./compose-macros"))
  .settings(publishSettings("zio-compose-macros"))
  .settings(
    fork                := true,
    libraryDependencies := Seq(
      ZIOSchema,
      "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
    ),
  )

// Flags
Global / semanticdbEnabled    := true
Global / onChangedBuildSource := ReloadOnSourceChanges
Global / scalacOptions        := Seq(
  "-Ywarn-unused:imports",
  "-Werror",
  "-feature",
  "-language:reflectiveCalls",
)

Things that I have tried

  • Checked if the token has permissions, and it does.

Update 1
Updating the publishSettings method to the following worked

def publishSettings(projectName: String) = Seq(
  publish / skip := false,
  name           := projectName,
  versionScheme  := Some("early-semver"),
  publishTo      := Some("GitHub Package Registry" at s"https://maven.pkg.github.com/tusharmath/zio-compose"),
  credentials += Credentials("GitHub Package Registry", "maven.pkg.github.com", "tusharmath", sys.env("GITHUB_TOKEN")),
  organization   := "io.github.tusharmath",
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions