Skip to content

Commit

Permalink
publish to maven using sbt-ci-release
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Bonezi <[email protected]>
  • Loading branch information
felipebonezi committed Nov 22, 2022
1 parent 6d22a64 commit b4b861c
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 51 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/continouos-delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Continuous Integration (CI) to Build & Test & Coverage & Lint.
# ~~
name: CI
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 }}
57 changes: 52 additions & 5 deletions .github/workflows/continouos-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
name: CI
on:
pull_request:
branches: [ '**' ]
branches: [ main, '**' ]
push:
branches: [ '**' ]
branches: [ main ]

jobs:
validate:
Expand All @@ -28,18 +28,24 @@ jobs:
name: Build & Test
needs: [ validate ]
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
scala: [ '2.12.17', '2.13.10' ]

steps:
- uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: '11'
distribution: 'corretto'
java-version: '8'
cache: 'sbt'

- name: Build & Test
run: sbt testWithCoverage
run: sbt ++${{ matrix.scala }} testWithCoverage

- name: Upload coverage report (Cobertura)
uses: actions/[email protected]
Expand All @@ -53,6 +59,39 @@ jobs:
name: scoverage-report-html
path: ${{github.workspace}}/target/scala-2.13/scoverage-report/

optional-build:
name: Build (Optional)
continue-on-error: ${{ matrix.experimental }}
needs: [ validate ]
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
distribution: [ 'corretto' ]
jdk: [ '11' ]
scala: [ '2.12.17', '2.13.10' ]
experimental: [ false ]
include:
- jdk: '17'
distribution: 'corretto'
scala: '2.13.10'
experimental: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.jdk }}
cache: 'sbt'

- name: Perform Build / Test
run: sbt ++${{ matrix.scala }} compile test

coverage:
name: Coverage Report
if: ${{ github.event.pull_request }}
Expand All @@ -75,3 +114,11 @@ jobs:
show_class_names: true
link_missing_lines: true
minimum_coverage: 75

ready-to-merge:
name: Ready to Merge
if: ${{ github.event.pull_request }}
needs: [ optional-build, coverage ]
runs-on: ubuntu-latest
steps:
- run: echo 'Ready to merge.'
57 changes: 21 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
name := """play-hmac-signatures"""

version := "0.3"

organization := "com.mesonomics"

homepage := Some(url("https://github.com/phelps-sg/play-hmac-signatures"))

scmInfo := Some(
ScmInfo(
url("https://github.com/phelps-sg/play-hmac-signatures"),
"[email protected]:phelps-sg/play-hmac-signatures.git"
)
)
import Common._
import Dependencies.Version.scala212
import Dependencies.Version.scala213

developers := List(
Developer(
"phelps-sg",
"Steve Phelps",
"[email protected]",
url("https://github.com/usernamehttps://github.com/phelps-sg")
)
)

licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))

publishMavenStyle := true

publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)
name := """play-hmac-signatures"""

enablePlugins(Dependencies)
enablePlugins(Common, Dependencies)

inThisBuild(
List(
scalaVersion := "2.13.10",
scalaVersion := scala213,
crossScalaVersions := Seq(scala212, scala213),
scalafixScalaBinaryVersion := "2.13",
versionScheme := Some("early-semver"),
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalacOptions += "-Ywarn-unused",
scalacOptions += "-Xcheckinit"
scalacOptions += "-Xcheckinit",
sonatypePublishTo := Some({
if (isSnapshot.value)
Opts.resolver.sonatypeOssSnapshots.head
else
Opts.resolver.sonatypeStaging
}),
scmInfo := Some(
ScmInfo(
url(s"https://github.com/$gitAccount/$repoName"),
s"[email protected]:$gitAccount/$repoName.git"
)
)
)
)

Expand Down
71 changes: 71 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2022 Felipe Bonezi <https://about.me/felipebonezi>
*
* 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 = "phelps-sg"
val repoName = "play-hmac-signatures"

import Dependencies.Version._

override def globalSettings: Seq[Setting[_]] =
Seq(
// project
description := "A Play! Framework dependency to validate an HMAC signature in a HTTP request.",
// organization
organization := "com.mesonomics",
organizationName := "Mesonomics",
organizationHomepage := Some(
url(s"https://github.com/$gitAccount/$repoName")
),
// scala settings
scalaVersion := scala213,
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked",
"-encoding",
"utf8"
),
javacOptions ++= Seq("-encoding", "UTF-8"),
// legal
licenses := Seq(
"Apache-2.0" ->
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")
)
)

}
14 changes: 6 additions & 8 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
/*
* Copyright (C) 2021 Just Play LTDA.
* See the LICENCE.txt file distributed with this work for additional
* information regarding copyright ownership.
*/

import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin

object Dependencies extends AutoPlugin {

object Version {
val scala212 = "2.12.17"
val scala213 = "2.13.10"

val play = "2.8.18"
val guice = "5.1.0"
val jackson = "2.13.4"

val scalatic = "3.2.14"
val scalaMock = "5.2.0"
val scalaTest = "3.2.14"
val scalaTestPlus = "5.1.0"
val scalaMock = "5.2.0"
val jackson = "2.13.4"
}

override def trigger: PluginTrigger = allRequirements
Expand Down
8 changes: 6 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.14")

// CI Release plugin.
// ~
// 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.11")

// Test Coverage plugin.
// ~
Expand Down

0 comments on commit b4b861c

Please sign in to comment.