Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tusharmath opened this issue Aug 15, 2022 · 0 comments

Comments

@tusharmath
Copy link

tusharmath commented Aug 15, 2022

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",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant