diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..f76c86c8 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,58 @@ +# Automatically generate Release Notes. +# ~~~~~~~~~~~~~ +changelog: + exclude: + labels: + - "Type: Ignore" + - "type:ignore" + + categories: + - title: "Breaking Changes 🚨" + labels: + - "Type: Breaking Change" + - "type:breaking-change" + + - title: "Amazing New Features ✨" + labels: + - "Type: Feature" + - "type:feature" + + - title: "Feature Improvements 👨‍💻" + labels: + - "Type: Enhancement" + - "type:enhancement" + + - title: "Hotfixes 🔥" + labels: + - "Type: Hotfix" + - "type:hotfix" + + - title: "Fixing Bugs 🐛" + labels: + - "Type: Bug" + - "type:bug" + + - title: "Maintain Project 🤝" + labels: + - "Type: Maintainance" + - "type:maintainance" + - "Type: Docs" + - "type:docs" + - "Type: Doc" + - "type:doc" + + - title: "Dependencies Changes ⬆️⬇️" + labels: + - "Type: Dependency" + - "type:dependency" + + - title: "Improve Security 🚔" + labels: + - "Type: Security" + - "type:security" + - "security fix" + - "security vulnerability" + + - title: "Other Changes 🛠" + labels: + - "*" diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml new file mode 100644 index 00000000..378ad5d3 --- /dev/null +++ b/.github/workflows/continuous_delivery.yml @@ -0,0 +1,28 @@ +# publish to Maven when a new release is made +# ~~ +name: CD +on: + release: + types: [ created ] + +jobs: + publish: + name: Publish to Maven + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: '11' + cache: 'sbt' + + - name: Publish package + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/build.sbt b/build.sbt index 8aaca69c..a8cd5648 100755 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,7 @@ import sbt.Keys.test +enablePlugins(Common) + // Supported versions val scala212 = "2.12.15" val scala213 = "2.13.10" @@ -7,7 +9,8 @@ val scala3 = "3.2.2" ThisBuild / organization := "io.cequence" ThisBuild / scalaVersion := scala212 -ThisBuild / version := "0.3.3" +//handled by cbt-ci-release +//ThisBuild / version := "0.3.3" ThisBuild / isSnapshot := false lazy val core = (project in file("openai-core")) @@ -44,4 +47,33 @@ ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org" ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local" -ThisBuild / publishTo := sonatypePublishToBundle.value \ No newline at end of file +ThisBuild / publishTo := sonatypePublishToBundle.value + +addCommandAlias( + "validateCode", + List( + "scalafix", + "scalafmtSbtCheck", + "scalafmtCheckAll", + "test:scalafix", + "test:scalafmtCheckAll" + ).mkString(";") +) + +addCommandAlias( + "formatCode", + List( + "scalafmt", + "scalafmtSbt", + "Test/scalafmt" + ).mkString(";") +) + +addCommandAlias( + "testWithCoverage", + List( + "coverage", + "test", + "coverageReport" + ).mkString(";") +) diff --git a/project/Common.scala b/project/Common.scala new file mode 100644 index 00000000..92f200b7 --- /dev/null +++ b/project/Common.scala @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Felipe Bonezi + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import sbt.Keys._ +import sbt._ +import sbt.plugins.JvmPlugin + +object Common extends AutoPlugin { + + override def trigger: PluginTrigger = allRequirements + + override def requires: Plugins = JvmPlugin + + val gitAccount = "cequence-io" + val repoName = "openai-scala-client" + + override def globalSettings: Seq[Setting[_]] = + Seq( + // project + description := "Scala client for OpenAI API", + // organization + organization := "cequence.io", + organizationName := "Cequence", + organizationHomepage := Some( + url(s"https://github.com/$gitAccount/$repoName") + ), + // legal + licenses := Seq( + "MIT" -> + url(s"https://github.com/$gitAccount/$repoName/blob/main/LICENSE") + ), + // on the web + homepage := Some(url(s"https://github.com/$gitAccount/$repoName")), + developers += Developer( + "contributors", + "Contributors", + s"https://github.com/$gitAccount/$repoName/graphs/contributors", + url(s"https://github.com/$gitAccount") + ) + ) + +} diff --git a/project/plugins.sbt b/project/plugins.sbt index d5445b43..a703ea71 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,7 @@ logLevel := Level.Warn addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.15") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") \ No newline at end of file +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +// This is an sbt plugin to help automate releases to Sonatype and Maven Central from GitHub Actions. +// See more: https://github.com/sbt/sbt-ci-release +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")