Skip to content

Commit 1f23b6c

Browse files
authored
Publish to Central Portal (#96)
1 parent e66dc48 commit 1f23b6c

File tree

9 files changed

+58
-48
lines changed

9 files changed

+58
-48
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,70 @@ on:
1616
env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818

19+
20+
concurrency:
21+
group: ${{ github.workflow }} @ ${{ github.ref }}
22+
cancel-in-progress: true
23+
1924
jobs:
2025
build:
21-
name: Build and Test
26+
name: Test
2227
strategy:
2328
matrix:
24-
os: [ubuntu-latest]
29+
os: [ubuntu-22.04]
2530
scala: [2.12.15, 2.11.12, 2.13.8, 3.0.2]
2631
java: [temurin@8, temurin@11, temurin@17]
2732
runs-on: ${{ matrix.os }}
33+
timeout-minutes: 60
2834
steps:
2935
- name: Checkout current branch (full)
30-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3137
with:
3238
fetch-depth: 0
3339

40+
- name: Setup sbt
41+
uses: sbt/setup-sbt@v1
42+
3443
- name: Setup Java (temurin@8)
44+
id: setup-java-temurin-8
3545
if: matrix.java == 'temurin@8'
36-
uses: actions/setup-java@v2
46+
uses: actions/setup-java@v4
3747
with:
3848
distribution: temurin
3949
java-version: 8
50+
cache: sbt
51+
52+
- name: sbt update
53+
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
54+
run: sbt +update
4055

4156
- name: Setup Java (temurin@11)
57+
id: setup-java-temurin-11
4258
if: matrix.java == 'temurin@11'
43-
uses: actions/setup-java@v2
59+
uses: actions/setup-java@v4
4460
with:
4561
distribution: temurin
4662
java-version: 11
63+
cache: sbt
64+
65+
- name: sbt update
66+
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
67+
run: sbt +update
4768

4869
- name: Setup Java (temurin@17)
70+
id: setup-java-temurin-17
4971
if: matrix.java == 'temurin@17'
50-
uses: actions/setup-java@v2
72+
uses: actions/setup-java@v4
5173
with:
5274
distribution: temurin
5375
java-version: 17
76+
cache: sbt
5477

55-
- name: Cache sbt
56-
uses: actions/cache@v2
57-
with:
58-
path: |
59-
~/.sbt
60-
~/.ivy2/cache
61-
~/.coursier/cache/v1
62-
~/.cache/coursier/v1
63-
~/AppData/Local/Coursier/Cache/v1
64-
~/Library/Caches/Coursier/v1
65-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
78+
- name: sbt update
79+
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
80+
run: sbt +update
6681

6782
- name: Check that workflows are up to date
68-
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
83+
run: sbt githubWorkflowCheck
6984

70-
- run: sbt ++${{ matrix.scala }} testIfRelevant mimaReportBinaryIssues
85+
- run: sbt '++ ${{ matrix.scala }}' testIfRelevant mimaReportBinaryIssues

build.sbt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ lazy val binaryCompatStep = releaseStepCommandAndRemaining("+mimaReportBinaryIss
1313
lazy val testIfRelevantStep = releaseStepCommandAndRemaining("+testIfRelevant")
1414
lazy val publishIfRelevantStep = releaseStepCommandAndRemaining("+publishSignedIfRelevant")
1515

16+
// sonaReleaseIfNecessary is from sbt-typelevel
17+
// https://github.com/typelevel/sbt-typelevel/blob/v0.8.0/sonatype/src/main/scala/org/typelevel/sbt/TypelevelSonatypePlugin.scala#L81-L87
18+
// SPDX-License-Identifier: Apache-2.0
19+
// Copyright 2022 Typelevel
20+
lazy val sonaReleaseIfNecessary: Command =
21+
Command.command("sonaReleaseIfNecessary") { state =>
22+
if (state.getSetting(isSnapshot).getOrElse(false))
23+
state // a snapshot is good-to-go
24+
else // a non-snapshot releases as a bundle
25+
Command.process("sonaRelease", state, _ => ())
26+
}
27+
28+
commands += sonaReleaseIfNecessary
29+
lazy val sonaReleaseIfNecessaryStep = releaseStepCommand("sonaReleaseIfNecessary")
30+
1631
/* This is the standard release process plus a binary compat check after tests */
1732
releaseProcess := Seq[ReleaseStep](
1833
checkSnapshotDependencies,
@@ -24,6 +39,7 @@ releaseProcess := Seq[ReleaseStep](
2439
commitReleaseVersion,
2540
tagRelease,
2641
publishIfRelevantStep,
42+
sonaReleaseIfNecessaryStep,
2743
setNextVersion,
2844
commitNextVersion,
2945
pushChanges

project/BasicSettings.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ trait BasicSettings extends ProjectSettings { st: SettingTemplate =>
6161
} else {
6262
Seq.empty
6363
}
64-
) ++ (
65-
if (sonatypeResolver) {
66-
/* Many OSS projects push here and then appear in Maven Central later */
67-
Seq(resolvers += Resolver.sonatypeRepo("releases"))
68-
} else {
69-
Seq.empty
70-
}
7164
)
7265
)
7366

project/Publish.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import sbt._
1+
import sbt.{Resolvers => _, _}
22
import Keys._
33

44
object Publish {
5-
import Resolvers._
65
import Helpers._
76

87
val sonaCreds = (
@@ -12,7 +11,7 @@ object Publish {
1211
} yield {
1312
credentials +=
1413
Credentials("Sonatype Nexus Repository Manager",
15-
"oss.sonatype.org",
14+
"central.sonatype.com",
1615
user, pass)
1716
}
1817
).toSeq
@@ -23,10 +22,9 @@ object Publish {
2322
Test / publishArtifact := false,
2423

2524
publishTo := {
26-
if (version.value.trim endsWith "SNAPSHOT")
27-
Some(sonatypeSnaps)
28-
else
29-
Some(sonatypeStaging)
25+
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
26+
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
27+
else localStaging.value
3028
},
3129

3230
pomExtra := BasicSettings.developerInfo

project/Resolvers.scala

Lines changed: 0 additions & 8 deletions
This file was deleted.

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.6.2
1+
sbt.version=1.11.2

project/plugin-github-actions.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
1+
addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.8.0")

project/plugin-sonatype.sbt

Lines changed: 0 additions & 4 deletions
This file was deleted.

version.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "1.10.1-SNAPSHOT"
1+
ThisBuild / version := "1.10.1-SNAPSHOT"

0 commit comments

Comments
 (0)