Skip to content

Commit

Permalink
Added githubSuppressPublicationWarning setting to better support reso…
Browse files Browse the repository at this point in the history
…lver use-cases
  • Loading branch information
djspiewak committed Mar 7, 2020
1 parent 8b1bb72 commit b5e4c56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ The following setting keys are defined:
- `githubRepository : String` The repository which hosts this project under the organization/user defined in the other setting
- `githubActor : String` (*defaults to `GITHUB_ACTOR`*) *Your* GitHub username. This should almost never be specified in the build itself, but rather read from some external source. By default, it will read the `GITHUB_ACTOR` environment variable. To be extremely clear, this is the user who ran the `sbt` command, it is not *necessarily* the repository owner!
- `githubTokenSource : TokenSource` (*defaults to `Environment("GITHUB_TOKEN")`*) Where the plugin should go to read the GitHub API token to use in authentication. `TokenSource` has two possible values: `Environment(variable: String)` and `GitConfig(key: String)`. You can compose multiple sources together using `||`, which will result in each being attempted in order from left to right. This is mostly just a convenience. You're free to do whatever you want. Just don't, like, put it in your build.
- `githubSuppressPublicationWarning : Boolean` (*defaults to `false`*) If you're just using this plugin as a means to *resolve* artifacts, not to publish them, the publication warning may serve as an annoyance more than anything else. Setting this to `true` will suppress the normal warning text when you fail to define `githubOwner` or `githubRepository`.

`homepage` and `scmInfo` will be automatically set for you if `githubOwner` and `githubRepository` are themselves set.
2 changes: 2 additions & 0 deletions src/main/scala/sbtghpackages/GitHubPackagesKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ trait GitHubPackagesKeys {

val githubActor = settingKey[String]("The github user to use when authenticating (defaults to github.actor in the git config)")
val githubTokenSource = settingKey[TokenSource]("Where to get the API token used in publication (defaults to github.token in the git config)")

val githubSuppressPublicationWarning = settingKey[Boolean]("Whether or not to suppress the publication warning (default: false, meaning the warning will be printed)")
}

object GitHubPackagesKeys extends GitHubPackagesKeys
5 changes: 4 additions & 1 deletion src/main/scala/sbtghpackages/GitHubPackagesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ object GitHubPackagesPlugin extends AutoPlugin {

val packagePublishSettings = Seq(
publishTo := {
val suppress = githubSuppressPublicationWarning.value
val log = streams.value.log
val ms = publishMavenStyle.value
val back = for {
Expand All @@ -73,7 +74,7 @@ object GitHubPackagesPlugin extends AutoPlugin {

back orElse {
GitHubPackagesPlugin synchronized {
if (!alreadyWarned) {
if (!alreadyWarned && !suppress) {
log.warn("undefined keys `githubOwner` and `githubRepository`")
log.warn("retaining pre-existing publication settings")
alreadyWarned = true
Expand Down Expand Up @@ -132,4 +133,6 @@ object GitHubPackagesPlugin extends AutoPlugin {
s"GitHub Package Registry (${owner}${if (repo != "_") s"/$repo" else ""})"

override def projectSettings = packagePublishSettings

override def buildSettings = Seq(githubSuppressPublicationWarning := false)
}

0 comments on commit b5e4c56

Please sign in to comment.