From b41e3eb64f01e5b36773c86c38fe105e0b6857e6 Mon Sep 17 00:00:00 2001 From: abalias Date: Fri, 11 Nov 2022 16:32:37 +0000 Subject: [PATCH] build(prism-agent): automate release process (#109) * build(prism-agent): automate release process * build(prism-agent): use ghcr.io and simplify build script --- prism-agent/service/CHANGELOG.md | 0 prism-agent/service/build.sbt | 36 +++++++++--- prism-agent/service/package.json | 55 +++++++++++++++++++ .../service/project/Dependencies.scala | 4 +- prism-agent/service/project/build.sbt | 1 + 5 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 prism-agent/service/CHANGELOG.md create mode 100644 prism-agent/service/package.json diff --git a/prism-agent/service/CHANGELOG.md b/prism-agent/service/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/prism-agent/service/build.sbt b/prism-agent/service/build.sbt index 67a7fd2f7f..f618101360 100644 --- a/prism-agent/service/build.sbt +++ b/prism-agent/service/build.sbt @@ -1,19 +1,28 @@ import Dependencies._ import sbtghpackages.GitHubPackagesPlugin.autoImport._ - -ThisBuild / version := "0.1.0-SNAPSHOT" -ThisBuild / scalaVersion := "3.2.0" -ThisBuild / organization := "io.iohk.atala" +import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ // Custom keys val apiBaseDirectory = settingKey[File]("The base directory for PrismAgent API specifications") -ThisBuild / apiBaseDirectory := baseDirectory.value / "../api" -ThisBuild / resolvers += Resolver.githubPackages("input-output-hk", "atala-prism-building-blocks") + +inThisBuild( + Seq( + organization := "io.iohk.atala", + scalaVersion := "3.2.0", + apiBaseDirectory := baseDirectory.value / "../api", + fork := true, + run / connectInput := true, + versionScheme := Some("semver-spec"), + githubOwner := "input-output-hk", + githubRepository := "atala-prism-building-blocks", + githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN") + ) +) val commonSettings = Seq( testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")), githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN"), - resolvers += Resolver.githubPackages("input-output-hk", "atala-prism-sdk"), + resolvers += Resolver.githubPackages("input-output-hk"), // Needed for Kotlin coroutines that support new memory management mode resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven" ) @@ -48,10 +57,19 @@ lazy val server = project .map(model => (model, s"io.iohk.atala.agent.server.http.model.OASModelPatches.$model")) .toMap, Docker / maintainer := "atala-coredid@iohk.io", - Docker / dockerRepository := Some("atala-prism.io"), - // Docker / packageName := s"atala-prism/${packageName.value}", + Docker / dockerRepository := Some("ghcr.io"), dockerExposedPorts := Seq(8080), dockerBaseImage := "openjdk:11" ) .enablePlugins(OpenApiGeneratorPlugin, JavaAppPackaging, DockerPlugin) .dependsOn(`wallet-api`) + +releaseProcess := Seq[ReleaseStep]( + checkSnapshotDependencies, + inquireVersions, + runClean, + runTest, + setReleaseVersion, + ReleaseStep(releaseStepTask(server / Docker / publish)), + setNextVersion +) diff --git a/prism-agent/service/package.json b/prism-agent/service/package.json new file mode 100644 index 0000000000..34dd548af6 --- /dev/null +++ b/prism-agent/service/package.json @@ -0,0 +1,55 @@ +{ + "name": "prism-agent", + "devDependencies": { + "@commitlint/cli": "^17.0.3", + "@commitlint/config-conventional": "^17.0.3", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/exec": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "conventional-changelog-conventionalcommits": "^5.0.0", + "gradle-semantic-release-plugin": "1.7.3", + "husky": "^8.0.1", + "pinst": "^3.0.0", + "prettier": "^2.7.1", + "semantic-release": "^19.0.3", + "semantic-release-monorepo": "^7.0.5" + }, + "extends": "semantic-release-monorepo", + "release": { + "branches": [ + { + "name": "main" + }, + { + "name": "prerelease/prism-agent", + "prerelease": "snapshot" + } + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/exec", + { + "prepareCmd": "sbt \"release release-version ${nextRelease.version} next-version ${nextRelease.version}-SNAPSHOT with-defaults\"" + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "version.sbt", + "CHANGELOG.md" + ], + "message": "chore(release): cut prism-agent image ${nextRelease.version} release [skip ci]\n\n${nextRelease.notes}" + } + ] + ] + } +} diff --git a/prism-agent/service/project/Dependencies.scala b/prism-agent/service/project/Dependencies.scala index 7ae3658d5b..74ae7fe7ab 100644 --- a/prism-agent/service/project/Dependencies.scala +++ b/prism-agent/service/project/Dependencies.scala @@ -7,8 +7,8 @@ object Dependencies { val zioHttp = "2.0.0-RC11" val akka = "2.6.20" val akkaHttp = "10.2.9" - val castor = "0.1.0-SNAPSHOT" - val pollux = "0.1.0-SNAPSHOT" + val castor = "0.1.0" + val pollux = "0.1.0" val bouncyCastle = "1.70" val logback = "1.4.4" } diff --git a/prism-agent/service/project/build.sbt b/prism-agent/service/project/build.sbt index e57b04af95..73b9bc70cf 100644 --- a/prism-agent/service/project/build.sbt +++ b/prism-agent/service/project/build.sbt @@ -1,5 +1,6 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9") +addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") libraryDependencies ++= Seq("org.openapitools" % "openapi-generator" % "6.0.0")