diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..a77179a --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,50 @@ +name-template: 'v$RESOLVED_VERSION 🌈' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '⚠️ Backward Incompatible' + label: 'break' + - title: '🚀 Features' + label: 'enhancement' + - title: '🐛 Bug Fixes' + label: 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'break' + minor: + labels: + - 'enhancement' + patch: + labels: + - 'bug' + - 'chore' + default: patch +template: | + ## Changes + + $CHANGES +autolabeler: + - label: 'break' + branch: + - '/break\/.+/' + title: + - '/break/i' + - label: 'chore' + branch: + - '/chore\/.+/' + title: + - '/chore/i' + - label: 'bug' + branch: + - '/fix\/.+/' + title: + - '/fix/i' + - label: 'enhancement' + branch: + - '/feature\/.+/' + title: + - '/feature/i' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2084e6..c102089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,8 @@ jobs: scala: [2.13.12] java: [temurin@17] runs-on: ${{ matrix.os }} + timeout-minutes: 20 + steps: - name: Checkout current branch (full) uses: actions/checkout@v4 @@ -45,3 +47,56 @@ jobs: - name: Build project run: sbt '++ ${{ matrix.scala }}' test + + - name: Compress target directories + run: tar cf targets.tar target codegen/target sbt-plugin/target runtime/target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v4 + with: + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.12] + java: [temurin@17] + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: sbt + + - name: Download target directories (2.13.12) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-2.13.12-${{ matrix.java }} + + - name: Inflate target directories (2.13.12) + run: | + tar xf targets.tar + rm targets.tar + + - name: Publish project + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + run: sbt ci-release diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..6186684 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,30 @@ +name: Release Drafter + +on: + push: + branches: + - main + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + +permissions: + contents: read + +# can maybe run locally via https://github.com/nektos/act +# act -s DOCKER_USERNAME=abc -s DOCKER_PASSWORD=xyz --container-architecture linux/arm64 -W .github/workflows/ci.yml pull_request +jobs: + update_release_draft: + timeout-minutes: 5 + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.sbt b/build.sbt index 740a106..b5775ad 100644 --- a/build.sbt +++ b/build.sbt @@ -1,28 +1,41 @@ import sbt.Keys.scalaVersion import sbt.addSbtPlugin -ThisBuild / organization := "io.github.touchdown" +import scala.concurrent.duration._ +ThisBuild / organization := "io.github.touchdown" +ThisBuild / scalaVersion := Dependencies.Versions.scala213 +// versioning ThisBuild / dynverVTagPrefix := true ThisBuild / dynverSeparator := "-" -// append -SNAPSHOT to version when isSnapshot -ThisBuild / dynverSonatypeSnapshots := true +ThisBuild / dynverSonatypeSnapshots := true // append -SNAPSHOT to version when isSnapshot ThisBuild / versionScheme := Some("early-semver") - +// publish settings ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org" -ThisBuild / publishTo := sonatypePublishToBundle.value - +sonatypeRepository := "https://s01.oss.sonatype.org/service/local" // enable scalafix ThisBuild / semanticdbEnabled := true ThisBuild / semanticdbVersion := scalafixSemanticdb.revision - ThisBuild / scalacOptions ++= Seq("-Ywarn-unused") - +// github action settings ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")) -ThisBuild / crossScalaVersions := Dependencies.Versions.CrossScalaForLib +ThisBuild / githubWorkflowScalaVersions := Dependencies.Versions.CrossScalaForLib ThisBuild / githubWorkflowTargetTags ++= Seq("v*") - -ThisBuild / githubWorkflowPublishTargetBranches := Seq() +ThisBuild / githubWorkflowBuildTimeout := Some(20.minutes) +ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))) +ThisBuild / githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + commands = List("ci-release"), + name = Some("Publish project"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}" + ) + ) +) +ThisBuild / githubWorkflowPublishTimeout := Some(10.minutes) val gyremockRuntimeName = "gyremock-runtime" val akkaGrpcVersion = "2.1.6" @@ -70,5 +83,5 @@ lazy val root = Project(id = "gyremock", base = file(".")) // version (and set the crossScalaVersions as empty list) so each sub-project // can then decide which scalaVersion and crossCalaVersions they use. crossScalaVersions := Nil, - scalaVersion := Dependencies.Versions.scala212 + scalaVersion := Dependencies.Versions.scala213 ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4024789..06a9ab2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,5 @@ addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")