Skip to content

Commit 72fa177

Browse files
committed
Update build.sbt and workflows to publish to Central.
1 parent bc431e2 commit 72fa177

File tree

6 files changed

+34
-214
lines changed

6 files changed

+34
-214
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,9 @@ jobs:
3737
- name: Launch pulsar docker
3838
run: docker-compose up -d
3939

40-
- name: Import GPG key
41-
id: import_gpg
42-
uses: crazy-max/ghaction-import-gpg@v3
43-
with:
44-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
45-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
46-
47-
- name: GPG user IDs
48-
run: |
49-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
50-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
51-
echo "name: ${{ steps.import_gpg.outputs.name }}"
52-
echo "email: ${{ steps.import_gpg.outputs.email }}"
5340
- name: run tests
5441
run: sbt ++2.12 test
5542

56-
- name: publish snapshot
57-
run: sbt ++2.12 publish
58-
env:
59-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
60-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
61-
6243
scala-2_13:
6344
runs-on: ubuntu-latest
6445
steps:
@@ -84,29 +65,9 @@ jobs:
8465
- name: Launch pulsar docker
8566
run: docker-compose up -d
8667

87-
- name: Import GPG key
88-
id: import_gpg
89-
uses: crazy-max/ghaction-import-gpg@v3
90-
with:
91-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
92-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
93-
94-
- name: GPG user IDs
95-
run: |
96-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
97-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
98-
echo "name: ${{ steps.import_gpg.outputs.name }}"
99-
echo "email: ${{ steps.import_gpg.outputs.email }}"
100-
10168
- name: run tests
10269
run: sbt ++2.13 test
10370

104-
- name: publish snapshot
105-
run: sbt ++2.13 publish
106-
env:
107-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
108-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
109-
11071
scala-3:
11172
runs-on: ubuntu-latest
11273
steps:
@@ -132,25 +93,5 @@ jobs:
13293
- name: Launch pulsar docker
13394
run: docker-compose up -d
13495

135-
- name: Import GPG key
136-
id: import_gpg
137-
uses: crazy-max/ghaction-import-gpg@v3
138-
with:
139-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
140-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
141-
142-
- name: GPG user IDs
143-
run: |
144-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
145-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
146-
echo "name: ${{ steps.import_gpg.outputs.name }}"
147-
echo "email: ${{ steps.import_gpg.outputs.email }}"
148-
14996
- name: run tests
15097
run: sbt ++3.6 test
151-
152-
- name: publish snapshot
153-
run: sbt ++3.6 publish
154-
env:
155-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
156-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

.github/workflows/release.yml

Lines changed: 8 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
default: "master"
1313

1414
jobs:
15-
release-scala-2-12:
15+
release:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: checkout the repo
@@ -37,122 +37,14 @@ jobs:
3737
- name: Launch pulsar docker
3838
run: docker-compose up -d
3939

40-
- name: Import GPG key
41-
id: import_gpg
42-
uses: crazy-max/ghaction-import-gpg@v6
43-
with:
44-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
45-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
46-
47-
- name: GPG user IDs
48-
run: |
49-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
50-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
51-
echo "name: ${{ steps.import_gpg.outputs.name }}"
52-
echo "email: ${{ steps.import_gpg.outputs.email }}"
53-
54-
- name: run tests
55-
run: sbt ++2.12 test
56-
57-
- name: publish release
58-
run: sbt ++2.12 publishSigned
59-
env:
60-
RELEASE_VERSION: ${{ github.event.inputs.version }}
61-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
62-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
63-
64-
release-scala-2-13:
65-
runs-on: ubuntu-latest
66-
steps:
67-
- name: checkout the repo
68-
uses: actions/checkout@v2
69-
with:
70-
fetch-depth: 0
71-
72-
- uses: awalsh128/cache-apt-pkgs-action@latest
73-
with:
74-
packages: docker-compose
75-
version: 1.0
76-
77-
- name: Set up JDK
78-
uses: actions/setup-java@v4
79-
with:
80-
distribution: temurin
81-
java-version: 17
82-
83-
- name: Setup sbt launcher
84-
uses: sbt/setup-sbt@v1
85-
86-
- name: Launch pulsar docker
87-
run: docker-compose up -d
88-
89-
- name: Import GPG key
90-
id: import_gpg
91-
uses: crazy-max/ghaction-import-gpg@v6
92-
with:
93-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
94-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
95-
96-
- name: GPG user IDs
97-
run: |
98-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
99-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
100-
echo "name: ${{ steps.import_gpg.outputs.name }}"
101-
echo "email: ${{ steps.import_gpg.outputs.email }}"
102-
103-
- name: run tests
104-
run: sbt ++2.13 test
105-
106-
- name: publish release
107-
run: sbt ++2.13 publishSigned
108-
env:
109-
RELEASE_VERSION: ${{ github.event.inputs.version }}
110-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
111-
112-
release-scala-3:
113-
runs-on: ubuntu-latest
114-
steps:
115-
- name: checkout the repo
116-
uses: actions/checkout@v2
117-
with:
118-
fetch-depth: 0
119-
120-
- uses: awalsh128/cache-apt-pkgs-action@latest
121-
with:
122-
packages: docker-compose
123-
version: 1.0
124-
125-
- name: Set up JDK
126-
uses: actions/setup-java@v4
127-
with:
128-
distribution: temurin
129-
java-version: 17
130-
131-
- name: Setup sbt launcher
132-
uses: sbt/setup-sbt@v1
133-
134-
- name: Launch pulsar docker
135-
run: docker-compose up -d
136-
137-
- name: Import GPG key
138-
id: import_gpg
139-
uses: crazy-max/ghaction-import-gpg@v6
140-
with:
141-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
142-
passphrase: ${{ secrets.PGP_PASSPHRASE }}
143-
144-
- name: GPG user IDs
145-
run: |
146-
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
147-
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
148-
echo "name: ${{ steps.import_gpg.outputs.name }}"
149-
echo "email: ${{ steps.import_gpg.outputs.email }}"
150-
15140
- name: run tests
152-
run: sbt ++3.6 test
41+
run: sbt + test
15342

