Skip to content

Commit

Permalink
Switch to releasing with sbt-ci-release under new org (#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed May 7, 2024
1 parent 01ee080 commit d628263
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 111 deletions.
71 changes: 12 additions & 59 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,22 @@
name: release

on:
workflow_dispatch:
inputs:
version:
description: "The release version"
required: true
branch:
description: "The branch to release from"
required: true
default: 'master'

push:
branches: [master]
tags: ["*"]
jobs:
release:
publish:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Launch elastic docker
run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.12.2

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: publish 2.12 release
run: sbt ++2.12.12 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

- name: publish 2.13 release
run: sbt ++2.13.4 publishSigned
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

- name: publish 3.0 release
run: sbt ++3.3.0 elastic4s-scala3/publishSigned
- run: sbt ci-release
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

- name: tag release
run: |
git tag v${{ github.event.inputs.version }}
git push --tags
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
65 changes: 19 additions & 46 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Dependencies._

ThisBuild / organizationName := "com.sksamuel.elastic4s"

// Required due to dependency conflict in SBT
// See https://github.com/sbt/sbt/issues/6997
ThisBuild / libraryDependencySchemes ++= Seq(
Expand All @@ -14,17 +12,9 @@ def isGithubActions = sys.env.getOrElse("CI", "false") == "true"
def releaseVersion: String = sys.env.getOrElse("RELEASE_VERSION", "")
def isRelease = releaseVersion != ""

// the version to use to publish - either from release version or a snapshot run number
def publishVersion = if (isRelease) releaseVersion else "8.6.0." + githubRunNumber + "-SNAPSHOT"

// set by github actions and used as the snapshot build number
def githubRunNumber = sys.env.getOrElse("GITHUB_RUN_NUMBER", "local")

// creds for release to maven central
def ossrhUsername = sys.env.getOrElse("OSSRH_USERNAME", "")
def ossrhPassword = sys.env.getOrElse("OSSRH_PASSWORD", "")


val scala2Versions = Seq("2.12.19", "2.13.14")
val scalaAllVersions = scala2Versions :+ "3.3.3"

Expand All @@ -42,27 +32,15 @@ lazy val warnUnusedImport = Seq(
)

lazy val commonSettings = Seq(
organization := "com.sksamuel.elastic4s",
version := publishVersion,
organization := "nl.gn0s1s",
resolvers ++= Seq(Resolver.mavenLocal),
Test / parallelExecution := false,
Compile / doc / scalacOptions := (Compile / doc / scalacOptions).value.filter(_ != "-Xfatal-warnings"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8")
)

lazy val publishSettings = Seq(
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := Function.const(false),
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isRelease)
Some("releases" at nexus + "service/local/staging/deploy/maven2")
else
Some("snapshots" at nexus + "content/repositories/snapshots")
}
Test / publishArtifact := false
)

lazy val commonJvmSettings = Seq(
Expand All @@ -76,28 +54,24 @@ lazy val commonJvmSettings = Seq(
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:+CMSClassUnloadingEnabled"),
)


lazy val pomSettings = Seq(
homepage := Some(url("https://github.com/sksamuel/elastic4s")),
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(ScmInfo(url("https://github.com/sksamuel/elastic4s"), "scm:git:git@github.com:sksamuel/elastic4s.git")),
apiURL := Some(url("http://github.com/sksamuel/elastic4s/")),
pomExtra := <developers>
<developer>
<id>sksamuel</id>
<name>Sam Samuel</name>
<url>https://github.com/sksamuel</url>
</developer>
</developers>
)

lazy val credentialSettings = Seq(
credentials := Seq(Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
sys.env.getOrElse("OSSRH_USERNAME", ""),
sys.env.getOrElse("OSSRH_PASSWORD", "")
))
startYear := Some(2013),
homepage := Some(url("https://github.com/philippus/elastic4s")),
licenses += License.Apache2,
developers := List(
Developer(
id = "Philippus",
name = "Philippus Baalman",
email = "",
url = url("https://github.com/philippus")
),
Developer(
id = "sksamuel",
name = "Samuel",
email = "",
url = url("https://github.com/sksamuel")
)
)
)

lazy val noPublishSettings = Seq(
Expand All @@ -111,7 +85,6 @@ lazy val allSettings = commonScalaVersionSettings ++
commonJvmSettings ++
commonSettings ++
commonDeps ++
credentialSettings ++
pomSettings ++
warnUnusedImport ++
publishSettings
Expand Down
6 changes: 1 addition & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "7.9.3-SNAPSHOT"
ThisBuild / version := "8.12.0-SNPSHOT"

0 comments on commit d628263

Please sign in to comment.