- Configure your package naming and organization (generally optional).
org ⤷ name ⤷ package
- Set up the package information in your
build.sbt
file. Complete the fields with your repository's information. The GitHub token is provided in the Actions environment so this sbt file will assume it exists upon execution.
name := "PACKAGE_NAME"
version := "1.0.0"
scalaVersion := "2.13.6"
organization := "org.name"
versionScheme := Some("semver-spec")
homepage := Some(url("https://github.com/USERNAME/PACKAGE"))
licenses := Seq("LICENSE" -> url("LICENSE_URL"))
publishMavenStyle := true
pomIncludeRepository := { _ => false }
publishTo := Some("GitHub USERNAME Apache Maven Packages" at "https://maven.pkg.github.com/USERNAME/PACKAGE")
credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"USERNAME",
System.getenv("GITHUB_TOKEN")
)
-
Test your package and make sure it's functional.
-
Upload your repository to GitHub to prepare it for publishing as a package.
-
Visit
Actions
tab of the repository and look for the Scala workflow set up.- The workflow's title should say
Scala
by GitHub Actions and havesbt test
as the default code in the workflow. - Once you find configuration, click the
Set up this workflow
button.
- The workflow's title should say
-
In the workflow editor, use the YAML code and replace the name with your Scala package's name.
name: Scala Package
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Run tests
run: sbt test
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Publish package
run: sbt test publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- You may also change the workflow run event to be prompted by created releases instead of pushes.
on:
release:
types: [created]
branches: [main]
-
Commit and push the file.
- If the workflow was configured for created releases, create a release for the action to run.
-
Visit the workflow run.
-
If the workflow passes all checks and publishing is successful, a packages tab will on the repository's homepage and you can manage its packages from there. You may add a description to the package as well.