Change to per suite for Scala #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Sign 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 | |
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.scala-test-metrics | |
working-directory: scalatest-listener | |
run: | | |
BUNDLE_FILE=$(find .. -name "bundle.zip" | head -n 1) | |
if [ -z "$BUNDLE_FILE" ]; then | |
echo "Error: No bundle file found" | |
exit 1 | |
fi | |
echo "Found bundle file: $BUNDLE_FILE" | |
AUTH_TOKEN=$(echo -n "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64) | |
RESPONSE=$(curl --fail --location "https://central.sonatype.com/api/v1/publisher/upload?publishingType=${PUBLISH_TYPE_PARAMS}" \ | |
--header "Authorization: Basic ${AUTH_TOKEN}" \ | |
--form "bundle=@${BUNDLE_FILE}" \ | |
--form "name=${BUNDLE_NAME}" \ | |
--write-out "%{http_code}" \ | |
--silent --output /dev/null) | |
if [ $RESPONSE -eq 200 ] || [ $RESPONSE -eq 201 ]; then | |
echo "Successfully published to Maven Central. HTTP status code: $RESPONSE" | |
else | |
echo "Failed to publish to Maven Central. HTTP status code: $RESPONSE" | |
exit 1 | |
fi |