aboutsummaryrefslogtreecommitdiff
path: root/src/sbt-test/sbt-gpg/simple/build.sbt
blob: 1f5dce9505ce33026dde185aeb177dde1e9a50b7 (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",
        "764D 70D5 5506 DB6F 0D3C  F3D3 3665 C9FC E716 EC52",
        "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)")
        }
      }
      ()
    }
  )