Skip to content

Commit 3d7d66e

Browse files
committed
feat: publish to sonatype
1 parent 76ef462 commit 3d7d66e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/publish.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
CI: true
99
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1010
PGP_PASSPHRASE: ${{secrets.PGP_PASSPHRASE}}
11+
PUBLISH_TO_REGISTRY: sonatype
1112

1213
jobs:
1314
publish:
@@ -34,7 +35,16 @@ jobs:
3435
- name: Import PGP key
3536
run: echo -e "${{secrets.GPG_KEY}}" | gpg --batch --import
3637

37-
- name: Publish packages
38+
- name: Publish to GitHub Pakcages
39+
if: env.PUBLISH_TO_REGISTRY != 'sonatype'
3840
run: |
3941
sbt publishSigned
4042
43+
- name: Publish to sonatype
44+
if: env.PUBLISH_TO_REGISTRY == 'sonatype'
45+
env:
46+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
47+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
48+
run: |
49+
sbt ';publishSigned; sonatypeBundleRelease'
50+

build.sbt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ ThisBuild / homepage := Some(url("https://ovotech.github.io/natchez-extras/"))
2222

2323
ThisBuild / licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))
2424

25+
ThisBuild / sonatypeCredentialHost := Sonatype.sonatypeCentralHost
26+
ThisBuild / sonatypeRepository := Sonatype.sonatypeCentralHost
27+
2528
ThisBuild / publishTo := {
2629
sys.env.get("PUBLISH_TO_REGISTRY") match {
2730
case Some("sonatype") => sonatypePublishToBundle.value
@@ -50,7 +53,7 @@ ThisBuild / credentials ++= (
5053
(for {
5154
user <- sys.env.get("SONATYPE_USERNAME")
5255
pass <- sys.env.get("SONATYPE_PASSWORD")
53-
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, pass)).orElse {
56+
} yield Credentials("Sonatype Nexus Repository Manager", Sonatype.sonatypeCentralHost, user, pass)).orElse {
5457
val credentialsFile = Path.userHome / ".sbt" / ".sonatype_credentials"
5558
if (new File(credentialsFile.toString()).exists()) Some(Credentials(credentialsFile))
5659
else None

0 commit comments

Comments
 (0)