ohze / sbt-devops   6.10.0

GitHub

Sân Đình devops automator for scala projects

Scala versions: 2.13 2.12
sbt plugins: 1.0

sbt-devops

CI

devops automator for scala/sbt projects

This is a sbt AutoPlugin that do 4 things:

1. devopsSetup task:

  • Setup scalafmt
  • Setup Github Action CI to
    • test
    • QA (Quality Assurance) check by running sbt test devopsQA
    • Auto release when you push code to github
      • Release to maven central (sonatype oss) if your project is open source
      • Release to your private nexus repository if your project is private
      • Release to releases maven if you push a git tag with special prefix
      • Release to snapshots maven otherwise
    • notify to mattermost when the CI jobs completed
  • Setup other things such as adding a badge to README.md,..

2. devopsQA task validate that

  • You have setup CI, scalafmt
  • Your code is formatted
  • You don't define version manually
  • You don't break binary compatibility with the previous stable version
  • ... see source code for more detail

3. devopsNotify task

  • Notify your Mattermost or Slack webhook when CI jobs done
  • The message also contains jobs info such as status, published version, link to job, optional mentions like @channel, @here, @some_user

4. Auto add some sbt settings such as

  • version: Auto get from git
  • resolvers += your private repository (unless using sbt-devops-oss)
  • publishMavenStyle := true
  • scmInfo, homepage, publishTo, publishMavenStyle, credentials,.. See source code for more detail.
  • Of course, you can override those settings in your project

Install

Add to project/plugins.sbt

  • For private projects that will be published to repo.bennuoc.com
addSbtPlugin("com.sandinh" % "sbt-devops" % "<version>")
  • For oss projects that will be published to sonatype oss
addSbtPlugin("com.sandinh" % "sbt-devops-oss" % "<version>")

See releases for available <version>s. Release with tag vM.N.P => version M.N.P, ex v3.0.0 => version 3.0.0

Usage

  1. install (see above) -> run sbt devopsSetup
  2. (optional) remove some sbt settings that have been defined by sbt-devops such as publishTo,.. see above.
  3. run sbt +devopsQA
  4. If you use private maven hosting with sbt-devops then add this to build.sbt:
    Global / devopsNexusHost := "<your repo, ex repo.example.com>"
  5. To auto release, you need manually setup secrets in your github repo setting:
    Your github repo -> Settings -> Secrets -> New repository secret
  • sbt-devops (private maven repository)
    • NEXUS_USER, NEXUS_PASS: Your username/ password in devopsNexusHost
  • sbt-devops-oss
    • SONATYPE_USERNAME, SONATYPE_PASSWORD: Your username/ password in sonatype oss
    • PGP_SECRET, PGP_PASSPHRASE: See sbt-ci-release's guide
  1. secrets need to notify mattermost/ slack:
  • MATTERMOST_WEBHOOK_URL See files/sbt-devops.yml for details and how to customize message, icon, channel,..
  1. (optional) customize .scalafmt.conf, .github/workflows/sbt-devops.yml
  2. Commit changes, push -> auto publish -> notify.
  • Tag to release: Push tag -> publish release version.
    The tag format must be <dynverTagPrefix><MajorNumber><remains>
    dynverTagPrefix default = v
    Tag example: v1.2.3-blabla to release version 1.2.3-blabla
  • Push commit has no matched tag -> publish ..-SNAPSHOT version
  1. Enjoy

Thanks

This project use:

Licence

This software is licensed under the Apache 2 license

Copyright 2021 Sân Đình (https://sandinh.com)

CHANGES

see CHANGELOG.md

For Sân Đình's projects only (private or oss)

Use sd-devops / sd-devops-oss instead of devops / devops-oss It add some predefined settings for sandinh such as:

  • organization := "com.sandinh"
  • scalacOptions
  • repo.bennuoc.com
  • ... see sbtsd code for more details.

Contributing

To manually test devops-notify

sbt devops-notify/docker
docker run --rm -it \
  -eMATTERMOST_WEBHOOK_URL=https://chat.ohze.net/hooks/i9t3q869mp8gbecjbak4x9bndh \
  -eMATTERMOST_PRETEXT="hehe" \
  -e_DEVOPS_NEEDS='{"j1":{"result":"success","outputs":{"info":"info1","commitMsg":"commitMsg"}}}' \
  -eGITHUB_RUN_ID="123" \
  -eGITHUB_SERVER_URL=https://github.com \
  -eGITHUB_REPOSITORY=ohze/sd-devops \
  -eGITHUB_EVENT_NAME=push \
  -eGITHUB_SHA=sha111 \
ohze/devops-notify:edge