Skip to content

Update build.yml to add code coverage #22

Update build.yml to add code coverage

Update build.yml to add code coverage #22

Workflow file for this run

name: Build
on:
push:
branches:
- master
tags-ignore:
- '*'
paths-ignore:
- README.adoc
pull_request:
branches:
- master
paths-ignore:
- README.adoc
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- id: get-snapshot-version
name: Generate snapshot version
shell: bash
run: |
version=$(git describe --tag --abbrev=0 | cut -c 2-)
regex="^([0-9]+).([0-9]+).([0-9]+)$"
if [[ $version =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
patch=$(($patch + 1))
snapshot_version="${major}.${minor}.${patch}"
if ! [[ $snapshot_version =~ $regex ]]; then
echo "SNAPSHOT version $snapshot_version is not a valid SemVer"
exit 1
fi
echo "${snapshot_version}-SNAPSHOT"
echo "snapshot-version=${snapshot_version}-SNAPSHOT" >> $GITHUB_OUTPUT
else
echo "Version $version is not a valid SemVer"
exit 1
fi
- name: Build
run: ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} build
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Upload SNAPSHOT artifacts to Sonatype
id: upload_release_artifacts
if: ${{ github.ref == 'refs/heads/master' }}
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIV_KEY: ${{ secrets.GPG_PRIV_KEY }}
GPG_PASS_PHRASE: ${{ secrets.GPG_PASS_PHRASE }}
run: ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepository
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}