README.md

April 19, 2026 ยท View on GitHub

๐Ÿ“š Scala Library Template

A reusable template for Scala libraries deployed to Maven Central.



"Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away." โ€” Antoine de Saint-Exupรฉry.


๐Ÿ“‹ What's included?

  1. Everything from Scala Library Config, including reasonable Scalafmt settings, CI piplines for build integrity, and some IDE config.
  2. Automatic deployment to Maven Central using sbt-ci-release.
  3. Example build configuration and setup instructions.

๐Ÿ”จ How to use this template

1. Create your repository

Click 'Use this template' on GitHub, and follow the instructions to create a new repository for your library. All files herein will be copied as-is.

2. Configure build.sbt and release.sbt

Replace every placeholder with real values for your project. The sbt settings necessary for publishing are defined by sbt-ci-release and are documented here.

Settings to update in release.sbt:

NamePurposeExample
organizationYour organisation's package namespace.org.nohungrydogs
organizationNameYour organisation's name.No Hungry Dogs
organizationHomepageYour organisation's website.nohungrydogs.org
versionSchemeWhat does the version number say about binary compatibility?strict
licensesThe license under which your library is released. Update LICENSE.md to match.MIT
developersThe individual developers who contribute to your library.SgtSwagrid

Settings to update in build.sbt:

NamePurposeExample
packagePrefixIntelliJ's implicit package prefix for all code files.org.nohungrydogs
Name of subproject (following lazy val)Your library's name, or the name of a particular module.dog-food-finder

Multiple modules

Each subproject listed in build.sbt is published as a separate artefact on Maven (albeit under the same versioning), which is useful if you want a modular design whereby downstream users need not include all facets of your library. Typically in this case you'll introduce one top-level subdirectory for each subproject.

A note on sbt settings

Settings are read from every .sbt file in the project root. It doesn't matter what they are called, other than that sbt simply concatenates their contents in alphabetical order of their names. A division between build information and publishing information is introduced for convenience.

3. Set up your Maven Central account

  1. Create an account on Maven Central to enable publishing, if you don't already have one.
  2. Register your namespace (e.g. org.nohungrydogs). This should match the organization setting in release.sbt.
  3. Generate a user token. This will give you a username and password, which you can add as repository secrets (see step 5).

4. Generate a PGP key for signing releases

Execute the following on your local machine to generate a PGP key:

# Generate a new PGP key, making sure to remember your passphrase:
gpg --gen-key

# Expose the secret key in base64, using the public key provided by the above:
gpg --armor --export-secret-keys <PUBLIC_KEY> | base64

# Upload the public key to a keyserver:
gpg --keyserver keyserver.ubuntu.com --send-keys <PUBLIC_KEY>

5. Add repository secrets

Add the following secrets to your repository on GitHub, to allow publishing as part of an automated workflow:

SecretValue
SONATYPE_USERNAMEUsername from Maven user token in step 3.
SONATYPE_PASSWORDPassword from Maven user token in step 3.
PGP_SECRETBase64-encoded PGP private key from step 4.
PGP_PASSPHRASEPassphrase used when generating the PGP key in step 4.
GH_TOKENYour GitHub PAT with administrator to access your repository.
CLAUDE_CODE_OAUTH_TOKENAPI key from Claude for agentic workflows (optional).

Secrets can be added from the GitHub web interface by nagivating as follows from your repository's page:

Settings โ†’ Secrets and variables โ†’ Actions

6. Publish the Scaladoc documentation with Github Pages

This project is configured to automatically extract and publish all Scaladoc content as a stand-alone website using GitHub Pages.

All you need to do is configure GitHub to deploy the site from the branch named gh-pages, which will be automatically created following the first release. You can find this setting under:

Settings โ†’ Pages

๐Ÿ‘ฎโ€โ™‚๏ธ License

The included MIT license should be considered only as part of the template, and is not binding. This repository is hereby released to the public domain, to be used freely. In particular, and contra LICENSE.md, you may remove the license text from copies.

๐Ÿค Contributing

CONTRIBUTING.md is also part of the template, and does not necessarily apply to contributions to the template itself. The most important thing to know is that many of the configuration files are automatically synced from Scala Config, and should be updated there rather than here.

๐Ÿ‘๏ธ See also





โฌ†๏ธ Delete โ€ข Keep โฌ‡๏ธ





โœจ My Library

A very cool Scala library that does something great.

Build status Maven Central Documentation

โฌ‡๏ธ Installation

Add the following dependency to your build.sbt:

libraryDependencies += "com.alecdorrington" %% "scala-library-template" % "0.2.1"

๐Ÿ‘๏ธ See also