If cloning a repo on GitHub with HTTPS the remote URL is formatted like https://github.com/olafurpg/sbt-ci-release, which is not picked up by the automatic scmInfo detection in
|
scmInfo := { |
|
val user = """(?:[^@\/]+@)?""" |
|
val domain = """([^\/]+)""" |
|
val gitPath = """(.*)\.git\/?""" |
|
val unauthenticated = raw"""(?:git|https?|ftps?)\:\/\/$domain\/$gitPath""".r |
|
val ssh = raw"""ssh\:\/\/$user$domain\/$gitPath""".r |
|
val headlessSSH = raw"""$user$domain:$gitPath""".r |
|
|
|
def buildScmInfo(domain: String, repo: String) = Option( |
|
ScmInfo( |
|
url(s"https://$domain/$repo"), |
|
s"scm:git:https://$domain/$repo.git", |
|
Some(s"scm:git:git@$domain:$repo.git") |
|
) |
|
) |
|
|
|
gitReader.value.withGit(_.remoteOrigin) match { |
|
case unauthenticated(domain, repo) => buildScmInfo(domain,repo) |
|
case ssh(domain, repo) => buildScmInfo(domain,repo) |
|
case headlessSSH(domain, repo) => buildScmInfo(domain,repo) |
|
case _ => None |
|
} |
|
} |
A workaround is to add the following to buildSettings:
+ scmInfo ~= {
+ case Some(info) => Some(info)
+ case None =>
+ import scala.sys.process._
+ val identifier = """([^\/]+)"""
+ val GitHubHttps = s"https://github.com/$identifier/$identifier".r
+ try {
+ val remote = List("git", "ls-remote", "--get-url", "origin").!!.trim()
+ remote match {
+ case GitHubHttps(user, repo) =>
+ Some(
+ ScmInfo(
+ url(s"https://github.com/$user/$repo"),
+ s"scm:git:https://github.com/$user/$repo.git",
+ Some(s"scm:git:git@github.com:$user/$repo.git")
+ )
+ )
+ case _ =>
+ None
+ }
+ } catch {
+ case NonFatal(_) => None
+ }
+ }
This issue was discovered while publishing a Sonatype release via GitHub Actions with the following error message
[error] Failed to close the repository
[error] Activity close started:2019-09-22T22:33:25.400Z, stopped:2019-09-22T22:33:33.729Z
[error] Failed: pom-staging, failureMessage:Invalid POM: /com/geirsson/sbt-ci-release_2.12_1.0/1.4.27/sbt-ci-release-1.4.27.pom: SCM URL missing
[error] java.lang.Exception: Failed to close the repository
[error] Use 'last' for the full log.
It appears that GitHub Actions clone the repository with the HTTPS remote instead of SSH remote.
If cloning a repo on GitHub with HTTPS the remote URL is formatted like
https://github.com/olafurpg/sbt-ci-release, which is not picked up by the automaticscmInfodetection insbt-git/src/main/scala/com/typesafe/sbt/SbtGit.scala
Lines 124 to 146 in 74e03af
A workaround is to add the following to
buildSettings:This issue was discovered while publishing a Sonatype release via GitHub Actions with the following error message
It appears that GitHub Actions clone the repository with the HTTPS remote instead of SSH remote.