Skip to content

Commit

Permalink
Update release.yml to use new action
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Roberts <[email protected]>
  • Loading branch information
Rowanne Kabalan and paulmr committed Nov 22, 2023
1 parent 176d2cd commit 22a6f22
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 47 deletions.
47 changes: 16 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
name: Release Sonatype
name: 'Publish Release'

on:
release:
types: [published]
workflow_dispatch:
inputs:
isSnapshot:
description: Produce a snapshot release
required: true
default: true
type: boolean

jobs:
release_snapshot_sonatype:
if: "github.event.release.prerelease"
sbt_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: guardian/actions-sbt-release@v3
with:
base: main
- uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11
cache: sbt
- name: Release Snapshot (prerelease) to Sonatype
run: |
VERSION=$(git describe --tags | cut -f2 -d"@")
if [[ ${VERSION:0:1} == "v" ]] ; then
VERSION=${VERSION:1}
fi
if [[ ${VERSION: -9} != "-SNAPSHOT" ]] ; then
echo "Version must end in -SNAPSHOT. Adding -SNAPSHOT suffix"
VERSION="$VERSION-SNAPSHOT"
fi
echo $PGP_SECRET | base64 --decode | gpg --batch --import
export GPG_TTY=$(tty)
echo "Releasing version $VERSION Sonatype as snapshot"
yes | sbt -DRELEASE_TYPE=snapshot "clean" "release cross release-version $VERSION with-defaults"
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
fetchDepth: 0
pgpSecret: ${{ secrets.PGP_SECRET }}
pgpPassphrase: ${{ secrets.PGP_PASSPHRASE }}
sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
isSnapshot: ${{ github.event.release.prerelease }}
39 changes: 24 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,35 @@ lazy val atomManagerPlay = (project in file("./atom-manager-play-lib"))
.settings(Test / publishArtifact := true)
.dependsOn(atomPublisher % "test->test;compile->compile")

lazy val commonReleaseProcess = Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
setReleaseVersion,
runClean,
runTest,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
)

lazy val productionReleaseProcess = commonReleaseProcess ++ Seq[ReleaseStep](
releaseStepCommand("sonatypeBundleRelease"),
)

lazy val snapshotReleaseProcess = commonReleaseProcess

lazy val atomLibraries = (project in file("."))
.aggregate(atomPublisher, atomManagerPlay)
.settings(baseSettings: _*).settings(
publishArtifact := false,
publish := {},
publishLocal := {},
releaseCrossBuild := true, // true if you cross-build the project for multiple Scala versions
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
releaseProcess := {
sys.props.get("RELEASE_TYPE") match {
case Some("production") => productionReleaseProcess
case _ => snapshotReleaseProcess
}
}
)

resolvers ++= Resolver.sonatypeOssRepos("snapshots")
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit 22a6f22

Please sign in to comment.