Skip to content

Commit

Permalink
switch from sbt-git to sbt-dynver for git-based versioning;
Browse files Browse the repository at this point in the history
switch to new GPG key import;
  • Loading branch information
greenhat committed Sep 23, 2021
1 parent 571ebb7 commit d81eb51
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 71 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -31,9 +31,14 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Publish release ${{ github.ref }}
run: ci/publish_release_gpg2.sh
- name: Import GPG key
run: ci/import_gpg.sh
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: Publish release
run: sbt +ergoWallet/publishSigned sonatypeBundleRelease
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
34 changes: 5 additions & 29 deletions build.sbt
Expand Up @@ -296,39 +296,15 @@ credentials ++= (for {
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq

enablePlugins(GitVersioning)

version in ThisBuild := {
if (git.gitCurrentTags.value.nonEmpty) {
git.gitDescribedVersion.value.get
} else {
if (git.gitHeadCommit.value.contains(git.gitCurrentBranch.value)) {
// see https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
if (Try(sys.env("TRAVIS")).getOrElse("false") == "true") {
// pull request number, "false" if not a pull request
if (Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false") {
// build is triggered by a pull request
val prBranchName = Try(sys.env("TRAVIS_PULL_REQUEST_BRANCH")).get
val prHeadCommitSha = Try(sys.env("TRAVIS_PULL_REQUEST_SHA")).get
prBranchName + "-" + prHeadCommitSha.take(8) + "-SNAPSHOT"
} else {
// build is triggered by a push
val branchName = Try(sys.env("TRAVIS_BRANCH")).get
branchName + "-" + git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitCurrentBranch.value + "-" + git.gitHeadCommit.value.getOrElse("").take(8) + "-SNAPSHOT"
}
}
}

def javacReleaseOption = {
if (System.getProperty("java.version").startsWith("1."))
// java <9 "--release" is not supported
Seq()
else
Seq("--release", "8")
}

// prefix version with "-SNAPSHOT" for builds without a git tag
dynverSonatypeSnapshots in ThisBuild := true
// use "-" instead of default "+"
dynverSeparator in ThisBuild := "-"
13 changes: 7 additions & 6 deletions ci/publish_release_gpg2.sh → ci/import_gpg.sh
Expand Up @@ -3,6 +3,7 @@
# via https://github.com/beautiful-scala/scalastyle/blob/master/.github/workflows/release.yml#L16
# from https://github.com/olafurpg/sbt-ci-release/issues/95

# setup gpg
mkdir ~/.gnupg && chmod 700 ~/.gnupg
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
Expand All @@ -11,10 +12,10 @@ chmod 600 ~/.gnupg/*
echo RELOADAGENT | gpg-connect-agent

# decode key
openssl aes-256-cbc -K $encrypted_394e5a7bea7c_key -iv $encrypted_394e5a7bea7c_iv -in ci/secring.asc.enc -out ci/secring.asc -d
# import key
gpg --no-tty --batch --yes --import ci/secring.asc

# publish
sbt +ergoWallet/publishSigned sonatypeBundleRelease
# private key should be previously exported with:
# gpg --export-secret-keys [id] | base64 | pbcopy
# and stored as github repository secret under the following name (see env var name below)
printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key

# import key
gpg --no-tty --batch --yes --import ~/.gnupg/private.key
30 changes: 0 additions & 30 deletions ci/pubring.asc

This file was deleted.

Binary file removed ci/secring.asc.enc
Binary file not shown.
6 changes: 3 additions & 3 deletions project/plugins.sbt
Expand Up @@ -20,10 +20,10 @@ addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")

addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.25")
addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.25")

addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")

0 comments on commit d81eb51

Please sign in to comment.