This is a sbt AutoPlugin that do 4 things:
- 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
releasesmaven if you push a git tag with special prefix - Release to
snapshotsmaven otherwise
- notify to mattermost when the CI jobs completed
- Setup other things such as adding a badge to README.md,..
- 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
- 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
version: Auto get from gitresolvers += your private repository(unless usingsbt-devops-oss)publishMavenStyle := truescmInfo,homepage,publishTo,publishMavenStyle,credentials,.. See source code for more detail.- Of course, you can override those settings in your project
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
- install (see above) -> run
sbt devopsSetup - (optional) remove some sbt settings that have been defined by sbt-devops such as
publishTo,.. see above. - run
sbt +devopsQA - If you use private maven hosting with
sbt-devopsthen add this tobuild.sbt:
Global / devopsNexusHost := "<your repo, ex repo.example.com>" - 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 indevopsNexusHost
- sbt-devops-oss
SONATYPE_USERNAME, SONATYPE_PASSWORD: Your username/ password in sonatype ossPGP_SECRET, PGP_PASSPHRASE: See sbt-ci-release's guide
- secrets need to notify mattermost/ slack:
MATTERMOST_WEBHOOK_URLSee files/sbt-devops.yml for details and how to customize message, icon, channel,..
- (optional) customize
.scalafmt.conf, .github/workflows/sbt-devops.yml - Commit changes, push -> auto publish -> notify.
- Tag to release: Push tag -> publish release version.
The tag format must be<dynverTagPrefix><MajorNumber><remains>
dynverTagPrefixdefault =v
Tag example:v1.2.3-blablato release version1.2.3-blabla - Push commit has no matched tag -> publish
..-SNAPSHOTversion
- Enjoy
This project use:
- Depends on sbt plugins: sbt-scalafmt, sbt-dynver, sbt-git, sbt-sonatype, sbt-pgp
- Copy some code from sbt-ci-release plugins.
- sbt-version-policy and MiMa
- Use lihaoyi's ujson
- of course scala, sbt and the transitive dependencies. Thanks you all!
This software is licensed under the Apache 2 license
Copyright 2021 Sân Đình (https://sandinh.com)
see CHANGELOG.md
Use sd-devops / sd-devops-oss instead of devops / devops-oss
It add some predefined settings for sandinh such as:
organization := "com.sandinh"scalacOptionsrepo.bennuoc.com- ... see sbtsd code for more details.
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