Skip to content

Commit

Permalink
CDF-22157: dual-publish to jfrog & sonatype
Browse files Browse the repository at this point in the history
[CDF-22157]
  • Loading branch information
dmivankov committed Jul 26, 2024
1 parent 72cc873 commit 2db8b6c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
49 changes: 48 additions & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,54 @@ jobs:
with:
token: ${{ secrets.codecov_token }}

publish:
publish_jfrog:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
environment: CD

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
git rev-list --count --first-parent HEAD > patch_version.txt
- name: Set up JDK 8
uses: coursier/setup-action@v1
with:
jvm: adopt:8

- name: Build JAR file
run: |
cat /dev/null | sbt -Dsbt.log.noformat=true +dependencyLockCheck
cat /dev/null | sbt -Dsbt.log.noformat=true -J-Xmx3G -J-XX:+UseG1GC "set Test/test := {}" "set compile/skip := true" +package
- name: Install GPG & Sonatype credentials for SBT
env:
GPG_PUBLIC_KEY: ${{ secrets.SONATYPE_OSSRH_GPG_PUBLIC_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.SONATYPE_OSSRH_GPG_PRIVATE_KEY }}
GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.SONATYPE_OSSRH_GPG_KEY_PASSPHRASE }}
run: |
set -x
echo "$GPG_PUBLIC_KEY" > public.key
gpg --import public.key
echo "$GPG_PRIVATE_KEY" > private.key
gpg --verbose --batch --import-options import-show --import private.key
mkdir -p ~/.sbt/gpg
echo "$GPG_PRIVATE_KEY_PASSPHRASE" | gpg --verbose --batch -a --export-secret-keys --pinentry-mode loopback --passphrase-fd 0 > ~/.sbt/gpg/secring.asc
- name: Publish package
env:
GPG_KEY_PASSWORD: ${{ secrets.SONATYPE_OSSRH_GPG_KEY_PASSPHRASE }}
JFROG_USERNAME: ${{ secrets.ARTIFACTORY_PUBLISH_TOKEN_USER }}
JFROG_PASSWORD: ${{ secrets.ARTIFACTORY_PUBLISH_TOKEN }}
PUBLISH_TO_JFROG: "true"
run: |
sbt -Dsbt.log.noformat=true -J-Xmx3G -J-XX:+UseG1GC +publishSigned
publish_sonatype:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
Expand Down
16 changes: 14 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ credentials += Credentials(
System.getenv("SONATYPE_USERNAME"),
System.getenv("SONATYPE_PASSWORD")
)
credentials += Credentials("Artifactory Realm",
"cognite.jfrog.io",
System.getenv("JFROG_USERNAME"),
System.getenv("JFROG_PASSWORD"),
)

val artifactory = "https://cognite.jfrog.io/cognite"

lazy val commonSettings = Seq(
name := "cognite-sdk-scala",
Expand Down Expand Up @@ -67,11 +74,16 @@ lazy val commonSettings = Seq(
pomIncludeRepository := { _ =>
false
},
publishTo := {
publishTo := (if (System.getenv("PUBLISH_TO_JFROG") == "true") {
if (isSnapshot.value)
Some("snapshots".at(s"$artifactory/libs-snapshot-local/"))
else
Some("local-releases".at(s"$artifactory/libs-release-local/"))
} else {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value) Some("snapshots".at(nexus + "content/repositories/snapshots"))
else Some("releases".at(nexus + "service/local/staging/deploy/maven2"))
},
}),
publishMavenStyle := true,
pgpPassphrase := {
if (gpgPass.isDefined) gpgPass.map(_.toCharArray)
Expand Down

0 comments on commit 2db8b6c

Please sign in to comment.