aboutsummaryrefslogtreecommitdiff
path: root/src/sbt-test/sbt-gpg/simple/build.sbt
blob: 124217c9280a6832f7fd5586fb4c93c834cf9216 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sbt.librarymanagement.Artifact
import sys.process._

lazy val root = project
  .in(file("."))
  .settings(
    credentials += {
      "gpg --import snakeoil.asc".!!
      Credentials(
        "GnuPG Key ID",
        "gpg",
        "AF19 CAC5 0D55 E6AE E0D1  F28E F05C 07EE CC58 F7C3",
        "ignored"
      )
    }
  )
  .settings(
    TaskKey[Unit]("check") := {
      val artifacts: Map[Artifact, java.io.File] =
        packagedArtifacts.value

      // check that every artifact is signed and that the actual signature file
      // exists
      artifacts.foreach{ case (art, file) =>
        if (art.extension.endsWith(".asc")) {
          file.exists || sys.error(s"Signature file $file does not exist")
        } else {
          artifacts.contains(art.withExtension(art.extension + ".asc")) ||
            sys.error(s"Found unsigned artifact: $art ($file)")
        }
      }
      ()
    }
  )