15443
- name: publish release
155-
run: sbt ++3.6 publishSigned
15644
env:
157-
RELEASE_VERSION: ${{ github.event.inputs.version }}
158-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
45+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
46+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
47+
SONATYPE_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
48+
SONATYPE_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
49+
CI_SONATYPE_RELEASE: sonatypeBundleRelease
50+
run: sbt ci-release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.idea
44
*.iml
55
pom.xml.versionsBackup
6+
.env*
67

78
# sbt specific
89
dist/*

build.sbt

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import xerial.sbt.Sonatype.sonatypeCentralHost
2+
3+
ThisBuild / sonatypeCredentialHost := sonatypeCentralHost
4+
15
def isGithubActions = sys.env.getOrElse("CI", "false") == "true"
26
def releaseVersion = sys.env.getOrElse("RELEASE_VERSION", "")
37
def isRelease = releaseVersion != ""
48
def githubRunNumber = sys.env.getOrElse("GITHUB_RUN_NUMBER", "")
5-
def ossrhUsername = sys.env.getOrElse("OSSRH_USERNAME", "")
6-
def ossrhPassword = sys.env.getOrElse("OSSRH_PASSWORD", "")
79
def publishVersion = if (isRelease) releaseVersion else if (isGithubActions) "2.9.0." + githubRunNumber + "-SNAPSHOT" else "0.0.0-LOCAL"
810

911
val org = "com.clever-cloud.pulsar4s"
@@ -50,7 +52,7 @@ lazy val warnUnusedImport = Seq(
5052
)
5153

5254
lazy val commonSettings = Seq(
53-
organization := "com.clever-cloud.pulsar4s",
55+
organization := org,
5456
version := publishVersion,
5557
resolvers ++= Seq(Resolver.mavenLocal),
5658
Test / parallelExecution := false,
@@ -67,22 +69,9 @@ lazy val commonSettings = Seq(
6769
)
6870

6971
lazy val publishSettings = Seq(
70-
publishMavenStyle := true,
7172
Test / publishArtifact := false,
7273
pomIncludeRepository := Function.const(false),
73-
credentials += Credentials(
74-
"Sonatype Nexus Repository Manager",
75-
"s01.oss.sonatype.org",
76-
ossrhUsername,
77-
ossrhPassword
78-
),
79-
publishTo := {
80-
val nexus = "https://s01.oss.sonatype.org/"
81-
if (isRelease)
82-
Some("releases" at nexus + "service/local/staging/deploy/maven2")
83-
else
84-
Some("snapshots" at nexus + "content/repositories/snapshots")
85-
}
74+
usePgpKeyHex("A7B8F38C536F1DF2"),
8675
)
8776

8877
lazy val commonJvmSettings = Seq(
@@ -125,34 +114,19 @@ lazy val pomSettings = Seq(
125114
</developers>
126115
)
127116

128-
val travisCreds = Credentials(
129-
"Sonatype Nexus Repository Manager",
130-
"s01.oss.sonatype.org",
131-
sys.env.getOrElse("OSSRH_USERNAME", ""),
132-
sys.env.getOrElse("OSSRH_PASSWORD", "")
133-
)
134-
135-
val localCreds = Credentials(Path.userHome / ".sbt" / "credentials.sbt")
136-
137-
lazy val credentialSettings = Seq(
138-
credentials := (if (isGithubActions) Seq(travisCreds) else Seq(localCreds))
139-
)
140-
141-
lazy val noPublishSettings = Seq(
142-
publish := {},
143-
publishLocal := {},
144-
publishArtifact := false
145-
)
146-
147117
lazy val allSettings = commonScalaVersionSettings ++
148118
commonJvmSettings ++
149119
commonSettings ++
150120
commonDeps ++
151-
credentialSettings ++
152121
pomSettings ++
153122
warnUnusedImport ++
154123
publishSettings
155124

125+
lazy val noPublishSettings = Seq(
126+
publish := {},
127+
publishLocal := {},
128+
publishArtifact := false
129+
)
156130

157131
lazy val root = Project("pulsar4s", file("."))
158132
.settings(name := "pulsar4s")

project/plugins.sbt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
resolvers += Classpaths.sbtPluginReleases
2-
31
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
2+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.3+0-8f89fa50+20250524-0110-SNAPSHOT")
3+
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
4+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2")
5+
6+

sonatype.sbt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// To sync with Maven central, you need to supply the following information:
2+
publishMavenStyle := true
3+
4+
// Open-source license of your choice
5+
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0"))
6+
7+
// Where is the source code hosted: GitHub or GitLab?
8+
import xerial.sbt.Sonatype._
9+
sonatypeProjectHosting := Some(GitHubHosting("clevercloud", "pulsar4s", "julien.durillon@clever-cloud.com"))

0 commit comments

Comments
 (0)