From 5ef6499da03b0683bea305ff309a327dcfcbebc0 Mon Sep 17 00:00:00 2001 From: Rowanne Kabalan Date: Thu, 30 Nov 2023 15:55:21 +0000 Subject: [PATCH] Experiment --- .github/workflows/release.yml | 60 ++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16b9a528..381132cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,11 +6,55 @@ jobs: sbt_release: runs-on: ubuntu-latest steps: - - uses: guardian/actions-sbt-release@v3 - with: - pgpSecret: ${{ secrets.PGP_SECRET }} - pgpPassphrase: ${{ secrets.PGP_PASSPHRASE }} - sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} - sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} - isSnapshot: ${{ github.event.release.prerelease }} - CAPI_TEST_KEY: ${{ secrets.CAPI_TEST_KEY }} + - uses: actions/checkout@v3 + with: + fetch-depth: ${{ inputs.fetchDepth }} + - uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + cache: sbt + - name: Use supplied version + if: ${{ inputs.version != '' }} + shell: bash + run: | + echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV" + - name: Get version to publish as + if: ${{ inputs.version == '' }} + shell: bash + run: | + git describe --tags --exact-match HEAD || exit 1 + VERSION=$(git describe --tags | cut -f2 -d"@") + if [[ ${VERSION:0:1} == "v" ]] ; then + VERSION=${VERSION:1} + fi + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" + - name: Optionally set snapshot version + if: ${{ inputs.isSnapshot != 'false' }} + shell: bash + run: | + if [[ ${VERSION: -9} != "-SNAPSHOT" ]] ; then + echo "Version must end in -SNAPSHOT. Adding -SNAPSHOT suffix" + VERSION="$VERSION-SNAPSHOT" + fi + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" + - name: Import PGP key if there is one + if: ${{ inputs.pgpSecret != '' }} + shell: bash + run: "echo $PGP_SECRET | base64 --decode | gpg --batch --import" + env: + PGP_SECRET: ${{ inputs.pgpSecret }} + PGP_PASSPHRASE: ${{ inputs.pgpPassphrase }} + - name: Run sbt release + shell: bash + run: + export GPG_TTY=$(tty) + RELEASE_TYPE="${{ github.event.release.prerelease && 'snapshot' || 'production' }}" + echo "Releasing version $VERSION Sonatype as $RELEASE_TYPE" + sbt -DRELEASE_TYPE=$RELEASE_TYPE "clean" "release cross release-version $VERSION with-defaults" + env: + PGP_PASSPHRASE: ${{ inputs.pgpPassphrase }} + SONATYPE_USERNAME: ${{ inputs.sonatypeUsername }} + SONATYPE_PASSWORD: ${{ inputs.sonatypePassword }} + CAPI_TEST_KEY: ${{ secrets.CAPI_TEST_KEY }} + isSnapshot: ${{ github.event.release.prerelease }} \ No newline at end of file