From 403ee15640aa7e268dda5d6e0ee1806494495e70 Mon Sep 17 00:00:00 2001 From: Tony McCrae Date: Thu, 9 Nov 2023 12:32:54 +0000 Subject: [PATCH] Take release.yml directly from firehose client. --- .github/workflows/release.yml | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..66f1cb2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release Sonatype + +on: + release: + types: [published] + +jobs: + release_snapshot_sonatype: + if: "github.event.release.prerelease" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + base: main #see https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#pull-request-events + - 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 }} + + release_production_sonatype: + if: "! github.event.release.prerelease" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + base: main #see https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#pull-request-events + - uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + cache: sbt + - name: Release Production 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 NOT end in -SNAPSHOT." + exit 1 + fi + echo $PGP_SECRET | base64 --decode | gpg --batch --import + export GPG_TTY=$(tty) + echo "Releasing version $VERSION Sonatype as production" + yes | sbt -DRELEASE_TYPE=production "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 }} \ No newline at end of file