Skip to content

Add Scalatest Listener (#9) #32

Add Scalatest Listener (#9)

Add Scalatest Listener (#9) #32

Workflow file for this run

name: Scala CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
MAJOR_MINOR_VERSION: 0.1.
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: "11"
distribution: "adopt"
- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
- name: Run tests
working-directory: scalatest-listener
run: sbt test
- name: Build project
working-directory: scalatest-listener
run: sbt compile
- name: Prepare and Signed Artifact
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_SECRET_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
BUNDLE_VERSION_NUMBER: ${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}
BUNDLE_PATH: ./target/sonatype-staging/0.1.0-SNAPSHOT
working-directory: scalatest-listener
run: |
echo "$GPG_PRIVATE_KEY" | gpg --import --batch
echo "$GPG_PUBLIC_KEY" | gpg --import --batch
mkdir -p $HOME/.sbt/gpg
gpg --batch --pinentry-mode=loopback --yes --passphrase $GPG_PASSPHRASE --output $HOME/.sbt/gpg/secring.asc --export-secret-key --armor
sbt publishSigned
cd $BUNDLE_PATH && zip -r ${GITHUB_WORKSPACE}/bundle.zip .
- name: Publish to Maven Central
env:
SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
PUBLISH_TYPE_PARAMS: AUTOMATIC
BUNDLE_NAME: io.agodadev.testmetricsscala
working-directory: scalatest-listener
run: |
AUTH_TOKEN=$(echo -n "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64)
curl --location "https://central.sonatype.com/api/v1/publisher/upload?publishingType=${PUBLISH_TYPE_PARAMS}" \
--header "Authorization: Bearer ${AUTH_TOKEN}" \
--form "bundle=@${GITHUB_WORKSPACE}/bundle.zip" \
--form "name=${BUNDLE_NAME}"
# Optional: Add a step to publish the artifact if needed
# - name: Publish artifact
# working-directory: scalatest-listener
# run: sbt publish
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Optional: Add a step to generate and publish code coverage report
# - name: Generate code coverage report
# working-directory: scalatest-listener
# run: sbt coverage test coverageReport
#
# - name: Publish code coverage
# uses: codecov/codecov-action@v1