Skip to content

Commit

Permalink
add ci publish sonatype (#14)
Browse files Browse the repository at this point in the history
* add release-drafter

* added sbt-ci-release
  • Loading branch information
touchdown authored Dec 27, 2023
1 parent 1aac53e commit 79d526c
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 12 deletions.
50 changes: 50 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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'
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
30 changes: 30 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 25 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
)
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 79d526c

Please sign in to comment.